Package io.temporal.testing
Class TestWorkflowRule.Builder
- java.lang.Object
-
- io.temporal.testing.TestWorkflowRule.Builder
-
- Enclosing class:
- TestWorkflowRule
public static class TestWorkflowRule.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TestWorkflowRule
build()
TestWorkflowRule.Builder
registerSearchAttribute(io.temporal.common.SearchAttributeKey<?> key)
Add a search attribute to be registered on the Temporal Server.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.TestWorkflowRule.Builder
setActivityImplementations(java.lang.Object... activityImplementations)
TestWorkflowRule.Builder
setDoNotSetupNexusEndpoint(boolean doNotSetupNexusEndpoint)
When set to true theTestWorkflowEnvironment
will not automatically create a Nexus Endpoint.TestWorkflowRule.Builder
setDoNotStart(boolean doNotStart)
When set to true theTestWorkflowEnvironment.start()
is not called by the rule before executing the test.TestWorkflowRule.Builder
setInitialTime(java.time.Instant initialTime)
Set the initial time for the workflow virtual clock.TestWorkflowRule.Builder
setInitialTimeMillis(long initialTimeMillis)
Set the initial time for the workflow virtual clock, milliseconds since epoch.TestWorkflowRule.Builder
setMetricsScope(com.uber.m3.tally.Scope metricsScope)
Sets the scope to be used for metrics reporting.TestWorkflowRule.Builder
setNamespace(java.lang.String namespace)
TestWorkflowRule.Builder
setNexusServiceImplementation(java.lang.Object... nexusServiceImplementations)
Specify Nexus service implementations to register with the Temporal worker.TestWorkflowRule.Builder
setTarget(java.lang.String target)
Optional parameter that defines an endpoint which will be used for the communication with standalone temporal service.TestWorkflowRule.Builder
setTestTimeoutSeconds(long testTimeoutSeconds)
Deprecated.Temporal test rule shouldn't be responsible for enforcing test timeouts.TestWorkflowRule.Builder
setUseExternalService(boolean useExternalService)
Switches between in-memory and external temporal service implementations.TestWorkflowRule.Builder
setUseTimeskipping(boolean useTimeskipping)
Sets TestEnvironmentOptions.setUseTimeskippings.TestWorkflowRule.Builder
setWorkerFactoryOptions(io.temporal.worker.WorkerFactoryOptions options)
TestWorkflowRule.Builder
setWorkerOptions(io.temporal.worker.WorkerOptions options)
TestWorkflowRule.Builder
setWorkflowClientOptions(io.temporal.client.WorkflowClientOptions workflowClientOptions)
OverrideWorkflowClientOptions
for test environment.void
setWorkflowServiceStubsOptions(io.temporal.serviceclient.WorkflowServiceStubsOptions workflowServiceStubsOptions)
TestWorkflowRule.Builder
setWorkflowTypes(io.temporal.worker.WorkflowImplementationOptions implementationOptions, java.lang.Class<?>... workflowTypes)
TestWorkflowRule.Builder
setWorkflowTypes(java.lang.Class<?>... workflowTypes)
-
-
-
Method Detail
-
setWorkerOptions
public TestWorkflowRule.Builder setWorkerOptions(io.temporal.worker.WorkerOptions options)
-
setWorkflowServiceStubsOptions
public void setWorkflowServiceStubsOptions(io.temporal.serviceclient.WorkflowServiceStubsOptions workflowServiceStubsOptions)
-
setWorkflowClientOptions
public TestWorkflowRule.Builder setWorkflowClientOptions(io.temporal.client.WorkflowClientOptions workflowClientOptions)
OverrideWorkflowClientOptions
for test environment. If set, takes precedence overnamespace
.
-
setWorkerFactoryOptions
public TestWorkflowRule.Builder setWorkerFactoryOptions(io.temporal.worker.WorkerFactoryOptions options)
-
setNamespace
public TestWorkflowRule.Builder setNamespace(java.lang.String namespace)
-
setWorkflowTypes
public TestWorkflowRule.Builder setWorkflowTypes(java.lang.Class<?>... workflowTypes)
-
setWorkflowTypes
public TestWorkflowRule.Builder setWorkflowTypes(io.temporal.worker.WorkflowImplementationOptions implementationOptions, java.lang.Class<?>... workflowTypes)
-
setNexusServiceImplementation
public TestWorkflowRule.Builder setNexusServiceImplementation(java.lang.Object... nexusServiceImplementations)
Specify Nexus service implementations to register with the Temporal worker. If any Nexus services are registered with the worker, the rule will automatically create a Nexus Endpoint for the test and the endpoint will be set on the per-service options and default options inWorkflowImplementationOptions
if none are provided.This can be disabled by setting
setDoNotSetupNexusEndpoint(boolean)
to true.- See Also:
Worker.registerNexusServiceImplementation(Object...)
-
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 ifsetUseExternalService(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
-
setDoNotStart
public TestWorkflowRule.Builder setDoNotStart(boolean doNotStart)
When set to true theTestWorkflowEnvironment.start()
is not called by the rule before executing the test. This to support tests that register activities and workflows with workers directly instead of using onlyTestWorkflowRule.Builder
.
-
setDoNotSetupNexusEndpoint
public TestWorkflowRule.Builder setDoNotSetupNexusEndpoint(boolean doNotSetupNexusEndpoint)
When set to true theTestWorkflowEnvironment
will not automatically create a Nexus Endpoint. This is useful when you want to manually create a Nexus Endpoint for your test.
-
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 attributetype
- search attribute type- Returns:
this
- See Also:
- Add a Custom Search Attribute Using tctl
-
registerSearchAttribute
public TestWorkflowRule.Builder registerSearchAttribute(io.temporal.common.SearchAttributeKey<?> key)
Add a search attribute to be registered on the Temporal Server.- Parameters:
key
- key to register- 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
-
build
public TestWorkflowRule build()
-
-