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)

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.

Constructors

Link copied to clipboard
constructor(script: DecisionScript.() -> Unit)

Properties

Link copied to clipboard

How many decisions of the script the model has not given yet. 0 when the whole script was used.

Link copied to clipboard

Every request the model received so far, oldest first, also those of a call that failed.

Functions

Link copied to clipboard
open suspend override fun decide(request: DecisionRequest): DecisionResponse