Class TestEnvironmentOptions.Builder

java.lang.Object
io.temporal.testing.TestEnvironmentOptions.Builder
Enclosing class:
TestEnvironmentOptions

public static final class TestEnvironmentOptions.Builder extends Object
  • Method Details

    • setWorkflowClientOptions

      public TestEnvironmentOptions.Builder setWorkflowClientOptions(io.temporal.client.WorkflowClientOptions workflowClientOptions)
    • setActivityClientOptions

      public TestEnvironmentOptions.Builder setActivityClientOptions(io.temporal.client.ActivityClientOptions activityClientOptions)
    • setWorkerFactoryOptions

      public TestEnvironmentOptions.Builder setWorkerFactoryOptions(io.temporal.worker.WorkerFactoryOptions options)
      Set factoryOptions for worker factory used to create workers.
    • setWorkflowServiceStubsOptions

      public TestEnvironmentOptions.Builder setWorkflowServiceStubsOptions(io.temporal.serviceclient.WorkflowServiceStubsOptions options)
    • setMetricsScope

      public TestEnvironmentOptions.Builder setMetricsScope(com.uber.m3.tally.Scope metricsScope)
      Sets the scope to be used for metrics reporting. Optional. Default is to not report metrics.

      Note: Don't mock Scope in tests! If you need to verify the metrics behavior, create a real Scope and mock, stub or spy a reporter instance:

      
       StatsReporter reporter = mock(StatsReporter.class);
       Scope metricsScope =
           new RootScopeBuilder()
               .reporter(reporter)
               .reportEvery(com.uber.m3.util.Duration.ofMillis(10));
       
      Parameters:
      metricsScope - the scope to be used for metrics reporting.
      Returns:
      this
    • setUseExternalService

      public TestEnvironmentOptions.Builder setUseExternalService(boolean useExternalService)
      Set to true in order to make test environment use external temporal service or false for in-memory test implementation.
    • setTarget

      public TestEnvironmentOptions.Builder setTarget(String target)
      Optional parameter that defines an endpoint which will be used for the communication with standalone temporal service. Has no effect if useExternalService is set to false.

      Defaults to 127.0.0.1:7233

    • setInitialTimeMillis

      public TestEnvironmentOptions.Builder setInitialTimeMillis(long initialTimeMillis)
      Set the initial time for the workflow virtual clock, milliseconds since epoch.

      Default is current time

    • setInitialTime

      public TestEnvironmentOptions.Builder setInitialTime(Instant initialTime)
      Set the initial time for the workflow virtual clock.

      Default is current time

    • setUseTimeskipping

      public TestEnvironmentOptions.Builder setUseTimeskipping(boolean useTimeskipping)
      Sets whether the TestWorkflowEnvironment will timeskip. If true, no actual wall-clock time will pass when a workflow sleeps or sets a timer.

      Default is true

    • registerSearchAttribute

      public TestEnvironmentOptions.Builder registerSearchAttribute(String name, io.temporal.api.enums.v1.IndexedValueType type)
      Add a search attribute to be registered on the Temporal Server.
      Parameters:
      name - name of the search attribute
      type - search attribute type
      Returns:
      this
      See Also:
    • build

      public TestEnvironmentOptions build()
    • validateAndBuildWithDefaults

      public TestEnvironmentOptions validateAndBuildWithDefaults()