Search in sources :

Example 1 with ExpectedTuples

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);
}
Also used : ExpectedTuples(com.ibm.streamsx.topology.tester.spl.ExpectedTuples) RString(com.ibm.streams.operator.types.RString) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) RString(com.ibm.streams.operator.types.RString) StreamSchema(com.ibm.streams.operator.StreamSchema) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) Test(org.junit.Test)

Example 2 with ExpectedTuples

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());
}
Also used : ExpectedTuples(com.ibm.streamsx.topology.tester.spl.ExpectedTuples) RString(com.ibm.streams.operator.types.RString) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) RString(com.ibm.streams.operator.types.RString) StreamSchema(com.ibm.streams.operator.StreamSchema) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) Test(org.junit.Test)

Aggregations

StreamSchema (com.ibm.streams.operator.StreamSchema)2 RString (com.ibm.streams.operator.types.RString)2 Topology (com.ibm.streamsx.topology.Topology)2 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)2 TestTopology (com.ibm.streamsx.topology.test.TestTopology)2 ExpectedTuples (com.ibm.streamsx.topology.tester.spl.ExpectedTuples)2 List (java.util.List)2 Test (org.junit.Test)2