Class TestWorkflowExtension.Builder

  • Enclosing class:
    TestWorkflowExtension

    public static class TestWorkflowExtension.Builder
    extends java.lang.Object
    • Method Detail

      • setWorkflowClientOptions

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

        public TestWorkflowExtension.Builder setNamespace​(java.lang.String namespace)
        Set Temporal namespace to use for tests, by default, UnitTest is used.
        See Also:
        WorkflowClientOptions.getNamespace()
      • registerWorkflowImplementationTypes

        public TestWorkflowExtension.Builder registerWorkflowImplementationTypes​(java.lang.Class<?>... workflowTypes)
        Specify workflow implementation types to register with the Temporal worker.
        See Also:
        Worker.registerWorkflowImplementationTypes(Class[])
      • registerWorkflowImplementationTypes

        public TestWorkflowExtension.Builder registerWorkflowImplementationTypes​(io.temporal.worker.WorkflowImplementationOptions options,
                                                                                 java.lang.Class<?>... workflowTypes)
        Specify workflow implementation types to register with the Temporal worker.
        See Also:
        Worker.registerWorkflowImplementationTypes(Class[])
      • setNexusServiceImplementation

        public TestWorkflowExtension.Builder setNexusServiceImplementation​(java.lang.Object... nexusServiceImplementations)
        Specify Nexus service implementations to register with the Temporal workerIf any Nexus services are registered with the worker, the extension will automatically create a Nexus Endpoint for the test and the endpoint will be set on the per-service options and default options in WorkflowImplementationOptions if none are provided.

        This can be disabled by setting setDoNotSetupNexusEndpoint(boolean) to true.

        See Also:
        Worker.registerNexusServiceImplementation(Object...)
      • setWorkflowTypes

        @Deprecated
        public TestWorkflowExtension.Builder setWorkflowTypes​(java.lang.Class<?>... workflowTypes)
        Deprecated.
        use registerWorkflowImplementationTypes instead
        Specify workflow implementation types to register with the Temporal worker.
        See Also:
        Worker.registerWorkflowImplementationTypes(Class[])
      • setActivityImplementations

        public TestWorkflowExtension.Builder setActivityImplementations​(java.lang.Object... activityImplementations)
        Specify activity implementations to register with the Temporal worker
        See Also:
        Worker.registerActivitiesImplementations(Object...)
      • useInternalService

        public TestWorkflowExtension.Builder useInternalService()
        Switches to internal in-memory Temporal service implementation (default).
      • setDoNotSetupNexusEndpoint

        public TestWorkflowExtension.Builder setDoNotSetupNexusEndpoint​(boolean doNotSetupNexusEndpoint)
        When set to true the TestWorkflowEnvironment will not automatically create a Nexus Endpoint. This is useful when you want to manually create a Nexus Endpoint for your test.
      • setInitialTimeMillis

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

        Default is current time

      • setInitialTime

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

        Default is current time

      • setUseTimeskipping

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

      • registerSearchAttribute

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