Class SDKTestWorkflowRule

java.lang.Object
io.temporal.testing.internal.SDKTestWorkflowRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class SDKTestWorkflowRule extends Object implements 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
  • Field Details

    • NAMESPACE

      public static final String NAMESPACE
      See Also:
    • UUID_REGEXP

      public static final String 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

      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:
      apply in interface org.junit.rules.TestRule
    • getInterceptor

      public <T extends io.temporal.common.interceptors.WorkerInterceptor> T getInterceptor(Class<T> type)
    • getTaskQueue

      public String getTaskQueue()
    • getDeploymentName

      public String getDeploymentName()
    • getNexusEndpoint

      public io.temporal.api.nexus.v1.Endpoint getNexusEndpoint()
    • getNexusClient

      public io.temporal.client.NexusClient getNexusClient()
      Returns a NexusClient bound 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

      public io.temporal.worker.Worker newWorkerWithBuildID(String buildId)
      Start a new worker, changing only the build ID
    • getWorkerFactoryOptions

      public io.temporal.worker.WorkerFactoryOptions getWorkerFactoryOptions()
    • getExecutionHistory

      public io.temporal.common.WorkflowExecutionHistory getExecutionHistory(String workflowId)
    • getExecutionHistory

      public io.temporal.common.WorkflowExecutionHistory getExecutionHistory(String workflowId, String runId)
    • getHistoryEvents

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

      public void assertHistoryEvent(String workflowId, io.temporal.api.enums.v1.EventType eventType)
      Asserts that an event of the given EventType is found in the history.
    • assertHistoryEvent

      public void assertHistoryEvent(String workflowId, String runId, io.temporal.api.enums.v1.EventType eventType)
    • assertNoHistoryEvent

      public void assertNoHistoryEvent(String workflowId, io.temporal.api.enums.v1.EventType eventType)
      Asserts that an event of the given EventType is not found in the history.
    • assertNoHistoryEvent

      public void assertNoHistoryEvent(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.
    • 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

      public void waitForTheEndOfWFT(String workflowId)
      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

      public TestWorkflowEnvironment getTestEnvironment()
    • newWorkflowStub

      public <T> T newWorkflowStub(Class<T> workflow)
    • newWorkflowStubTimeoutOptions

      public <T> T newWorkflowStubTimeoutOptions(Class<T> workflow)
    • newWorkflowStubTimeoutOptions

      public <T> T newWorkflowStubTimeoutOptions(Class<T> workflow, String workflowIdPrefix)
    • newWorkflowStub200sTimeoutOptions

      public <T> T newWorkflowStub200sTimeoutOptions(Class<T> workflow)
    • newUntypedWorkflowStub

      public io.temporal.client.WorkflowStub newUntypedWorkflowStub(String workflow)
    • newUntypedWorkflowStubTimeoutOptions

      public io.temporal.client.WorkflowStub newUntypedWorkflowStubTimeoutOptions(String workflow)
    • waitForOKQuery

      public static void waitForOKQuery(Object anyStub)
      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

      public void regenerateHistoryForReplay(String workflowId, String fileName)
    • registerDelayedCallback

      public void registerDelayedCallback(Duration delay, Runnable r)
    • shutdown

      protected void shutdown() throws Throwable
      Throws:
      Throwable
    • sleep

      public void sleep(Duration d)
    • invalidateWorkflowCache

      public void invalidateWorkflowCache()
      Causes eviction of all workflows in the worker cache