org.aitools.programd.test.aiml
Class TestCase

java.lang.Object
  extended by org.aitools.programd.test.aiml.TestCase

public class TestCase
extends Object

A TestCase contains an inputs and a set of checkers that test the response to that inputs.

Author:
Albertas Mickensas, Noel Bush

Field Summary
protected  List<Checker> checkers
          The checker(s) contained in this test case.
protected  String input
          The inputs that this test case should send.
protected  String lastResponse
          The last response received by this test case.
protected  String name
          The name of this test case.
static String TAG_DESCRIPTION
          The string "".
static String TAG_INPUT
          The string "".
static String TAG_TESTCASE
          The string "".
 
Constructor Summary
TestCase(Element element, String encoding, int index)
          Creates a new TestCase from the given XML element.
TestCase(String testInput)
          Constructs a basic TestCase with just an input.
TestCase(String testInput, String expectedAnswer)
          Constructs a basic TestCase with an input and an expected answer (utility constructor).
 
Method Summary
 void addChecker(Checker checker)
          Adds a given checker.
 boolean equals(Object obj)
           
 List<String[]> getDescription()
          Produces a map of checker names to contents that can be used to describe the test case textually.
 String getInput()
           
 String getLastResponse()
           
 String getName()
           
 int hashCode()
           
 void removeCheckers()
          Removes all checkers.
 boolean run(Multiplexor multiplexor, String userid, String botid)
          Runs this test case for the given botid.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_TESTCASE

public static String TAG_TESTCASE
The string "".


TAG_DESCRIPTION

public static String TAG_DESCRIPTION
The string "".


TAG_INPUT

public static String TAG_INPUT
The string "".


name

protected String name
The name of this test case.


input

protected String input
The inputs that this test case should send.


checkers

protected List<Checker> checkers
The checker(s) contained in this test case.


lastResponse

protected String lastResponse
The last response received by this test case.

Constructor Detail

TestCase

public TestCase(Element element,
                String encoding,
                int index)
Creates a new TestCase from the given XML element.

Parameters:
element - the TestCase element
encoding - the encoding of the document from which this element comes
index - a default index to use for automatically naming this case

TestCase

public TestCase(String testInput,
                String expectedAnswer)
Constructs a basic TestCase with an input and an expected answer (utility constructor).

Parameters:
testInput - the input to use
expectedAnswer - the answer to expect

TestCase

public TestCase(String testInput)
Constructs a basic TestCase with just an input.

Parameters:
testInput - the input to use
Method Detail

getName

public String getName()
Returns:
the name of this test case

getInput

public String getInput()
Returns:
the input to be sent by this test case

getLastResponse

public String getLastResponse()
Returns:
the last response received by this test case

run

public boolean run(Multiplexor multiplexor,
                   String userid,
                   String botid)
Runs this test case for the given botid.

Parameters:
multiplexor - the Multiplexor to use for testing
userid - the userid to use when testing
botid - the bot for whom to run this test case
Returns:
whether the test passed

getDescription

public List<String[]> getDescription()
Produces a map of checker names to contents that can be used to describe the test case textually.

Returns:
a map of checker names to contents that can be used to describe the test case textually

removeCheckers

public void removeCheckers()
Removes all checkers.


addChecker

public void addChecker(Checker checker)
Adds a given checker.

Parameters:
checker - the checker to add

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()