use of com.ibm.streamsx.topology.tester.spl.ExpectedTuples in project streamsx.topology by IBMStreams.
the class ConditionTest method testSPLContentsGood.
@Test
public void testSPLContentsGood() throws Exception {
final Topology topology = new Topology();
TStream<String> source = topology.strings("A", "B", "C", "D");
StreamSchema schema = SPLSchemas.STRING.extend("int32", "id");
SPLStream tested = SPLStreams.convertStream(source, (s, t) -> {
t.setString(0, s);
t.setInt(1, s.charAt(0));
return t;
}, schema);
ExpectedTuples expected = new ExpectedTuples(schema);
int id = "A".charAt(0);
expected.addAsTuple(new RString("A"), id);
expected.addAsTuple(new RString("B"), ++id);
expected.addAsTuple(new RString("C"), ++id);
expected.addAsTuple(new RString("D"), ++id);
Condition<List<Tuple>> contents = expected.contents(tested);
boolean passed = complete(topology.getTester(), contents, 10, TimeUnit.SECONDS);
assertTrue(contents.toString(), contents.valid());
assertTrue(passed);
}
use of com.ibm.streamsx.topology.tester.spl.ExpectedTuples in project streamsx.topology by IBMStreams.
the class ConditionTest method testSPLContentsBad.
@Test
public void testSPLContentsBad() throws Exception {
final Topology topology = new Topology();
TStream<String> source = topology.strings("A", "B", "C", "D");
StreamSchema schema = SPLSchemas.STRING.extend("int32", "id");
SPLStream tested = SPLStreams.convertStream(source, (s, t) -> {
t.setString(0, s);
t.setInt(1, s.charAt(0));
return t;
}, schema);
ExpectedTuples expected = new ExpectedTuples(schema);
int id = "A".charAt(0);
expected.addAsTuple(new RString("A"), id);
expected.addAsTuple(new RString("B"), ++id);
expected.addAsTuple(new RString("C"), 1241241);
expected.addAsTuple(new RString("D"), ++id);
Condition<List<Tuple>> contents = expected.contents(tested);
boolean passed = complete(topology.getTester(), contents, 10, TimeUnit.SECONDS);
assertFalse(passed);
assertFalse(contents.toString(), contents.valid());
}
Aggregations