WowServer

class WowServer(val context: ConfigurableApplicationContext) : AutoCloseable

A Wow application a test started (wowServer): its context, the publicPort and internalPort it bound, and clients of them. A test drives the service as its users do, with the typed clients of the public port: commands sends command objects and queries reads states, both as a caller, through the wow-client a peer calls with. The JSON clients (http, internal) are for what the wire itself must show: a route's shape, a header, a problem's members (Answer.problem). Closing it closes the application and every client.

val alice = Caller.of(subject = "alice", scope = Scope(ownerId = "alice"))
server.commands(alice).wait(Deposit(100), "alice").version.assert().isEqualTo(2)
val account = server.queries(alice).snapshots(AccountState::class.java).state("alice")!!
assertThrows<CommandRejectedException> { server.commands(alice).wait(Withdraw(150), "alice") }
.code.assert().isEqualTo("bank.account.insufficient-balance")

Constructors

Link copied to clipboard
constructor(context: ConfigurableApplicationContext)

Properties

Link copied to clipboard
val context: ConfigurableApplicationContext
Link copied to clipboard

A client of the public port.

Link copied to clipboard

A client of the internal port, made on first use.

Link copied to clipboard

The port of the internal server: the cluster channel, the wait signals, the services' calls.

Link copied to clipboard

The port of the public server: the HTTP API.

Functions

Link copied to clipboard
inline fun <reified T : Any> bean(): T

The application's bean of T.

fun <T : Any> bean(type: Class<T>): T

The application's bean of type.

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun commands(caller: Caller, credential: UserCredential = UserCredential.DEVELOPMENT): CommandClient

The command client of the public port, sending as caller: the wow-client a peer calls with, in user mode. It sends the commands of the contexts the server serves as objects, system commands among them (a lifecycle command, a snapshot rebuild, a job's command), waits as their wait plans say, and throws a rejection as a CommandRejectedException, any other problem as a WowProblemException, each with its error code; a command of another context fails, as no endpoint is known for it.

Link copied to clipboard
fun queries(caller: Caller, credential: UserCredential = UserCredential.DEVELOPMENT): Queries

The queries of the public port as caller, sent as commands sends, with credential: the states, snapshots, events and datasets of the contexts the server serves, by their state classes, read as that caller may.