Skip to content
Snippets Groups Projects
Commit ad107ca0 authored by as's avatar as
Browse files

fix tests

parent c6d711ba
No related branches found
No related tags found
No related merge requests found
...@@ -17,9 +17,7 @@ package teetime.stage.opad.filter; ...@@ -17,9 +17,7 @@ package teetime.stage.opad.filter;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static teetime.framework.test.StageTester.test; import static teetime.framework.test.StageTester.test;
...@@ -46,7 +44,6 @@ public class AnomalyDetectionFilterTest { ...@@ -46,7 +44,6 @@ public class AnomalyDetectionFilterTest {
private StorableDetectionResult input3; private StorableDetectionResult input3;
private StorableDetectionResult input4; private StorableDetectionResult input4;
private List<StorableDetectionResult> inputElements; private List<StorableDetectionResult> inputElements;
private List<StorableDetectionResult> resultsNormalPort; private List<StorableDetectionResult> resultsNormalPort;
private List<StorableDetectionResult> resultsAnnormalPort; private List<StorableDetectionResult> resultsAnnormalPort;
...@@ -65,23 +62,26 @@ public class AnomalyDetectionFilterTest { ...@@ -65,23 +62,26 @@ public class AnomalyDetectionFilterTest {
@Test @Test
public void theOutputPortNormalShouldForwardElements() { public void theOutputPortNormalShouldForwardElements() {
test(adf).and().send(input1, input2).to(adf.getInputPort()).and().receive(resultsNormalPort).from(adf.getOutputPortNormal()).start();
assertThat(resultsNormalPort, contains(input1, input2));
test(adf).and().send(input1, input2).to(adf.getInputPort()).and().receive(resultsAnnormalPort).from(adf.getOutputPortAnnormal()).start(); Collection<Pair<Thread, Throwable>> exceptions;
exceptions = test(adf).and().send(input1, input2).to(adf.getInputPort())
.and().receive(resultsNormalPort).from(adf.getOutputPortNormal())
.and().receive(resultsAnnormalPort).from(adf.getOutputPortAnnormal())
.start();
assertThat(exceptions, is(empty()));
assertThat(resultsNormalPort, contains(input1, input2));
assertThat(resultsAnnormalPort, is(empty())); assertThat(resultsAnnormalPort, is(empty()));
} }
@Test @Test
public void theOutputPortAnnormalShouldForwardElements() { public void theOutputPortAnnormalShouldForwardElements() {
test(adf).and().send(input3, input4).to(adf.getInputPort()) Collection<Pair<Thread, Throwable>> exceptions;
exceptions = test(adf).and().send(input3, input4).to(adf.getInputPort())
.and().receive(resultsNormalPort).from(adf.getOutputPortNormal()) .and().receive(resultsNormalPort).from(adf.getOutputPortNormal())
.start();
assertEquals(0, resultsAnnormalPort.size());
test(adf).and().send(input3, input4).to(adf.getInputPort())
.and().receive(resultsAnnormalPort).from(adf.getOutputPortAnnormal()) .and().receive(resultsAnnormalPort).from(adf.getOutputPortAnnormal())
.start(); .start();
assertThat(exceptions, is(empty()));
assertThat(resultsNormalPort, is(empty()));
assertThat(resultsAnnormalPort, contains(input3, input4)); assertThat(resultsAnnormalPort, contains(input3, input4));
} }
...@@ -90,16 +90,10 @@ public class AnomalyDetectionFilterTest { ...@@ -90,16 +90,10 @@ public class AnomalyDetectionFilterTest {
Collection<Pair<Thread, Throwable>> exceptions; Collection<Pair<Thread, Throwable>> exceptions;
exceptions = test(adf).and().send(inputElements).to(adf.getInputPort()) exceptions = test(adf).and().send(inputElements).to(adf.getInputPort())
.and().receive(resultsNormalPort).from(adf.getOutputPortNormal()) .and().receive(resultsNormalPort).from(adf.getOutputPortNormal())
.start();
assertThat(exceptions, is(empty()));
assertThat(resultsNormalPort, is(not(empty())));
assertThat(resultsNormalPort, contains(input1, input2));
exceptions = test(adf).and().send(inputElements).to(adf.getInputPort())
.and().receive(resultsAnnormalPort).from(adf.getOutputPortAnnormal()) .and().receive(resultsAnnormalPort).from(adf.getOutputPortAnnormal())
.start(); .start();
assertThat(exceptions, is(empty())); assertThat(exceptions, is(empty()));
assertThat(resultsAnnormalPort, is(not(empty()))); assertThat(resultsNormalPort, contains(input1, input2));
assertThat(resultsAnnormalPort, contains(input3, input4)); assertThat(resultsAnnormalPort, contains(input3, input4));
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment