Class TestWorkflowRule.Builder

  • Enclosing class:
    TestWorkflowRule

    public static class TestWorkflowRule.Builder
    extends java.lang.Object
    • Constructor Detail

      • Builder

        protected Builder()
    • Method Detail

      • setWorkerFactoryOptions

        public TestWorkflowRule.Builder setWorkerFactoryOptions​(io.temporal.worker.WorkerFactoryOptions options)
      • setWorkflowClientOptions

        public TestWorkflowRule.Builder setWorkflowClientOptions​(io.temporal.client.WorkflowClientOptions workflowClientOptions)
        Override WorkflowClientOptions for test environment. If set, takes precedence over namespace.
      • setWorkflowTypes

        public TestWorkflowRule.Builder setWorkflowTypes​(io.temporal.worker.WorkflowImplementationOptions implementationOptions,
                                                         java.lang.Class<?>... workflowTypes)
      • setActivityImplementations

        public TestWorkflowRule.Builder setActivityImplementations​(java.lang.Object... activityImplementations)
      • setUseExternalService

        public TestWorkflowRule.Builder setUseExternalService​(boolean useExternalService)
        Switches between in-memory and external temporal service implementations.
        Parameters:
        useExternalService - use external service if true.

        Default is false.

      • setUseTimeskipping

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

        Default is true

      • setTarget

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

        Default is to use 127.0.0.1:7233

      • setTestTimeoutSeconds

        @Deprecated
        public TestWorkflowRule.Builder setTestTimeoutSeconds​(long testTimeoutSeconds)
        Deprecated.
        Temporal test rule shouldn't be responsible for enforcing test timeouts. Use toolchain of your test framework to enforce timeouts.
      • setInitialTimeMillis

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

        Default is current time

      • setInitialTime

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

        Default is current time

      • registerSearchAttribute

        public TestWorkflowRule.Builder registerSearchAttribute​(java.lang.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:
        Add a Custom Search Attribute Using tctl
      • setMetricsScope

        public TestWorkflowRule.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