Class SDKTestWorkflowRule
java.lang.Object
io.temporal.testing.internal.SDKTestWorkflowRule
- All Implemented Interfaces:
org.junit.rules.TestRule
Intended to be used only in the Java SDK test code. This Rule duplicates
TestWorkflowRule
and provides additional convenience methods for SDK development-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<R> voidaddWorkflowImplementationFactory(Class<R> factoryImpl, io.temporal.workflow.Functions.Func<R> factoryFunc) org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) voidassertHistoryEvent(String workflowId, io.temporal.api.enums.v1.EventType eventType) Asserts that an event of the given EventType is found in the history.voidassertHistoryEvent(String workflowId, String runId, io.temporal.api.enums.v1.EventType eventType) static voidassertNoHistoryEvent(io.temporal.api.history.v1.History history, io.temporal.api.enums.v1.EventType eventType) Asserts that an event of the given EventType is not found in the history.voidassertNoHistoryEvent(String workflowId, io.temporal.api.enums.v1.EventType eventType) Asserts that an event of the given EventType is not found in the history.voidassertNoHistoryEvent(String workflowId, String runId, io.temporal.api.enums.v1.EventType eventType) Asserts that an event of the given EventType is not found in the history.io.temporal.client.ActivityClientio.temporal.common.WorkflowExecutionHistorygetExecutionHistory(String workflowId) io.temporal.common.WorkflowExecutionHistorygetExecutionHistory(String workflowId, String runId) io.temporal.api.history.v1.HistoryEventgetHistoryEvent(String workflowId, io.temporal.api.enums.v1.EventType eventType) Returns the first event of the given EventType found in the history.List<io.temporal.api.history.v1.HistoryEvent> getHistoryEvents(String workflowId, io.temporal.api.enums.v1.EventType eventType) Returns list of all events of the given EventType found in the history.<T extends io.temporal.common.interceptors.WorkerInterceptor>
TgetInterceptor(Class<T> type) io.temporal.client.NexusClientReturns aNexusClientbound to this rule's namespace and service stubs.io.temporal.api.nexus.v1.Endpointio.temporal.worker.Workerio.temporal.worker.WorkerFactoryOptionsio.temporal.client.WorkflowClientio.temporal.serviceclient.WorkflowServiceStubsvoidCauses eviction of all workflows in the worker cachebooleanstatic SDKTestWorkflowRule.Builderio.temporal.client.WorkflowStubnewUntypedWorkflowStub(String workflow) io.temporal.client.WorkflowStubnewUntypedWorkflowStubTimeoutOptions(String workflow) io.temporal.worker.WorkernewWorker(io.temporal.workflow.Functions.Proc1<io.temporal.worker.WorkerOptions.Builder> optionsModifier) Start a new worker, re-using existing options and modifying them with the provided modifierio.temporal.worker.WorkernewWorkerWithBuildID(String buildId) Start a new worker, changing only the build ID<T> TnewWorkflowStub(Class<T> workflow) <T> TnewWorkflowStub200sTimeoutOptions(Class<T> workflow) <T> TnewWorkflowStubTimeoutOptions(Class<T> workflow) <T> TnewWorkflowStubTimeoutOptions(Class<T> workflow, String workflowIdPrefix) voidregenerateHistoryForReplay(String workflowId, String fileName) voidregisterDelayedCallback(Duration delay, Runnable r) protected voidshutdown()voidstatic voidwaitForOKQuery(Object anyStub) Used to ensure that workflow first workflow task is executed.voidwaitForTheEndOfWFT(String workflowId) Waits till the end of the workflow task if there is a workflow task in progress
-
Field Details
-
NAMESPACE
- See Also:
-
UUID_REGEXP
- See Also:
-
REGENERATE_JSON_FILES
public static final boolean REGENERATE_JSON_FILES- See Also:
-
useExternalService
public static final boolean useExternalService -
USE_VIRTUAL_THREADS
public static final boolean USE_VIRTUAL_THREADS
-
-
Method Details
-
newBuilder
-
apply
public org.junit.runners.model.Statement apply(@Nonnull org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
applyin interfaceorg.junit.rules.TestRule
-
getInterceptor
public <T extends io.temporal.common.interceptors.WorkerInterceptor> T getInterceptor(Class<T> type) -
getTaskQueue
-
getDeploymentName
-
getNexusEndpoint
public io.temporal.api.nexus.v1.Endpoint getNexusEndpoint() -
getNexusClient
public io.temporal.client.NexusClient getNexusClient()Returns aNexusClientbound to this rule's namespace and service stubs. Use for tests that exercise the standalone Nexus client surface. -
getWorker
public io.temporal.worker.Worker getWorker() -
newWorker
public io.temporal.worker.Worker newWorker(io.temporal.workflow.Functions.Proc1<io.temporal.worker.WorkerOptions.Builder> optionsModifier) Start a new worker, re-using existing options and modifying them with the provided modifier -
newWorkerWithBuildID
Start a new worker, changing only the build ID -
getWorkerFactoryOptions
public io.temporal.worker.WorkerFactoryOptions getWorkerFactoryOptions() -
getExecutionHistory
-
getExecutionHistory
-
getHistoryEvents
-
getHistoryEvent
public io.temporal.api.history.v1.HistoryEvent getHistoryEvent(String workflowId, io.temporal.api.enums.v1.EventType eventType) Returns the first event of the given EventType found in the history. -
assertHistoryEvent
Asserts that an event of the given EventType is found in the history. -
assertHistoryEvent
-
assertNoHistoryEvent
Asserts that an event of the given EventType is not found in the history. -
assertNoHistoryEvent
-
assertNoHistoryEvent
public static void assertNoHistoryEvent(io.temporal.api.history.v1.History history, io.temporal.api.enums.v1.EventType eventType) Asserts that an event of the given EventType is not found in the history. -
waitForTheEndOfWFT
Waits till the end of the workflow task if there is a workflow task in progress -
getWorkflowClient
public io.temporal.client.WorkflowClient getWorkflowClient() -
getActivityClient
public io.temporal.client.ActivityClient getActivityClient() -
getWorkflowServiceStubs
public io.temporal.serviceclient.WorkflowServiceStubs getWorkflowServiceStubs() -
isUseExternalService
public boolean isUseExternalService() -
getTestEnvironment
-
newWorkflowStub
-
newWorkflowStubTimeoutOptions
-
newWorkflowStubTimeoutOptions
-
newWorkflowStub200sTimeoutOptions
-
newUntypedWorkflowStub
-
newUntypedWorkflowStubTimeoutOptions
-
waitForOKQuery
Used to ensure that workflow first workflow task is executed. -
addWorkflowImplementationFactory
public <R> void addWorkflowImplementationFactory(Class<R> factoryImpl, io.temporal.workflow.Functions.Func<R> factoryFunc) -
regenerateHistoryForReplay
-
registerDelayedCallback
-
shutdown
-
sleep
-
invalidateWorkflowCache
public void invalidateWorkflowCache()Causes eviction of all workflows in the worker cache
-