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 protectedBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TestWorkflowRulebuild()TestWorkflowRule.BuilderregisterSearchAttribute(io.temporal.common.SearchAttributeKey<?> key)Add a search attribute to be registered on the Temporal Server.TestWorkflowRule.BuilderregisterSearchAttribute(java.lang.String name, io.temporal.api.enums.v1.IndexedValueType type)Add a search attribute to be registered on the Temporal Server.TestWorkflowRule.BuildersetActivityImplementations(java.lang.Object... activityImplementations)TestWorkflowRule.BuildersetDoNotStart(boolean doNotStart)When set to true theTestWorkflowEnvironment.start()is not called by the rule before executing the test.TestWorkflowRule.BuildersetInitialTime(java.time.Instant initialTime)Set the initial time for the workflow virtual clock.TestWorkflowRule.BuildersetInitialTimeMillis(long initialTimeMillis)Set the initial time for the workflow virtual clock, milliseconds since epoch.TestWorkflowRule.BuildersetMetricsScope(com.uber.m3.tally.Scope metricsScope)Sets the scope to be used for metrics reporting.TestWorkflowRule.BuildersetNamespace(java.lang.String namespace)TestWorkflowRule.BuildersetTarget(java.lang.String target)Optional parameter that defines an endpoint which will be used for the communication with standalone temporal service.TestWorkflowRule.BuildersetTestTimeoutSeconds(long testTimeoutSeconds)Deprecated.Temporal test rule shouldn't be responsible for enforcing test timeouts.TestWorkflowRule.BuildersetUseExternalService(boolean useExternalService)Switches between in-memory and external temporal service implementations.TestWorkflowRule.BuildersetUseTimeskipping(boolean useTimeskipping)Sets TestEnvironmentOptions.setUseTimeskippings.TestWorkflowRule.BuildersetWorkerFactoryOptions(io.temporal.worker.WorkerFactoryOptions options)TestWorkflowRule.BuildersetWorkerOptions(io.temporal.worker.WorkerOptions options)TestWorkflowRule.BuildersetWorkflowClientOptions(io.temporal.client.WorkflowClientOptions workflowClientOptions)OverrideWorkflowClientOptionsfor test environment.voidsetWorkflowServiceStubsOptions(io.temporal.serviceclient.WorkflowServiceStubsOptions workflowServiceStubsOptions)TestWorkflowRule.BuildersetWorkflowTypes(io.temporal.worker.WorkflowImplementationOptions implementationOptions, java.lang.Class<?>... workflowTypes)TestWorkflowRule.BuildersetWorkflowTypes(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)
OverrideWorkflowClientOptionsfor 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)
-
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.
-
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
Scopein 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()
-
-