public class RouterSinkTests extends AbstractStreamIntegrationTest {
@Test
public void testUsingExpression() {
FileSink fileSink = newFileSink().binary(true);
HttpSource httpSource = newHttpSource();
String queue1 = generateQueueName();
String queue2 = generateQueueName();
stream().create(generateStreamName(), "%s > transform --expression=payload+'-foo' | %s", queue1, fileSink);
stream().create(generateStreamName(), "%s > transform --expression=payload+'-bar' | %s", queue2, fileSink);
stream().create(generateStreamName(),
"%s | router --expression=payload.contains('a')?'" + queue1 + "':'" + queue2 + "'",
httpSource);
httpSource.ensureReady();
httpSource.postData("a");
assertThat(fileSink, eventually(hasContentsThat(equalTo("a-foo"))));
httpSource.postData("b");
assertThat(fileSink, eventually(hasContentsThat(equalTo("a-foob-bar"))));
}