ScriptedDecisionModel
A DecisionModel for tests: it gives the decisions of its script, in the order they were written, and keeps every request it received. A graph that is routed by a model is tested with it without an API key.
val model = ScriptedDecisionModel {
chooses("refund") // the answer to the first request
no() // the answer to the second one
}
val state = routedSupport(model).invoke(SupportEmail(body = "I want my money back.")).state
assertEquals("refund", state.team)Content copied to clipboard
See DecisionScript for what a script can hold.
A decision of the script answers every question of its request. A model that is asked for more decisions than its script has, or for a decision of another kind than the script wrote, throws an AssertionError that says what it was asked. The engine passes an AssertionError on as it is, so the test fails with that message.
Parameters
script
the decisions of the model, in order.