Class BehaviorTestKit<T>
java.lang.Object
org.apache.pekko.actor.testkit.typed.javadsl.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.
Not for user extension or instantiation. See BehaviorTestKit.create factory methods
For asynchronous testing of Behaviors running see ActorTestKit
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.typesafe.config.ConfigJAVA APIabstract <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 spawnedabstract <U> TestInbox<U>childInbox(ActorRef<U> child) Get the child inbox for the child with the given name, or fail if there is no child with the given name spawnedabstract <U> BehaviorTestKit<U>childTestKit(ActorRef<U> child) Get thepekko.actor.typed.Behaviortestkit for the given childpekko.actor.typed.ActorRef.abstract voidclearLog()Clear the log entriesstatic <T> BehaviorTestKit<T>JAVA APIstatic <T> BehaviorTestKit<T>JAVA APIstatic <T> BehaviorTestKit<T>JAVA APIThe current behavior, can change any timerunis calledabstract voidexpectEffect(Effect expectedEffect) Asserts that the oldest effect is the expectedEffect.abstract <U extends Effect>
UexpectEffectClass(Class<U> effectClass) Asserts that the oldest effect is an instance of of class T.Requests all the effects.abstract List<CapturedLogEvent>Returns all theCapturedLogEventissued by this behavior(s)abstract EffectRequests the oldestEffectorpekko.actor.testkit.typed.javadsl.Effects.noEffectsif no effects have taken place.getRef()The self reference of the actor living inside this testkit.abstract booleanReturns if there have been any effects.abstract booleanisAlive()Is the current behavior alive or stoppedabstract TestInbox<Receptionist.Command>The receptionist inbox contains messages sent tosystem.receptionistReturns the current behavior as it was returned from processing the previous message.abstract voidSend the message to the behavior and record anyEffectsabstract voidrunOne()Send the first message in the selfInbox to the behavior and run it, recordingEffects.The self inbox contains messages the behavior sent tocontext.selfabstract voidSend the signal to the beheavior and record anyEffects
-
Constructor Details
-
BehaviorTestKit
public BehaviorTestKit()
-
-
Method Details
-
applicationTestConfig
public static com.typesafe.config.Config applicationTestConfig()JAVA API -
create
public static <T> BehaviorTestKit<T> create(Behavior<T> initialBehavior, String name, com.typesafe.config.Config config) JAVA API -
create
JAVA API -
create
JAVA API -
getEffect
Requests the oldestEffectorpekko.actor.testkit.typed.javadsl.Effects.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 with the given name, or fail if there is no child with the given name spawned -
childTestKit
Get thepekko.actor.typed.Behaviortestkit for the given childpekko.actor.typed.ActorRef. -
selfInbox
The self inbox contains messages the behavior sent tocontext.self -
getRef
The self reference of the actor living inside this testkit. -
getAllEffects
Requests all the effects. The effects are consumed, subsequent calls will only see new effects. -
hasEffects
public abstract boolean hasEffects()Returns if there have been any effects. -
expectEffect
Asserts that the oldest effect is the expectedEffect. Removing it from further assertions. -
expectEffectClass
Asserts that the oldest effect is an instance of of class T. Consumes and returns the concrete effect for further direct assertions. -
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.javadsl.Behaviors.unhandledis returned it will be kept here, but not incurrentBehavior(). -
isAlive
public abstract boolean isAlive()Is the current behavior alive or stopped -
run
Send the message to the behavior and record anyEffects -
runOne
public abstract void runOne()Send the first message in the selfInbox to the behavior and run it, recordingEffects. -
signal
Send the signal to the beheavior and record anyEffects -
getAllLogEntries
Returns all theCapturedLogEventissued by this behavior(s) -
clearLog
public abstract void clearLog()Clear the log entries -
receptionistInbox
The receptionist inbox contains messages sent tosystem.receptionist
-