Package io.temporal.testing
Class TestActivityEnvironmentInternal
- java.lang.Object
-
- io.temporal.testing.TestActivityEnvironmentInternal
-
- All Implemented Interfaces:
TestActivityEnvironment
public final class TestActivityEnvironmentInternal extends java.lang.Object implements TestActivityEnvironment
-
-
Constructor Summary
Constructors Constructor Description TestActivityEnvironmentInternal(TestEnvironmentOptions options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()<T> TnewActivityStub(java.lang.Class<T> activityInterface)Creates client stub to activities that implement given interface.<T> TnewActivityStub(java.lang.Class<T> activityInterface, io.temporal.activity.ActivityOptions options)Creates client stub to activities that implement given interface.<T> TnewLocalActivityStub(java.lang.Class<T> activityInterface, io.temporal.activity.LocalActivityOptions options, java.util.Map<java.lang.String,io.temporal.activity.LocalActivityOptions> activityMethodOptions)Creates client stub to activities that implement given interface.voidregisterActivitiesImplementations(java.lang.Object... activityImplementations)Registers activity implementations to test.voidrequestCancelActivity()Requests activity cancellation.<T> voidsetActivityHeartbeatListener(java.lang.Class<T> detailsClass, io.temporal.workflow.Functions.Proc1<T> listener)Sets a listener that is called every time an activity implementation heartbeats throughActivityExecutionContext.heartbeat(Object).<T> voidsetActivityHeartbeatListener(java.lang.Class<T> detailsClass, java.lang.reflect.Type detailsType, io.temporal.workflow.Functions.Proc1<T> listener)Sets a listener that is called every time an activity implementation heartbeats throughActivityExecutionContext.heartbeat(Object).<T> voidsetHeartbeatDetails(T details)Sets heartbeat details for the next activity execution.
-
-
-
Constructor Detail
-
TestActivityEnvironmentInternal
public TestActivityEnvironmentInternal(@Nullable TestEnvironmentOptions options)
-
-
Method Detail
-
registerActivitiesImplementations
public void registerActivitiesImplementations(java.lang.Object... activityImplementations)
Description copied from interface:TestActivityEnvironmentRegisters activity implementations to test. UseTestActivityEnvironment.newActivityStub(Class)to create stubs that can be used to invoke them.Implementations that share a worker must implement different interfaces as an activity type is identified by the activity interface, not by the implementation.
- Specified by:
registerActivitiesImplementationsin interfaceTestActivityEnvironment
-
newActivityStub
public <T> T newActivityStub(java.lang.Class<T> activityInterface)
Creates client stub to activities that implement given interface.- Specified by:
newActivityStubin interfaceTestActivityEnvironment- Type Parameters:
T- Type of the activity interface.- Parameters:
activityInterface- interface type implemented by activities- Returns:
- The stub that implements the activity interface.
-
newActivityStub
public <T> T newActivityStub(java.lang.Class<T> activityInterface, io.temporal.activity.ActivityOptions options)Creates client stub to activities that implement given interface.- Specified by:
newActivityStubin interfaceTestActivityEnvironment- Type Parameters:
T- Type of the activity interface.- Parameters:
activityInterface- interface type implemented by activitiesoptions- options that specify the activity invocation parameters- Returns:
- The stub that implements the activity interface.
-
newLocalActivityStub
public <T> T newLocalActivityStub(java.lang.Class<T> activityInterface, io.temporal.activity.LocalActivityOptions options, java.util.Map<java.lang.String,io.temporal.activity.LocalActivityOptions> activityMethodOptions)Creates client stub to activities that implement given interface.- Specified by:
newLocalActivityStubin interfaceTestActivityEnvironment- Type Parameters:
T- Type of the activity interface.- Parameters:
activityInterface- interface type implemented by activitiesoptions- options that specify the activity invocation parametersactivityMethodOptions- activity method-specific invocation parameters- Returns:
- The stub that implements the activity interface.
-
requestCancelActivity
public void requestCancelActivity()
Description copied from interface:TestActivityEnvironmentRequests activity cancellation. The cancellation is going to be delivered to the activity on the next heartbeat.- Specified by:
requestCancelActivityin interfaceTestActivityEnvironment
-
setActivityHeartbeatListener
public <T> void setActivityHeartbeatListener(java.lang.Class<T> detailsClass, io.temporal.workflow.Functions.Proc1<T> listener)Description copied from interface:TestActivityEnvironmentSets a listener that is called every time an activity implementation heartbeats throughActivityExecutionContext.heartbeat(Object).- Specified by:
setActivityHeartbeatListenerin interfaceTestActivityEnvironment- Type Parameters:
T- Type of the heartbeat details.- Parameters:
detailsClass- class of the details passed to theActivityExecutionContext.heartbeat(Object).listener- listener to register.
-
setActivityHeartbeatListener
public <T> void setActivityHeartbeatListener(java.lang.Class<T> detailsClass, java.lang.reflect.Type detailsType, io.temporal.workflow.Functions.Proc1<T> listener)Description copied from interface:TestActivityEnvironmentSets a listener that is called every time an activity implementation heartbeats throughActivityExecutionContext.heartbeat(Object).- Specified by:
setActivityHeartbeatListenerin interfaceTestActivityEnvironment- Type Parameters:
T- Type of the heartbeat details.- Parameters:
detailsClass- class of the details passed to theActivityExecutionContext.heartbeat(Object).detailsType- type of the details. Differs for detailsClass for generic types.listener- listener to register.
-
setHeartbeatDetails
public <T> void setHeartbeatDetails(T details)
Description copied from interface:TestActivityEnvironmentSets heartbeat details for the next activity execution. The next activity called from this TestActivityEnvironment will be able to access this value usingActivityExecutionContext.getHeartbeatDetails(Class). This value is cleared upon execution.- Specified by:
setHeartbeatDetailsin interfaceTestActivityEnvironment- Type Parameters:
T- Type of the heartbeat details.- Parameters:
details- The details object to make available to the next activity call.
-
close
public void close()
- Specified by:
closein interfaceTestActivityEnvironment
-
-