org.aitools.programd.test.aiml
Class TestCase

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

public class TestCase
extends java.lang.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  java.util.List<Checker> checkers
          The checker(s) contained in this test case.
protected  java.lang.String input
          The inputs that this test case should send.
protected  java.lang.String lastResponse
          The last response received by this test case.
protected  java.lang.String name
          The name of this test case.
static java.lang.String TAG_DESCRIPTION
          The string "".
static java.lang.String TAG_INPUT
          The string "".
static java.lang.String TAG_TESTCASE
          The string "".
 
Constructor Summary
private TestCase()
          A private constructor, for use in persistence.
  TestCase(org.w3c.dom.Element element, java.lang.String encoding, int index)
          Creates a new TestCase from the given XML element.
  TestCase(java.lang.String testInput)
          Constructs a basic TestCase with just an input.
  TestCase(java.lang.String testInput, java.lang.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(java.lang.Object obj)
           
 java.util.List<java.lang.String[]> getDescription()
          Produces a map of checker names to contents that can be used to describe the test case textually.
 java.lang.String getInput()
           
 java.lang.String getLastResponse()
           
 java.lang.String getName()
           
 int hashCode()
           
 void removeCheckers()
          Removes all checkers.
private  boolean responseIsValid(java.lang.String response)
          Response is valid if at least one of the checkers returns a positive result.
 boolean run(Multiplexor multiplexor, java.lang.String userid, java.lang.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 java.lang.String TAG_TESTCASE
The string "".


TAG_DESCRIPTION

public static java.lang.String TAG_DESCRIPTION
The string "".


TAG_INPUT

public static java.lang.String TAG_INPUT
The string "".


name

protected java.lang.String name
The name of this test case.


input

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


checkers

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


lastResponse

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

Constructor Detail

TestCase

public TestCase(org.w3c.dom.Element element,
                java.lang.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(java.lang.String testInput,
                java.lang.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(java.lang.String testInput)
Constructs a basic TestCase with just an input.

Parameters:
testInput - the input to use

TestCase

private TestCase()
A private constructor, for use in persistence.

Method Detail

getName

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

getInput

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

getLastResponse

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

run

public boolean run(Multiplexor multiplexor,
                   java.lang.String userid,
                   java.lang.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

responseIsValid

private boolean responseIsValid(java.lang.String response)
Response is valid if at least one of the checkers returns a positive result.

Parameters:
response - the response to check
Returns:
whether or not the response is valud

getDescription

public java.util.List<java.lang.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(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

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