public abstract class TestDialogueChannel<I extends InputTurn,O extends OutputTurn,F extends FirstTurn,L extends LastTurn,C extends DialogueContext<I,O>> extends Object implements DialogueChannel<I,O>
DialogueChannel
is intended for unit testing. Test case acts as the controller and interact
with the dialogue channel. Dialogue steps can be obtained and asserted.Constructor and Description |
---|
TestDialogueChannel(String name,
Duration defaultTimeout) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(DialogueChannelListener<I,O> listener)
Adds a listener to this dialogue channel.
|
void |
dispose() |
I |
doTurn(O outputTurn,
Duration timeout)
Performs a turn exchange: the dialogue channel will return the
InputTurn |
void |
dumpLogs() |
void |
dumpLogs(LogLevel logLevel) |
SynchronousDialogueChannel<I,O,F,L,C> |
getChannel() |
void |
getDefaultTimeout(Duration defaultTimeout) |
Step<O,L> |
getLastStep() |
Throwable |
getLastStepAsError() |
L |
getLastStepAsLastTurn() |
O |
getLastStepAsOutputTurn() |
Logger |
getLogger() |
Step<O,L> |
processInputTurn(I inputTurn) |
Step<O,L> |
processInputTurn(I inputTurn,
Duration timeout) |
void |
removeListener(DialogueChannelListener<I,O> listener)
Removes a listener from this dialogue channel.
|
void |
setDefaultTimeout(Duration defaultTimeout) |
Step<O,L> |
startDialogue(Dialogue<I,O,F,L,C> dialogue,
F firstTurn,
C dialogueContext) |
Step<O,L> |
startDialogue(Dialogue<I,O,F,L,C> dialogue,
F firstTurn,
Duration timeout,
C dialogueContext) |
void |
stop() |
public TestDialogueChannel(String name, Duration defaultTimeout)
public I doTurn(O outputTurn, Duration timeout) throws Timeout, InterruptedException
DialogueChannel
InputTurn
doTurn
in interface DialogueChannel<I extends InputTurn,O extends OutputTurn>
outputTurn
- The output turn to send. Cannot be null
.timeout
- maximum time allowed to receive the turn from the
dialogue. If null
, uses the default value of this
dialogue channel. A value of Duration.ZERO (or equivalent)
means to wait forever.InputTurn
. Cannot be null
.Timeout
- if the dialogue channel has not been able to give the
InputTurn before timeout
parameter.InterruptedException
- if the thread has been interrupted while
waiting for the result.public void addListener(DialogueChannelListener<I,O> listener)
DialogueChannel
addListener
in interface DialogueChannel<I extends InputTurn,O extends OutputTurn>
listener
- the listener to add.public void removeListener(DialogueChannelListener<I,O> listener)
DialogueChannel
removeListener
in interface DialogueChannel<I extends InputTurn,O extends OutputTurn>
listener
- the listener to remove.public void getDefaultTimeout(Duration defaultTimeout)
public void setDefaultTimeout(Duration defaultTimeout)
public void dispose()
public final void stop()
public final Step<O,L> startDialogue(Dialogue<I,O,F,L,C> dialogue, F firstTurn, C dialogueContext)
public final Step<O,L> startDialogue(Dialogue<I,O,F,L,C> dialogue, F firstTurn, Duration timeout, C dialogueContext)
public final Step<O,L> processInputTurn(I inputTurn)
public Step<O,L> getLastStep()
public final O getLastStepAsOutputTurn()
public final L getLastStepAsLastTurn()
public final Throwable getLastStepAsError()
public final SynchronousDialogueChannel<I,O,F,L,C> getChannel()
public final void dumpLogs()
Copyright © 2019 Nu Echo Inc..