Skip to main content
Version: 6.2.4 (Unmaintained)

Action

Action is a sealed interface representing an immutable, reusable execution unit processed by a Runner.

public sealed interface Action
permits Assert, Conditional, Delay, Instance, Isolated, Parallel, Repeat, Scope, Sequential, Static, Step, Timeout, Until {

String displayName();
}

Design​

An Action defines structure and identity, not execution logic. The runner and scheduler own all descriptor traversal, status transitions, and listener callbacks. Actions carry only their display name; execution behavior is handled by the scheduler interpreting each sealed subtype.

All action subtypes are immutable after construction. For configurable actions, use the corresponding Builder subtype to produce an immutable action snapshot via Builder.build().

Subtypes​

TypeDescription
StepTerminal action wrapping a ContextConsumer.
AssertTerminal action evaluating a boolean condition.
SequentialComposite: executes children sequentially. Dependent/independent modes.
ParallelComposite: executes children concurrently with bounded admission.
ScopeComposite: before-body-after with lifecycle guarantee (after always runs).
StaticComposite: before-body-after without a fixture instance. (Deprecated since 6.2 — use Scope instead.)
InstanceComposite: creates a fixture instance, runs body, destroys instance.
IsolatedComposite: executes body under a named re-entrant lock. Compose with Instance for state isolation.
DelayTerminal: pauses for a duration.
RepeatDecorator: executes a child action N times.
TimeoutDecorator: executes a child action with a wall-clock deadline.
ConditionalComposite: evaluates a Predicate<Context>; runs body when true, passes (body subtree skipped) when false. Does not disrupt dependent sibling execution.
UntilDecorator: executes child repeatedly until predicate satisfied, body passes, or iterations exhausted.

Composition​

Build action trees by nesting actions through builders:

import org.paramixel.api.action.Action;
import static org.paramixel.api.action.Scope.scope;
import static org.paramixel.api.action.Sequential.sequential;
import static org.paramixel.api.action.Step.step;

Action test = scope("browser test")
.before(step("start browser", ctx -> startBrowser()))
.body(sequential("scenario")
.child(step("open page", ctx -> openPage()))
.child(step("verify", ctx -> verifyPage()))
.build())
.after(step("stop browser", ctx -> stopBrowser()))
.build();

See Builder for the Builder sealed interface and its subtypes.

Named builders​

Most composite actions provide a public static method named after the action (e.g., Scope.scope(name)) that returns the corresponding Builder. Import these statically for concise action tree definitions.

Terminal actions Step and Delay also provide named factory methods (step(name, consumer), delay(name, ms), delayRandom(name, min, max)) that return the action directly.

For details and usage examples, see Named Builders.