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 Cadence service time in milliseconds.
|
java.lang.String |
getDiagnostics()
Returns the diagnostic data about the internal service state.
|
java.lang.String |
getDomain() |
WorkerFactory |
getWorkerFactory() |
IWorkflowService |
getWorkflowService()
Returns the in-memory test Cadence 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() ? |
Worker |
newWorker(java.lang.String taskList)
Creates a new Worker instance that is connected to the in-memory test Cadence service.
|
Worker |
newWorker(java.lang.String taskList,
java.util.function.Function<WorkerOptions.Builder,WorkerOptions.Builder> overrideOptions)
Creates a new Worker instance that is connected to the in-memory test Cadence service.
|
WorkflowClient |
newWorkflowClient()
Creates a WorkflowClient that is connected to the in-memory test Cadence service.
|
WorkflowClient |
newWorkflowClient(WorkflowClientOptions options)
Creates a WorkflowClient that is connected to the in-memory test Cadence service.
|
void |
registerDelayedCallback(java.time.Duration delay,
java.lang.Runnable r)
Registers a callback to run after the specified delay according to the test Cadence service
internal clock.
|
void |
shutdown()
Initiates an orderly shutdown in which polls are stopped and already received decision and
activity tasks are executed.
|
void |
shutdownNow()
Initiates an orderly shutdown in which polls are stopped and already received decision and
activity tasks are attempted to be stopped.
|
void |
sleep(java.time.Duration duration)
Wait until internal test Cadence 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 Worker newWorker(java.lang.String taskList)
TestWorkflowEnvironment
newWorker
in interface TestWorkflowEnvironment
taskList
- task list to poll.public Worker newWorker(java.lang.String taskList, java.util.function.Function<WorkerOptions.Builder,WorkerOptions.Builder> overrideOptions)
TestWorkflowEnvironment
newWorker
in interface TestWorkflowEnvironment
taskList
- task list to poll.overrideOptions
- is used to override the default worker options.public WorkflowClient newWorkflowClient()
TestWorkflowEnvironment
newWorkflowClient
in interface TestWorkflowEnvironment
public WorkflowClient newWorkflowClient(WorkflowClientOptions options)
TestWorkflowEnvironment
newWorkflowClient
in interface TestWorkflowEnvironment
options
- options used to configure the client.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 IWorkflowService getWorkflowService()
TestWorkflowEnvironment
getWorkflowService
in interface TestWorkflowEnvironment
public java.lang.String getDomain()
getDomain
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
Activity.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
Activity.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 WorkerFactory getWorkerFactory()
getWorkerFactory
in interface TestWorkflowEnvironment