Interface BehaviorTestKit<T>
public interface BehaviorTestKit<T>
Used for synchronous testing
pekko.actor.typed.Behaviors. Stores all effects e.g. Spawning of children,
watching and offers access to what effects have taken place.
For asynchronous testing of Behaviors running see ActorTestKit
Not for user extension. See BehaviorTestKit.apply factory methods
-
Method Summary
Modifier and TypeMethodDescription<U> TestInbox<U>childInbox(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> TestInbox<U>childInbox(ActorRef<U> child) Get the child inbox for the child ActorRef, or fail if there is no such child.<U> BehaviorTestKit<U>childTestKit(ActorRef<U> child) Get thepekko.actor.typed.Behaviortestkit for the given childpekko.actor.typed.ActorRef.voidclearLog()Clear the log entriescontext()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.booleanReturns if there have been any effects.booleanisAlive()Is the current behavior alive or stoppedscala.collection.immutable.Seq<CapturedLogEvent>Returns all theCapturedLogEventissued by this behavior(s)The receptionist inbox contains messages sent tosystem.receptionistref()The self reference of the actor living inside this testkit.scala.collection.immutable.Seq<Effect>Requests all the effects.Requests the oldestEffectorpekko.actor.testkit.typed.Effect.NoEffectsif no effects have taken place.Returns the current behavior as it was returned from processing the previous message.voidSend the message to the behavior and record anyEffectsvoidrunOne()Send the first message in the selfInbox to the behavior and run it, recordingEffects.The self inbox contains messages the behavior sent tocontext.selfvoidSend the signal to the behavior and record anyEffects
-
Method Details
-
context
TypedActorContext<T> context() -
retrieveEffect
Effect retrieveEffect()Requests the oldestEffectorpekko.actor.testkit.typed.Effect.NoEffectsif no effects have taken place. The effect is consumed, subsequent calls won't will not include this effect. -
childInbox
Get the child inbox for the child with the given name, or fail if there is no child with the given name spawned -
childInbox
Get the child inbox for the child ActorRef, or fail if there is no such child. -
childTestKit
Get thepekko.actor.typed.Behaviortestkit for the given childpekko.actor.typed.ActorRef. -
selfInbox
The self inbox contains messages the behavior sent tocontext.self -
ref
The self reference of the actor living inside this testkit. -
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
Asserts that the oldest effect is the expectedEffect. Removing it from further assertions. -
expectEffectType
Asserts that the oldest effect is of type T. Consumes and returns the concrete effect for further direct assertions. -
expectEffectPF
Asserts that the oldest effect matches the given partial function. -
currentBehavior
The current behavior, can change any timerunis called -
returnedBehavior
Returns the current behavior as it was returned from processing the previous message. For example ifpekko.actor.typed.scaladsl.Behaviors.unhandledis returned it will be kept here, but not incurrentBehavior(). -
isAlive
boolean isAlive()Is the current behavior alive or stopped -
run
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
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
-