Search in sources :

Example 6 with CycleSegment

use of io.engineblock.activityapi.cyclelog.buffers.cycles.CycleSegment in project engineblock by engineblock.

the class CycleArrayTest method testBasicArray.

@Test
public void testBasicArray() {
    CycleArray a1 = new CycleArray(2, 3, 9);
    CycleSegment s1 = a1.getInputSegment(1);
    assertThat(s1).isNotNull();
    assertThat(s1.isExhausted()).isFalse();
    long v1 = s1.nextCycle();
    assertThat(v1).isEqualTo(2L);
    assertThat(s1.isExhausted()).isTrue();
    long v2 = s1.nextCycle();
    assertThat(v2).isLessThan(0);
    CycleSegment s2 = a1.getInputSegment(2);
    assertThat(s2).isNotNull();
    assertThat(s2.isExhausted()).isFalse();
    long v3 = s2.nextCycle();
    assertThat(v3).isEqualTo(3L);
    assertThat(s2.isExhausted()).isFalse();
    long v4 = s2.nextCycle();
    assertThat(v4).isEqualTo(9L);
    assertThat(s2.isExhausted()).isTrue();
    long v5 = s2.nextCycle();
    assertThat(v5).isLessThan(0);
    CycleSegment s3 = a1.getInputSegment(1);
    assertThat(s3).isNull();
}
Also used : CycleArray(io.engineblock.activityapi.cyclelog.buffers.cycles.CycleArray) CycleSegment(io.engineblock.activityapi.cyclelog.buffers.cycles.CycleSegment) Test(org.testng.annotations.Test)

Aggregations

CycleSegment (io.engineblock.activityapi.cyclelog.buffers.cycles.CycleSegment)6 Test (org.testng.annotations.Test)4 CycleArray (io.engineblock.activityapi.cyclelog.buffers.cycles.CycleArray)2 Timer (com.codahale.metrics.Timer)1 CycleResultSegmentBuffer (io.engineblock.activityapi.cyclelog.buffers.results.CycleResultSegmentBuffer)1 CycleResultsSegment (io.engineblock.activityapi.cyclelog.buffers.results.CycleResultsSegment)1