tock / ai.tock.bot.test

Package ai.tock.bot.test

Utility methods for unit tests

Types

BotBusMock

A Bus mock used in unit tests.

open class BotBusMock : BotBus

BotBusMockContext

The context of the test.

data class BotBusMockContext

BotBusMockLog

The actions sent by the mocked bus.

data class BotBusMockLog

TestContext

A test context initialized for each test.

open class TestContext

TestLifecycle

open class TestLifecycle<out T : TestContext>

Extensions for External Classes

ch.tutteli.atrium.creating.AssertionPlant

Properties

currentTestContext

The current TestContext used when test parallelism is not a requirement.

var currentTestContext: TestContext

defaultTestConnectorType

Default connector used for tests.

var defaultTestConnectorType: ConnectorType

testModules

Test modules injected in testInjector.

val testModules: MutableList<Module>

testTranslatorModule

Module containing TranslatorEngine.

var testTranslatorModule: Module

Functions

alexa

The Alexa message if any.

fun BotBusMockLog.alexa(): AlexaMessage?

asGenericMessage

fun ConnectorMessage.asGenericMessage(assertionCreator: Assert<GenericMessage>.() -> Unit): Unit

busMock

Provides a mock context initialized with the specified TestContext.

fun busMock(testContext: TestContext = currentTestContext): BotBusMock

ga

The Google Assistant message if any.

fun BotBusMockLog.ga(): GAResponseConnectorMessage?

messenger

The Messenger message if any.

fun BotBusMockLog.messenger(): MessengerConnectorMessage?

newBusMock

Provides a mock initialized with the specified StoryDefinition.

fun BotDefinition.newBusMock(testContext: TestContext = currentTestContext, story: StoryDefinition = testContext.defaultStoryDefinition(this), connectorType: ConnectorType = testContext.defaultConnectorType(), locale: Locale = testContext.defaultLocale(), userId: PlayerId = testContext.defaultPlayerId()): BotBusMock

newBusMockContext

Provides a mock context initialized with the specified StoryDefinition.

fun BotDefinition.newBusMockContext(testContext: TestContext = currentTestContext, story: StoryDefinition = testContext.defaultStoryDefinition(this), connectorType: ConnectorType = testContext.defaultConnectorType(), locale: Locale = testContext.defaultLocale(), userId: PlayerId = testContext.defaultPlayerId(), botId: PlayerId = PlayerId("bot", PlayerType.bot), action: Action = SendSentence(userId, this.botId, botId, ""), userInterfaceType: UserInterfaceType = UserInterfaceType.textChat, userPreferences: UserPreferences = UserPreferences(locale = locale)): BotBusMockContext

slack

The Slack message if any.

fun BotBusMockLog.slack(): SlackConnectorMessage?

startBusMock

Provides a mock context initialized with the specified TestContext and runs the story.

fun startBusMock(testContext: TestContext = currentTestContext): BotBusMock

startNewBusMock

Provides a mock initialized with the specified StoryDefinition and starts the story.

fun BotDefinition.startNewBusMock(testContext: TestContext = currentTestContext, story: StoryDefinition = testContext.defaultStoryDefinition(this), connectorType: ConnectorType = testContext.defaultConnectorType(), locale: Locale = testContext.defaultLocale(), userId: PlayerId = testContext.defaultPlayerId()): BotBusMock

whatsapp

The WhatsApp message if any.

fun BotBusMockLog.whatsapp(): WhatsAppBotMessage?