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 void
close()
<T> T
newActivityStub(java.lang.Class<T> activityInterface)
Creates client stub to activities that implement given interface.<T> T
newActivityStub(java.lang.Class<T> activityInterface, io.temporal.activity.ActivityOptions options)
Creates client stub to activities that implement given interface.<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.void
registerActivitiesImplementations(java.lang.Object... activityImplementations)
Register activity implementation objects with a worker.void
requestCancelActivity()
Requests activity cancellation.<T> void
setActivityHeartbeatListener(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> void
setActivityHeartbeatListener(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)
.
-
-
-
Constructor Detail
-
TestActivityEnvironmentInternal
public TestActivityEnvironmentInternal(TestEnvironmentOptions options)
-
-
Method Detail
-
registerActivitiesImplementations
public void registerActivitiesImplementations(java.lang.Object... activityImplementations)
Register activity implementation objects with a worker. Overwrites previously registered objects. As activities are reentrant and stateless only one instance per activity type is registered.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:
registerActivitiesImplementations
in interfaceTestActivityEnvironment
-
newActivityStub
public <T> T newActivityStub(java.lang.Class<T> activityInterface)
Creates client stub to activities that implement given interface.- Specified by:
newActivityStub
in 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:
newActivityStub
in 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:
newLocalActivityStub
in 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:TestActivityEnvironment
Requests activity cancellation. The cancellation is going to be delivered to the activity on the next heartbeat.- Specified by:
requestCancelActivity
in interfaceTestActivityEnvironment
-
setActivityHeartbeatListener
public <T> void setActivityHeartbeatListener(java.lang.Class<T> detailsClass, io.temporal.workflow.Functions.Proc1<T> listener)
Description copied from interface:TestActivityEnvironment
Sets a listener that is called every time an activity implementation heartbeats throughActivityExecutionContext.heartbeat(Object)
.- Specified by:
setActivityHeartbeatListener
in 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:TestActivityEnvironment
Sets a listener that is called every time an activity implementation heartbeats throughActivityExecutionContext.heartbeat(Object)
.- Specified by:
setActivityHeartbeatListener
in 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.
-
close
public void close()
- Specified by:
close
in interfaceTestActivityEnvironment
-
-