... | ... | @@ -34,10 +34,9 @@ Examples are given below. |
|
|
### Testing a Usual Stage
|
|
|
|
|
|
```java
|
|
|
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
|
|
|
import static org.hamcrest.core.Is.is;
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
import static teetime.framework.test.StageTester.test;
|
|
|
import static teetime.framework.test.StageTester.*;
|
|
|
|
|
|
public class CounterTest {
|
|
|
|
... | ... | @@ -50,14 +49,11 @@ public class CounterTest { |
|
|
|
|
|
@Test
|
|
|
public void counterValueShouldBeCorrect() {
|
|
|
List<Integer> results = new ArrayList<Integer>();
|
|
|
|
|
|
test(counter).and()
|
|
|
.send(1, 2, -5, 10, 9).to(counter.getInputPort()).and()
|
|
|
.receive(results).from(counter.getOutputPort()).and()
|
|
|
.start();
|
|
|
|
|
|
assertThat(results, contains(1, 2, -5, 10, 9));
|
|
|
assertThat(counter.getOutputPort(), produces(1, 2, -5, 10, 9));
|
|
|
assertThat(counter.getNumElementsPassed(), is(5));
|
|
|
}
|
|
|
}
|
... | ... | @@ -72,20 +68,15 @@ public class CounterTest { |
|
|
|
|
|
@Test
|
|
|
public void outputMatchedAndMismatchedElements() {
|
|
|
List<Clazz> matchedElements = new ArrayList<InstanceOfFilterTest.Clazz>();
|
|
|
List<Object> mismatchedElements = new ArrayList<>();
|
|
|
|
|
|
Clazz clazz = new Clazz();
|
|
|
Integer number = 42;
|
|
|
final Clazz clazz = new Clazz();
|
|
|
final Integer number = 42;
|
|
|
|
|
|
test(filter).and()
|
|
|
.send(clazz, number, clazz).to(filter.getInputPort()).and()
|
|
|
.receive(matchedElements).from(filter.getMatchedOutputPort()).and()
|
|
|
.receive(mismatchedElements).from(filter.getMismatchedOutputPort()).and()
|
|
|
.start();
|
|
|
.send(clazz, number, clazz).to(filter.getInputPort())
|
|
|
.start();
|
|
|
|
|
|
assertThat(matchedElements, contains(clazz, clazz));
|
|
|
assertThat(mismatchedElements, contains(number));
|
|
|
assertThat(filter.getMatchedOutputPort(), produces(clazz, clazz));
|
|
|
assertThat(filter.getMismatchedOutputPort(), produces(number));
|
|
|
}
|
|
|
|
|
|
```
|
... | ... | @@ -99,13 +90,9 @@ public class CounterTest { |
|
|
|
|
|
@Test
|
|
|
public void testProducer() throws Exception {
|
|
|
List<Integer> outputElements = new ArrayList<>();
|
|
|
|
|
|
test(producer)
|
|
|
.receive(outputElements).from(producer.getOutputPort()).and()
|
|
|
.start();
|
|
|
test(producer).start();
|
|
|
|
|
|
assertThat(outputElements, contains(1, 2, 3));
|
|
|
assertThat(producer.getOutputPort(), produces(1, 2, 3));
|
|
|
}
|
|
|
```
|
|
|
|
... | ... | |