ZTestWorkflowEnvironment

zio.temporal.testkit.ZTestWorkflowEnvironment
See theZTestWorkflowEnvironment companion class

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final class ActivityRunOptionsWithZIOPartiallyApplied[R](dummy: Boolean = ...) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

Access activity options

Access activity options

Attributes

Internal helper used by the inline newWorkflowStub[A] (no-arg, deprecated) — wraps the testEnv access and the codec auto-reg thunk. Cannot be inline itself because the deprecated DSL class constructor is private[zio].

Internal helper used by the inline newWorkflowStub[A] (no-arg, deprecated) — wraps the testEnv access and the codec auto-reg thunk. Cannot be inline itself because the deprecated DSL class constructor is private[zio].

Attributes

This time might not be equal to java.lang.System.currentTimeMillis() due to time skipping.

This time might not be equal to java.lang.System.currentTimeMillis() due to time skipping.

Attributes

Returns

the current in-memory test Temporal service time in milliseconds or java.lang.System.currentTimeMillis() if an external service without time skipping support is used

def getDiagnostics: URIO[ZTestWorkflowEnvironment[Any], String]

Currently prints histories of all workflow instances stored in the service. This is useful information to print in the case of a unit test failure.

Currently prints histories of all workflow instances stored in the service. This is useful information to print in the case of a unit test failure.

Attributes

Returns

the diagnostic data about the internal service state.

def makeDefault[R : Tag]: URLayer[R, ZTestWorkflowEnvironment[R]]

Creates a new instance of ZTestWorkflowEnvironment with default options

Creates a new instance of ZTestWorkflowEnvironment with default options

Attributes

Returns

managed instance of test environment

def newUntypedWorkflowStub(workflowType: String, options: ZWorkflowOptions): URIO[ZTestWorkflowEnvironment[Any], Untyped]

Creates workflow untyped client stub that can be used to start a single workflow execution. After workflow is started it can be also used to send signals or queries to it.

Creates workflow untyped client stub that can be used to start a single workflow execution. After workflow is started it can be also used to send signals or queries to it.

Value parameters

options

options used to start a workflow through returned stub

workflowType

name of the workflow type

Attributes

Returns

builder instance

def newUntypedWorkflowStub(workflowId: String, runId: Option[String]): URIO[ZTestWorkflowEnvironment[Any], Untyped]

Creates workflow untyped client stub for a known execution.

Creates workflow untyped client stub for a known execution.

Value parameters

runId

runId of the workflow execution. If not provided the last workflow with the given workflowId is assumed.

workflowId

workflow id and optional run id for execution

Attributes

Returns

Stub that can be used to start workflow and later to signal or query it.

def newWorker(taskQueue: String, options: ZWorkerOptions = ...): URIO[ZTestWorkflowEnvironment[Any], ZWorker]

Creates a new Worker instance that is connected to the in-memory test Temporal service.

Creates a new Worker instance that is connected to the in-memory test Temporal service.

Value parameters

taskQueue

task queue to poll.

Attributes

inline def newWorkflowStub[A : IsWorkflow](options: ZWorkflowOptions): URIO[ZTestWorkflowEnvironment[Any], Of[A]]

Creates workflow client stub that can be used to start a single workflow execution. The first call must be to a method annotated with @zio.temporal.workflowMethod. After workflow is started it can be also used to send signals or queries to it. one.

Creates workflow client stub that can be used to start a single workflow execution. The first call must be to a method annotated with @zio.temporal.workflowMethod. After workflow is started it can be also used to send signals or queries to it. one.

Auto-registration: same contract as above. Applies to all newWorkflowStub[A] overloads on this object.

Type parameters

A

workflow interface

Value parameters

options

options used to start a workflow through returned stub

Attributes

Returns

builder instance

inline def newWorkflowStub[A : IsWorkflow](workflowId: String, runId: Option[String] = ...): URIO[ZTestWorkflowEnvironment[Any], Of[A]]

Creates workflow client stub for a known execution.

Creates workflow client stub for a known execution.

Auto-registration: same contract as the other overloads.

Type parameters

A

interface that given workflow implements.

Value parameters

runId

Run id of the workflow execution.

workflowId

Workflow id.

Attributes

Returns

Stub that implements workflowInterface and can be used to signal or query it.

def setup(options: ZAwaitTerminationOptions = ...): URIO[ZTestWorkflowEnvironment[Any] & Scope, Unit]

Setup test environment with a guaranteed finalization.

Setup test environment with a guaranteed finalization.

Value parameters

options

await options with polling interval and poll delay

Attributes

def sleep(duration: Duration): URIO[ZTestWorkflowEnvironment[Any], Unit]

Wait until internal test Temporal service time passes the specified duration. This call also indicates that workflow time might jump forward (if none of the activities are running) up to the specified duration.

Wait until internal test Temporal service time passes the specified duration. This call also indicates that workflow time might jump forward (if none of the activities are running) up to the specified duration.

This method falls back to Thread.sleep if an external service without time skipping support is used

Attributes

def workflowClientWithZIO[R : Tag, E, A](f: ZWorkflowClient => ZIO[R, E, A]): ZIO[ZTestWorkflowEnvironment[Any] & R, E, A]

Access a WorkflowClient that is connected to the in-memory test Temporal service.

Access a WorkflowClient that is connected to the in-memory test Temporal service.

Attributes

Returns the in-memory test Temporal service that is owned by this.

Returns the in-memory test Temporal service that is owned by this.

Attributes

Deprecated methods

Creates new untyped type workflow stub builder

Creates new untyped type workflow stub builder

Value parameters

workflowType

name of the workflow type

Attributes

Returns

builder instance

Deprecated
[Since version 0.6.0] Use newUntypedWorkflowStub accepting ZWorkerOptions

Creates new typed workflow stub builder.

Creates new typed workflow stub builder.

Auto-registration: auto-registers A's codecs into the test env's registry (which is the same one shared with its embedded client and workers). Opt-out (withDataConverter(raw)None) is a silent no-op.

Type parameters

A

workflow interface

Attributes

Returns

builder instance

Deprecated
[Since version 0.6.0] Use newWorkflowStub accepting ZWorkerOptions