use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class JobConfigOverlaysFileTest method testWithIsolate.
@Test
public void testWithIsolate() throws Exception {
// Just a simple graph, which won't be executed.
Topology topology = newTopology("testNoConfig");
topology.constants(Collections.emptyList()).isolate().sink(tuple -> {
});
sab = bundler().submit(topology).get();
JsonObject jcos = assertSabGetJcos(topology);
assertLegacyDeployment(jcos);
JsonObject jco = jobConfigOverlay(jcos);
assertMissing(jco, "jobConfig");
assertMissing(jco, "operatorConfigs");
assertMissing(jco, "configInstructions");
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class JobConfigSubmissionTest method testItDirect.
private List<String> testItDirect(String topologyName, JobConfig config) throws Exception {
// JobConfig only apply to DISTRIBUTED submit
assumeTrue(getTesterType() == StreamsContext.Type.DISTRIBUTED_TESTER);
assumeTrue(SC_OK);
config.addToConfig(getConfig());
Topology topology = newTopology(topologyName);
topology.addClassDependency(JobPropertiesTestOp.class);
SPLStream sourceSPL = JavaPrimitive.invokeJavaPrimitiveSource(topology, JobPropertiesTestOp.class, Schemas.STRING, null);
TStream<String> source = sourceSPL.toStringStream();
Condition<Long> end = topology.getTester().tupleCount(source, 4);
Condition<List<String>> result = topology.getTester().stringContents(source);
complete(topology.getTester(), end, 10, TimeUnit.SECONDS);
return result.getResult();
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class JSONStreamsTest method testJSONAble.
@Test
public void testJSONAble() throws IOException, Exception {
Topology topology = new Topology();
final TestJSONAble value = new TestJSONAble(42, QUESTION);
TStream<TestJSONAble> s = topology.constants(Collections.singletonList(value)).asType(TestJSONAble.class);
TStream<JSONObject> js = JSONStreams.toJSON(s);
JSONObject ev = new JSONObject();
ev.put("b", QUESTION);
ev.put("a", 42l);
checkJsonOutput(ev, JSONStreams.serialize(js));
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class JSONStreamsTest method testFlattenNoObjects.
@Test
public void testFlattenNoObjects() throws Exception {
final Topology t = new Topology();
final JSONObject value = new JSONObject();
final JSONArray array = new JSONArray();
array.add("hello");
value.put("greetings", array);
TStream<JSONObject> s = t.constants(Collections.singletonList(value));
TStream<JSONObject> jsonm = JSONStreams.flattenArray(s, "greetings");
TStream<String> output = JSONStreams.serialize(jsonm);
JSONObject payload = new JSONObject();
payload.put("payload", "hello");
completeAndValidate(output, 10, payload.toString());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class KafkaStreamsTest method testReusableApp.
@Test
public void testReusableApp() throws Exception {
// Threads per topic not supported in 4.2 onwards
skipVersion("kafka.threadsPerTopic", 4, 2);
checkAssumes();
Topology top = new Topology("testReusableApp");
MsgGenerator mgen = new MsgGenerator(top.getName());
String groupId = newGroupId(top.getName());
String topicVal = getKafkaTopics()[0];
Supplier<String> topic = top.createSubmissionParameter("kafka.topic", topicVal);
Supplier<Integer> threadsPerTopic = top.createSubmissionParameter("kafka.consumer.threadsPerTopic", 1);
KafkaProducer producer = new KafkaProducer(top, createProducerConfig());
KafkaConsumer consumer = new KafkaConsumer(top, createConsumerConfig(groupId));
// Test producer that takes an arbitrary TStream<T> and explicit topic
List<Vals> msgs = new ArrayList<>();
msgs.add(new Vals(mgen.create(topicVal, "Hello"), null, null));
msgs.add(new Vals(mgen.create(topicVal, "key1", "Are you there?"), "key1", null));
msgs.add(new Vals(mgen.create(topicVal, "Msg with an empty key"), "", null));
msgs.add(new Vals("", mgen.create(topicVal, null, "Msg with an empty msg (this is the key)"), null));
TStream<Vals> valsToPublish = top.constants(msgs).asType(Vals.class);
TStream<Message> msgsToPublish = valsToPublish.transform(msgFromValsFunc(null));
msgsToPublish = msgsToPublish.modify(new InitialDelay<Message>(PUB_DELAY_MSEC));
producer.publish(msgsToPublish, topic);
TStream<Message> rcvdMsgs = consumer.subscribe(threadsPerTopic, topic);
// for validation...
rcvdMsgs.print();
// just our msgs
rcvdMsgs = selectMsgs(rcvdMsgs, mgen.pattern());
TStream<String> rcvdAsString = rcvdMsgs.transform(msgToJSONStringFunc());
List<Message> expectedAsMessage = mapList(msgs, msgFromValsFunc(topicVal));
expectedAsMessage = modifyList(expectedAsMessage, adjustKey());
List<String> expectedAsString = mapList(expectedAsMessage, msgToJSONStringFunc());
setupDebug();
if (testBuildOnly(top))
return;
completeAndValidate(groupId, top, rcvdAsString, SEC_TIMEOUT, expectedAsString.toArray(new String[0]));
}
Aggregations