assertRejected
The rejection the command send sends is answered with: it fails, saying so, unless send throws a CommandRejectedException, with the exception it threw instead as its cause.
assertRejected { server.commands(alice).wait(Withdraw(150), "alice") }
.code.assert().isEqualTo("bank.account.insufficient-balance")
val invalid = assertRejected { server.commands(bob).wait(Deposit(0), "bob") }
invalid.violations.single().path.assert().isEqualTo("amount")Content copied to clipboard
send may call the typed clients' suspend functions: it runs blocking the calling thread, as a test does, in a coroutine of its own, so an element of a caller's coroutine context (ForwardedHeaders) is given in send itself.