Class TestActivityEnvironmentInternal

java.lang.Object
io.temporal.testing.TestActivityEnvironmentInternal
All Implemented Interfaces:
TestActivityEnvironment

public final class TestActivityEnvironmentInternal extends Object implements TestActivityEnvironment
  • Constructor Details

    • TestActivityEnvironmentInternal

      public TestActivityEnvironmentInternal(@Nullable TestEnvironmentOptions options)
  • Method Details

    • registerActivitiesImplementations

      public void registerActivitiesImplementations(Object... activityImplementations)
      Description copied from interface: TestActivityEnvironment
      Registers activity implementations to test. Use TestActivityEnvironment.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:
      registerActivitiesImplementations in interface TestActivityEnvironment
    • newActivityStub

      public <T> T newActivityStub(Class<T> activityInterface)
      Creates client stub to activities that implement given interface.
      Specified by:
      newActivityStub in interface TestActivityEnvironment
      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(Class<T> activityInterface, io.temporal.activity.ActivityOptions options)
      Creates client stub to activities that implement given interface.
      Specified by:
      newActivityStub in interface TestActivityEnvironment
      Type Parameters:
      T - Type of the activity interface.
      Parameters:
      activityInterface - interface type implemented by activities
      options - options that specify the activity invocation parameters
      Returns:
      The stub that implements the activity interface.
    • newLocalActivityStub

      public <T> T newLocalActivityStub(Class<T> activityInterface, io.temporal.activity.LocalActivityOptions options, Map<String,io.temporal.activity.LocalActivityOptions> activityMethodOptions)
      Creates client stub to activities that implement given interface.
      Specified by:
      newLocalActivityStub in interface TestActivityEnvironment
      Type Parameters:
      T - Type of the activity interface.
      Parameters:
      activityInterface - interface type implemented by activities
      options - options that specify the activity invocation parameters
      activityMethodOptions - 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 interface TestActivityEnvironment
    • setActivityHeartbeatListener

      public <T> void setActivityHeartbeatListener(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 through ActivityExecutionContext.heartbeat(Object).
      Specified by:
      setActivityHeartbeatListener in interface TestActivityEnvironment
      Type Parameters:
      T - Type of the heartbeat details.
      Parameters:
      detailsClass - class of the details passed to the ActivityExecutionContext.heartbeat(Object).
      listener - listener to register.
    • setActivityHeartbeatListener

      public <T> void setActivityHeartbeatListener(Class<T> detailsClass, 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 through ActivityExecutionContext.heartbeat(Object).
      Specified by:
      setActivityHeartbeatListener in interface TestActivityEnvironment
      Type Parameters:
      T - Type of the heartbeat details.
      Parameters:
      detailsClass - class of the details passed to the ActivityExecutionContext.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: TestActivityEnvironment
      Sets heartbeat details for the next activity execution. The next activity called from this TestActivityEnvironment will be able to access this value using ActivityExecutionContext.getHeartbeatDetails(Class). This value is cleared upon execution.
      Specified by:
      setHeartbeatDetails in interface TestActivityEnvironment
      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:
      close in interface TestActivityEnvironment