Interface BehaviorTestKit<T>
-
public interface BehaviorTestKit<T>Used for synchronous testingBehaviors. Stores all effects e.g. Spawning of children, watching and offers access to what effects have taken place.For asynchronous testing of
Behaviors running seeActorTestKitNot for user extension. See
BehaviorTestKit.applyfactory methods
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <U> TestInbox<U>childInbox(ActorRef<U> child)Get the child inbox for the child ActorRef, or fail if there is no such child.<U> TestInbox<U>childInbox(java.lang.String name)Get the child inbox for the child with the given name, or fail if there is no child with the given name spawned<U> BehaviorTestKit<U>childTestKit(ActorRef<U> child)voidclearLog()Clear the log entriesTypedActorContext<T>context()Behavior<T>currentBehavior()The current behavior, can change any timerunis calledvoidexpectEffect(Effect expectedEffect)Asserts that the oldest effect is the expectedEffect.<R> RexpectEffectPF(scala.PartialFunction<Effect,R> f)Asserts that the oldest effect matches the given partial function.<E extends Effect>
EexpectEffectType(scala.reflect.ClassTag<E> classTag)Asserts that the oldest effect is of type T.booleanhasEffects()Returns if there have been any effects.booleanisAlive()Is the current behavior alive or stoppedscala.collection.immutable.Seq<CapturedLogEvent>logEntries()Returns all theCapturedLogEventissued by this behavior(s)TestInbox<Receptionist.Command>receptionistInbox()The receptionist inbox contains messages sent tosystem.receptionistActorRef<T>ref()The self reference of the actor living inside this testkit.scala.collection.immutable.Seq<Effect>retrieveAllEffects()Requests all the effects.EffectretrieveEffect()Requests the oldestEffectorEffect.NoEffectsif no effects have taken place.Behavior<T>returnedBehavior()Returns the current behavior as it was returned from processing the previous message.voidrun(T message)Send the message to the behavior and record anyEffects<Res> ReplyInbox<Res>runAsk(scala.Function1<ActorRef<Res>,T> f)Constructs a message using the provided function to inject a single-use "reply to"ActorRef, and sends the constructed message to the behavior, recording anyEffects.<Res> StatusReplyInbox<Res>runAskWithStatus(scala.Function1<ActorRef<StatusReply<Res>>,T> f)The same as<Res>runAsk(scala.Function1<akka.actor.typed.ActorRef<Res>,T>)but only for requests that result in a response of typeStatusReply.voidrunOne()Send the first message in the selfInbox to the behavior and run it, recordingEffects.TestInbox<T>selfInbox()The self inbox contains messages the behavior sent tocontext.selfvoidsignal(Signal signal)Send the signal to the behavior and record anyEffects
-
-
-
Method Detail
-
runAsk
<Res> ReplyInbox<Res> runAsk(scala.Function1<ActorRef<Res>,T> f)
Constructs a message using the provided function to inject a single-use "reply to"ActorRef, and sends the constructed message to the behavior, recording anyEffects.The returned
ReplyInboxallows the message sent to the "reply to"ActorRefto be asserted on.
-
runAskWithStatus
<Res> StatusReplyInbox<Res> runAskWithStatus(scala.Function1<ActorRef<StatusReply<Res>>,T> f)
The same as<Res>runAsk(scala.Function1<akka.actor.typed.ActorRef<Res>,T>)but only for requests that result in a response of typeStatusReply.
-
context
TypedActorContext<T> context()
-
retrieveEffect
Effect retrieveEffect()
Requests the oldestEffectorEffect.NoEffectsif no effects have taken place. The effect is consumed, subsequent calls won't will not include this effect.
-
childInbox
<U> TestInbox<U> childInbox(java.lang.String name)
Get the child inbox for the child with the given name, or fail if there is no child with the given name spawned
-
childInbox
<U> TestInbox<U> childInbox(ActorRef<U> child)
Get the child inbox for the child ActorRef, or fail if there is no such child.
-
childTestKit
<U> BehaviorTestKit<U> childTestKit(ActorRef<U> child)
-
selfInbox
TestInbox<T> selfInbox()
The self inbox contains messages the behavior sent tocontext.self
-
retrieveAllEffects
scala.collection.immutable.Seq<Effect> retrieveAllEffects()
Requests all the effects. The effects are consumed, subsequent calls will only see new effects.
-
hasEffects
boolean hasEffects()
Returns if there have been any effects.
-
expectEffect
void expectEffect(Effect expectedEffect)
Asserts that the oldest effect is the expectedEffect. Removing it from further assertions.
-
expectEffectType
<E extends Effect> E expectEffectType(scala.reflect.ClassTag<E> classTag)
Asserts that the oldest effect is of type T. Consumes and returns the concrete effect for further direct assertions.
-
expectEffectPF
<R> R expectEffectPF(scala.PartialFunction<Effect,R> f)
Asserts that the oldest effect matches the given partial function.
-
currentBehavior
Behavior<T> currentBehavior()
The current behavior, can change any timerunis called
-
returnedBehavior
Behavior<T> returnedBehavior()
Returns the current behavior as it was returned from processing the previous message. For example ifBehaviors.unhandledis returned it will be kept here, but not incurrentBehavior().
-
isAlive
boolean isAlive()
Is the current behavior alive or stopped
-
run
void run(T message)
Send the message to the behavior and record anyEffects
-
runOne
void runOne()
Send the first message in the selfInbox to the behavior and run it, recordingEffects.
-
signal
void signal(Signal signal)
Send the signal to the behavior and record anyEffects
-
logEntries
scala.collection.immutable.Seq<CapturedLogEvent> logEntries()
Returns all theCapturedLogEventissued by this behavior(s)
-
clearLog
void clearLog()
Clear the log entries
-
receptionistInbox
TestInbox<Receptionist.Command> receptionistInbox()
The receptionist inbox contains messages sent tosystem.receptionist
-
-