... | ... | @@ -57,12 +57,42 @@ public class CounterTest { |
|
|
}
|
|
|
```
|
|
|
|
|
|
### Testing a Stage With Multiple Output Ports
|
|
|
```java
|
|
|
@Before
|
|
|
public void before() {
|
|
|
filter = InstanceOfFilter<Object, Clazz>(Clazz.class);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void outputMatchedAndMismatchedElements() {
|
|
|
List<Clazz> matchedElements = new ArrayList<InstanceOfFilterTest.Clazz>();
|
|
|
List<Object> mismatchedElements = new ArrayList<>();
|
|
|
|
|
|
Clazz clazz = new Clazz();
|
|
|
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())
|
|
|
.start();
|
|
|
|
|
|
assertThat(matchedElements, contains(clazz, clazz));
|
|
|
assertThat(mismatchedElements, contains(number));
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
### Testing a Producer Stage
|
|
|
```java
|
|
|
@Before
|
|
|
public void before() {
|
|
|
producer = new InitialElementProducer<Integer>(1, 2, 3);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testProducer() throws Exception {
|
|
|
InitialElementProducer<Integer> producer = new InitialElementProducer<>(1, 2, 3);
|
|
|
|
|
|
List<Integer> outputElements = new ArrayList<>();
|
|
|
|
|
|
test(producer)
|
... | ... | @@ -75,10 +105,13 @@ public class CounterTest { |
|
|
|
|
|
### Testing a Sink Stage:
|
|
|
```java
|
|
|
@Before
|
|
|
public void before() {
|
|
|
consumer = new CollectorSink<Integer>();
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testSink() throws Exception {
|
|
|
CollectorSink<Integer> consumer = new CollectorSink<>();
|
|
|
|
|
|
test(consumer).and()
|
|
|
.send(1, 2, 3).to(consumer.getInputPort()).and()
|
|
|
.start();
|
... | ... | |