public final class TestWorkflowEnvironmentInternal extends java.lang.Object implements TestWorkflowEnvironment
Constructor and Description |
---|
TestWorkflowEnvironmentInternal(TestEnvironmentOptions options) |
Modifier and Type | Method and Description |
---|---|
void |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Blocks until all tasks have completed execution after a shutdown request, or the timeout
occurs, or the current thread is interrupted, whichever happens first.
|
void |
close()
|
long |
currentTimeMillis()
Returns the current in-memory test Temporal service time in milliseconds.
|
java.lang.String |
getDiagnostics()
Returns the diagnostic data about the internal service state.
|
java.lang.String |
getNamespace() |
io.temporal.worker.WorkerFactory |
getWorkerFactory() |
io.temporal.client.WorkflowClient |
getWorkflowClient()
Creates a WorkflowClient that is connected to the in-memory test Temporal service.
|
io.temporal.serviceclient.WorkflowServiceStubs |
getWorkflowService()
Returns the in-memory test Temporal service that is owned by this.
|
boolean |
isShutdown()
|
boolean |
isStarted()
Was
TestWorkflowEnvironment.start() called? |
boolean |
isTerminated()
Are all tasks done after
TestWorkflowEnvironment.shutdownNow() or TestWorkflowEnvironment.shutdown() ? |
io.temporal.worker.Worker |
newWorker(java.lang.String taskQueue)
Creates a new Worker instance that is connected to the in-memory test Temporal service.
|
io.temporal.worker.Worker |
newWorker(java.lang.String taskQueue,
io.temporal.worker.WorkerOptions options)
Creates a new Worker instance that is connected to the in-memory test Temporal service.
|
void |
registerDelayedCallback(java.time.Duration delay,
java.lang.Runnable r)
Registers a callback to run after the specified delay according to the test Temporal service
internal clock.
|
void |
shutdown()
Initiates an orderly shutdown in which polls are stopped and already received workflow and
activity tasks are executed.
|
void |
shutdownNow()
Initiates an orderly shutdown in which polls are stopped and already received workflow and
activity tasks are attempted to be stopped.
|
void |
sleep(java.time.Duration duration)
Wait until internal test Temporal service time passes the specified duration.
|
void |
start()
Start all workers created by this factory.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newInstance, newInstance
public TestWorkflowEnvironmentInternal(TestEnvironmentOptions options)
public io.temporal.worker.Worker newWorker(java.lang.String taskQueue)
TestWorkflowEnvironment
newWorker
in interface TestWorkflowEnvironment
taskQueue
- task queue to poll.public io.temporal.worker.Worker newWorker(java.lang.String taskQueue, io.temporal.worker.WorkerOptions options)
TestWorkflowEnvironment
newWorker
in interface TestWorkflowEnvironment
taskQueue
- task queue to poll.public io.temporal.client.WorkflowClient getWorkflowClient()
TestWorkflowEnvironment
getWorkflowClient
in interface TestWorkflowEnvironment
public long currentTimeMillis()
TestWorkflowEnvironment
System.currentTimeMillis()
due to time skipping.currentTimeMillis
in interface TestWorkflowEnvironment
public void sleep(java.time.Duration duration)
TestWorkflowEnvironment
sleep
in interface TestWorkflowEnvironment
public void registerDelayedCallback(java.time.Duration delay, java.lang.Runnable r)
TestWorkflowEnvironment
registerDelayedCallback
in interface TestWorkflowEnvironment
public io.temporal.serviceclient.WorkflowServiceStubs getWorkflowService()
TestWorkflowEnvironment
getWorkflowService
in interface TestWorkflowEnvironment
public java.lang.String getNamespace()
getNamespace
in interface TestWorkflowEnvironment
public java.lang.String getDiagnostics()
TestWorkflowEnvironment
@Rule
public TestWatcher watchman =
new TestWatcher() {
@Override
protected void failed(Throwable e, Description description) {
System.err.println(testEnvironment.getDiagnostics());
testEnvironment.close();
}
};
getDiagnostics
in interface TestWorkflowEnvironment
public void close()
TestWorkflowEnvironment
TestWorkflowEnvironment.shutdownNow()
and TestWorkflowEnvironment.awaitTermination(long, TimeUnit)
.close
in interface TestWorkflowEnvironment
public void start()
TestWorkflowEnvironment
start
in interface TestWorkflowEnvironment
public boolean isStarted()
TestWorkflowEnvironment
TestWorkflowEnvironment.start()
called?isStarted
in interface TestWorkflowEnvironment
public boolean isShutdown()
TestWorkflowEnvironment
isShutdown
in interface TestWorkflowEnvironment
public boolean isTerminated()
TestWorkflowEnvironment
TestWorkflowEnvironment.shutdownNow()
or TestWorkflowEnvironment.shutdown()
?isTerminated
in interface TestWorkflowEnvironment
public void shutdown()
TestWorkflowEnvironment
ActivityExecutionContext.heartbeat(Object)
start throwing ActivityWorkerShutdownException
. Invocation has no additional effect if
already shut down. This method does not wait for previously received tasks to complete
execution. Use TestWorkflowEnvironment.awaitTermination(long, TimeUnit)
to do that.shutdown
in interface TestWorkflowEnvironment
public void shutdownNow()
TestWorkflowEnvironment
ActivityExecutionContext.heartbeat(Object)
start throwing ActivityWorkerShutdownException
. Invocation has no additional effect if
already shut down. This method does not wait for previously received tasks to complete
execution. Use TestWorkflowEnvironment.awaitTermination(long, TimeUnit)
to do that.shutdownNow
in interface TestWorkflowEnvironment
public void awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
TestWorkflowEnvironment
awaitTermination
in interface TestWorkflowEnvironment
public io.temporal.worker.WorkerFactory getWorkerFactory()
getWorkerFactory
in interface TestWorkflowEnvironment