use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class PythonFunctionalOperatorsKwargsTest method testFilter.
@Test
public void testFilter() throws Exception {
Topology topology = new Topology("testFilter");
SPLStream tuples = sampleFilterStream(topology);
PythonFunctionalOperatorsTest.addTestToolkit(tuples);
SPLStream pass = SPL.invokeOperator("com.ibm.streamsx.topology.pysamples.kwargs::ContainsFilter", tuples, tuples.getSchema(), Collections.singletonMap("term", "23"));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(pass, 2);
Condition<List<Tuple>> passResult = tester.tupleContents(pass);
this.getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
complete(tester, expectedCount, 10, TimeUnit.SECONDS);
assertEquals(TEST_TUPLES[1], passResult.getResult().get(0));
assertEquals(TEST_TUPLES[3], passResult.getResult().get(1));
assertTrue(expectedCount.valid());
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method createSPLFlowFromStream.
@SuppressWarnings("serial")
private static SPLStream createSPLFlowFromStream(final Topology topology, final boolean skipSecond) {
TStream<String> source = topology.strings("325", "457", "9325");
TStream<IntAndString> iands = source.transform(new Function<String, IntAndString>() {
@Override
public IntAndString apply(String v1) {
IntAndString is = new IntAndString();
is.s = v1;
is.n = Integer.valueOf(v1) + 93;
return is;
}
});
StreamSchema schema = Type.Factory.getStreamSchema("tuple<int32 ii, rstring ss>");
SPLStream splStream = SPLStreams.convertStream(iands, new BiFunction<IntAndString, OutputTuple, OutputTuple>() {
@Override
public OutputTuple apply(IntAndString v1, OutputTuple v2) {
if (skipSecond & v1.n == 550)
return null;
v2.setString("ss", v1.s);
v2.setInt("ii", v1.n);
return v2;
}
}, schema);
assertSPLStream(splStream, schema);
return splStream;
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method testTuples.
@Test
public void testTuples() throws Exception {
Topology topology = new Topology("testTuples");
SPLStream tuples = testTupleStream(topology);
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(tuples, TEST_TUPLES.length);
Condition<List<Tuple>> expectedTuples = tester.tupleContents(tuples, TEST_TUPLES);
complete(tester, expectedCount, 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(expectedTuples.toString(), expectedTuples.valid());
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method testConversionFromSPLToStringAttribute.
@Test
public void testConversionFromSPLToStringAttribute() throws Exception {
final Topology topology = new Topology();
SPLStream splStream = testTupleStream(topology);
TStream<String> strings = SPLStreams.toStringStream(splStream, "vl");
assertEquals(String.class, strings.getTupleClass());
completeAndValidate(strings, 10, "34535", "43675232", "654932", "82343");
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method testConversionToSPLWithSkip.
@Test
public void testConversionToSPLWithSkip() throws Exception {
final Topology topology = new Topology("ConvertSPLStream");
SPLStream splStream = createSPLFlowFromStream(topology, true);
TStream<String> tupleString = splStream.toTupleString();
completeAndValidate(tupleString, 10, "{ii=418,ss=\"325\"}", "{ii=9418,ss=\"9325\"}");
}
Aggregations