Package io.temporal.testing.internal
Class SDKTestWorkflowRule
- java.lang.Object
-
- io.temporal.testing.internal.SDKTestWorkflowRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class SDKTestWorkflowRule extends java.lang.Object implements org.junit.rules.TestRuleIntended to be used only in the Java SDK test code. This Rule duplicatesTestWorkflowRuleand provides additional convenience methods for SDK development
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSDKTestWorkflowRule.Builder
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAMESPACEstatic booleanREGENERATE_JSON_FILESstatic java.lang.StringtemporalServiceAddressstatic booleanuseExternalServicestatic java.lang.StringUUID_REGEXP
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> voidaddWorkflowImplementationFactory(java.lang.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(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Asserts that an event of the given EventType is found in the history.voidassertNoHistoryEvent(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Asserts that an event of the given EventType is not found in the history.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.io.temporal.internal.common.WorkflowExecutionHistorygetExecutionHistory(io.temporal.api.common.v1.WorkflowExecution execution)io.temporal.api.history.v1.HistorygetHistory(io.temporal.api.common.v1.WorkflowExecution execution)io.temporal.api.history.v1.HistoryEventgetHistoryEvent(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Returns the first event of the given EventType found in the history.java.util.List<io.temporal.api.history.v1.HistoryEvent>getHistoryEvents(io.temporal.api.common.v1.WorkflowExecution execution, 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(java.lang.Class<T> type)java.lang.StringgetTaskQueue()TestWorkflowEnvironmentgetTestEnvironment()io.temporal.worker.WorkergetWorker()io.temporal.client.WorkflowClientgetWorkflowClient()io.temporal.serviceclient.WorkflowServiceStubsgetWorkflowServiceStubs()booleanisUseExternalService()static SDKTestWorkflowRule.BuildernewBuilder()io.temporal.client.WorkflowStubnewUntypedWorkflowStub(java.lang.String workflow)io.temporal.client.WorkflowStubnewUntypedWorkflowStubTimeoutOptions(java.lang.String workflow)<T> TnewWorkflowStub(java.lang.Class<T> workflow)<T> TnewWorkflowStub200sTimeoutOptions(java.lang.Class<T> workflow)<T> TnewWorkflowStubTimeoutOptions(java.lang.Class<T> workflow)voidregenerateHistoryForReplay(io.temporal.api.common.v1.WorkflowExecution execution, java.lang.String fileName)voidregisterDelayedCallback(java.time.Duration delay, java.lang.Runnable r)protected voidshutdown()voidsleep(java.time.Duration d)static voidwaitForOKQuery(io.temporal.client.WorkflowStub stub)Used to ensure that workflow first workflow task is executed.
-
-
-
Field Detail
-
NAMESPACE
public static final java.lang.String NAMESPACE
- See Also:
- Constant Field Values
-
UUID_REGEXP
public static final java.lang.String UUID_REGEXP
- See Also:
- Constant Field Values
-
REGENERATE_JSON_FILES
public static final boolean REGENERATE_JSON_FILES
- See Also:
- Constant Field Values
-
useExternalService
public static final boolean useExternalService
-
temporalServiceAddress
public static final java.lang.String temporalServiceAddress
-
-
Method Detail
-
newBuilder
public static SDKTestWorkflowRule.Builder 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(java.lang.Class<T> type)
-
getTaskQueue
public java.lang.String getTaskQueue()
-
getWorker
public io.temporal.worker.Worker getWorker()
-
getHistory
public io.temporal.api.history.v1.History getHistory(io.temporal.api.common.v1.WorkflowExecution execution)
-
getExecutionHistory
public io.temporal.internal.common.WorkflowExecutionHistory getExecutionHistory(io.temporal.api.common.v1.WorkflowExecution execution)
-
getHistoryEvents
public java.util.List<io.temporal.api.history.v1.HistoryEvent> getHistoryEvents(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Returns list of all events of the given EventType found in the history.
-
getHistoryEvent
public io.temporal.api.history.v1.HistoryEvent getHistoryEvent(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Returns the first event of the given EventType found in the history.
-
assertHistoryEvent
public void assertHistoryEvent(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Asserts that an event of the given EventType is found in the history.
-
assertNoHistoryEvent
public void assertNoHistoryEvent(io.temporal.api.common.v1.WorkflowExecution execution, io.temporal.api.enums.v1.EventType eventType)Asserts that an event of the given EventType is not found in the history.
-
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.
-
getWorkflowClient
public io.temporal.client.WorkflowClient getWorkflowClient()
-
getWorkflowServiceStubs
public io.temporal.serviceclient.WorkflowServiceStubs getWorkflowServiceStubs()
-
isUseExternalService
public boolean isUseExternalService()
-
getTestEnvironment
public TestWorkflowEnvironment getTestEnvironment()
-
newWorkflowStub
public <T> T newWorkflowStub(java.lang.Class<T> workflow)
-
newWorkflowStubTimeoutOptions
public <T> T newWorkflowStubTimeoutOptions(java.lang.Class<T> workflow)
-
newWorkflowStub200sTimeoutOptions
public <T> T newWorkflowStub200sTimeoutOptions(java.lang.Class<T> workflow)
-
newUntypedWorkflowStub
public io.temporal.client.WorkflowStub newUntypedWorkflowStub(java.lang.String workflow)
-
newUntypedWorkflowStubTimeoutOptions
public io.temporal.client.WorkflowStub newUntypedWorkflowStubTimeoutOptions(java.lang.String workflow)
-
waitForOKQuery
public static void waitForOKQuery(io.temporal.client.WorkflowStub stub)
Used to ensure that workflow first workflow task is executed.
-
addWorkflowImplementationFactory
public <R> void addWorkflowImplementationFactory(java.lang.Class<R> factoryImpl, io.temporal.workflow.Functions.Func<R> factoryFunc)
-
regenerateHistoryForReplay
public void regenerateHistoryForReplay(io.temporal.api.common.v1.WorkflowExecution execution, java.lang.String fileName)
-
registerDelayedCallback
public void registerDelayedCallback(java.time.Duration delay, java.lang.Runnable r)
-
shutdown
protected void shutdown() throws java.lang.Throwable- Throws:
java.lang.Throwable
-
sleep
public void sleep(java.time.Duration d)
-
-