use of io.engineblock.activityapi.cyclelog.outputs.SimpleCycleResult in project engineblock by engineblock.
the class ResultFilteringSieveTest method testBasicFilter.
@Test
public void testBasicFilter() {
ResultFilteringSieve sieve = new ResultFilteringSieve.Builder().discardByDefault().include(3).build();
assertThat(sieve.apply(new SimpleCycleResult(3L, 2))).isEqualTo(TristateFilter.Policy.Discard);
assertThat(sieve.apply(new SimpleCycleResult(3L, 3))).isEqualTo(TristateFilter.Policy.Keep);
}
use of io.engineblock.activityapi.cyclelog.outputs.SimpleCycleResult in project engineblock by engineblock.
the class ResultFilteringSieveTest method testDefaultPolicy.
@Test
public void testDefaultPolicy() {
ResultFilteringSieve sieve = new ResultFilteringSieve.Builder().discardByDefault().build();
assertThat(sieve.apply(new SimpleCycleResult(4, 5))).isEqualTo(TristateFilter.Policy.Discard);
}
use of io.engineblock.activityapi.cyclelog.outputs.SimpleCycleResult in project engineblock by engineblock.
the class ResultFilteringSieveTest method testPredicateConversions.
public void testPredicateConversions() {
SimpleCycleResult c1 = new SimpleCycleResult(1, 1);
SimpleCycleResult c2 = new SimpleCycleResult(2, 2);
SimpleCycleResult c3 = new SimpleCycleResult(3, 3);
SimpleCycleResult c4 = new SimpleCycleResult(4, 4);
SimpleCycleResult c5 = new SimpleCycleResult(5, 5);
SimpleCycleResult c6 = new SimpleCycleResult(6, 6);
SimpleCycleResult c7 = new SimpleCycleResult(7, 7);
List<CycleResult> results = new ArrayList<CycleResult>() {
{
add(c1);
add(c2);
add(c3);
add(c4);
add(c5);
add(c6);
add(c7);
}
};
Predicate<ResultReadable> includer = new ResultFilteringSieve.Builder().include(3).exclude(4).build().toInclusivePredicate();
List<CycleResult> included = results.stream().filter(includer).collect(Collectors.toList());
assertThat(included).containsExactly(c1, c2, c3, c5, c6, c7);
Predicate<ResultReadable> excluder = new ResultFilteringSieve.Builder().include(3).exclude(4).build().toExclusivePredicate();
List<CycleResult> excluded = results.stream().filter(excluder).collect(Collectors.toList());
assertThat(excluded).containsExactly(c3);
}
use of io.engineblock.activityapi.cyclelog.outputs.SimpleCycleResult in project engineblock by engineblock.
the class CoreResultFilterTest method testComponentLifecycle.
@Test
public void testComponentLifecycle() {
ResultValueFilterType filterType = CoreResultValueFilter.FINDER.get("core").orElseThrow(() -> new RuntimeException("Unable to find " + ResultValueFilterType.class.getSimpleName() + " for 'core'"));
ResultFilterDispenser fd = filterType.getDispenser("in:5,ex:6,in:7");
Predicate<ResultReadable> cycleResultFilter = fd.getResultFilter();
assertThat(cycleResultFilter.test(new SimpleCycleResult(3, 3))).isFalse();
assertThat(cycleResultFilter.test(new SimpleCycleResult(3, 5))).isTrue();
assertThat(cycleResultFilter.test(new SimpleCycleResult(3, 6))).isFalse();
assertThat(cycleResultFilter.test(new SimpleCycleResult(3, 7))).isTrue();
assertThat(cycleResultFilter.test(new SimpleCycleResult(3, 8))).isFalse();
}
use of io.engineblock.activityapi.cyclelog.outputs.SimpleCycleResult in project engineblock by engineblock.
the class ResultFilteringSieveTest method testRangeFilter.
@Test
public void testRangeFilter() {
ResultFilteringSieve sieve = new ResultFilteringSieve.Builder().keepByDefault().exclude(3, 7).exclude(9).build();
assertThat(sieve.apply(new SimpleCycleResult(3L, 2))).isEqualTo(TristateFilter.Policy.Keep);
assertThat(sieve.apply(new SimpleCycleResult(3L, 3))).isEqualTo(TristateFilter.Policy.Discard);
assertThat(sieve.apply(new SimpleCycleResult(3L, 7))).isEqualTo(TristateFilter.Policy.Discard);
assertThat(sieve.apply(new SimpleCycleResult(3L, 8))).isEqualTo(TristateFilter.Policy.Keep);
assertThat(sieve.apply(new SimpleCycleResult(3L, 9))).isEqualTo(TristateFilter.Policy.Discard);
assertThat(sieve.apply(new SimpleCycleResult(3L, 10))).isEqualTo(TristateFilter.Policy.Keep);
}
Aggregations