Search in sources :

Example 1 with Action

use of io.engineblock.activityapi.core.Action in project engineblock by engineblock.

the class DiagActivityTypeTest method testDiagActivity.

@Test
public void testDiagActivity() {
    DiagActivityType da = new DiagActivityType();
    da.getName();
    ActivityDef ad = ActivityDef.parseActivityDef("type=diag;");
    DiagActivity a = da.getActivity(ad);
    a.initActivity();
    ActionDispenser actionDispenser = da.getActionDispenser(a);
    Action action = actionDispenser.getAction(1);
    action.runCycle(1L);
}
Also used : Action(io.engineblock.activityapi.core.Action) ActionDispenser(io.engineblock.activityapi.core.ActionDispenser) ActivityDef(io.engineblock.activityimpl.ActivityDef) Test(org.testng.annotations.Test)

Example 2 with Action

use of io.engineblock.activityapi.core.Action in project engineblock by engineblock.

the class StdoutActivityTypeTest method testDiagActivity.

@Test
public void testDiagActivity() {
    StdoutActivityType stdoutAt = new StdoutActivityType();
    String atname = stdoutAt.getName();
    assertThat(atname.equals("stdout"));
    ActivityDef ad = ActivityDef.parseActivityDef("type=stdout; yaml=stdout-test;");
    StdoutActivity stdoutActivity = stdoutAt.getActivity(ad);
    ActionDispenser actionDispenser = stdoutAt.getActionDispenser(stdoutActivity);
    Action action = actionDispenser.getAction(1);
}
Also used : Action(io.engineblock.activityapi.core.Action) ActionDispenser(io.engineblock.activityapi.core.ActionDispenser) ActivityDef(io.engineblock.activityimpl.ActivityDef) Test(org.testng.annotations.Test)

Example 3 with Action

use of io.engineblock.activityapi.core.Action in project engineblock by engineblock.

the class CoreMotorTest method testIteratorStride.

@Test
public void testIteratorStride() {
    BlockingSegmentInput lockstepper = new BlockingSegmentInput();
    Motor cm1 = new CoreMotor(new SimpleActivity("stride=3"), 1L, lockstepper);
    AtomicLongArray ary = new AtomicLongArray(10);
    Action a1 = getTestArrayConsumer(ary);
    cm1.setAction(a1);
    cm1.getSlotStateTracker().enterState(RunState.Starting);
    Thread t1 = new Thread(cm1);
    t1.setName("cm1");
    t1.start();
    try {
        // allow action time to be waiting in monitor for test fixture
        Thread.sleep(500);
    } catch (InterruptedException ignored) {
    }
    lockstepper.publishSegment(11L, 12L, 13L);
    boolean result = awaitAryCondition(ala -> (ala.get(2) == 13L), ary, 5000, 100);
    assertThat(ary.get(0)).isEqualTo(11L);
    assertThat(ary.get(1)).isEqualTo(12L);
    assertThat(ary.get(2)).isEqualTo(13L);
    assertThat(ary.get(3)).isEqualTo(0L);
}
Also used : Action(io.engineblock.activityapi.core.Action) BlockingSegmentInput(io.engineblock.activitycore.fortesting.BlockingSegmentInput) CoreMotor(io.engineblock.activityimpl.motor.CoreMotor) Motor(io.engineblock.activityapi.core.Motor) SimpleActivity(io.engineblock.activityimpl.SimpleActivity) AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray) CoreMotor(io.engineblock.activityimpl.motor.CoreMotor) Test(org.testng.annotations.Test)

Aggregations

Action (io.engineblock.activityapi.core.Action)3 Test (org.testng.annotations.Test)3 ActionDispenser (io.engineblock.activityapi.core.ActionDispenser)2 ActivityDef (io.engineblock.activityimpl.ActivityDef)2 Motor (io.engineblock.activityapi.core.Motor)1 BlockingSegmentInput (io.engineblock.activitycore.fortesting.BlockingSegmentInput)1 SimpleActivity (io.engineblock.activityimpl.SimpleActivity)1 CoreMotor (io.engineblock.activityimpl.motor.CoreMotor)1 AtomicLongArray (java.util.concurrent.atomic.AtomicLongArray)1