本文整理了Java中org.apache.edgent.topology.Topology.strings()
方法的一些代码示例,展示了Topology.strings()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Topology.strings()
方法的具体详情如下:
包路径:org.apache.edgent.topology.Topology
类名称:Topology
方法名:strings
[英]Declare a stream of strings.
[中]
代码示例来源:origin: org.apache.edgent/edgent-test-appservice-applications
@Override
public BiConsumer<Topology, JsonObject> getBuilder() {
return (t,c) -> t.strings(getName()).print();
}
}
代码示例来源:origin: apache/incubator-edgent
@Override
public BiConsumer<Topology, JsonObject> getBuilder() {
return (t,c) -> t.strings(getName()).print();
}
}
代码示例来源:origin: apache/incubator-edgent
public static void createApplicationOne(Topology topology, JsonObject config) {
TStream<String> out = topology.strings("APP1_A", "APP1_B", "APP1_C");
PublishSubscribe.publish(out, "appOne", String.class);
}
}
代码示例来源:origin: apache/incubator-edgent
public static TStream<JsonObject> sourceData(Topology topology)
{
TStream<String> seed = topology.strings("A1", "B7", "C4", "A4", "B3", "C99", "A102", "B43", "B13", "A0", "C700");
return seed.map(s -> {
JsonObject j = new JsonObject();
j.addProperty("id", s.substring(0, 1));
j.addProperty("value", Integer.valueOf(s.substring(1)));
return j;
});
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void jobName1() throws Exception {
String[] data = new String[] {};
String topologyName = "topoName";
Topology t = newTopology(topologyName);
t.strings(data);
JsonObject config = new JsonObject();
config.addProperty(Configs.JOB_NAME, (String)null);
Job job = awaitCompleteExecution(t, config);
assertTrue(job.getName().startsWith(topologyName));
}
代码示例来源:origin: apache/incubator-edgent
/**
* Test split() zero outputs
* @throws Exception on failure
*/
@Test(expected = IllegalArgumentException.class)
public void testSplitWithZeroOutputs() throws Exception {
newTopology().strings("a1").split(0, tuple -> 0);
}
代码示例来源:origin: apache/incubator-edgent
/**
* Test split() negative outputs
* @throws Exception on failure
*/
@Test(expected = IllegalArgumentException.class)
public void testSplitWithNegativeOutputs() throws Exception {
newTopology().strings("a1").split(-28, tuple -> 0);
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void jobName2() throws Exception {
String[] data = new String[] {};
String jobName = "testJob";
Topology t = newTopology();
t.strings(data);
JsonObject config = new JsonObject();
config.addProperty(Configs.JOB_NAME, jobName);
Job job = awaitCompleteExecution(t, config);
assertEquals(jobName, job.getName());
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void jobName0() throws Exception {
String[] data = new String[] {};
String topologyName = "topoName";
Topology t = newTopology(topologyName);
t.strings(data);
Job job = awaitCompleteExecution(t);
assertTrue(job.getName().startsWith(topologyName));
}
代码示例来源:origin: apache/incubator-edgent
@Test(expected=IllegalArgumentException.class)
public void testRegisterEmptyTopologyName() {
DirectProvider direct = new DirectProvider();
ApplicationService appService = AppService.createAndRegister(direct, direct);
appService.registerTopology("", (t,c) -> t.strings("a"));
}
代码示例来源:origin: apache/incubator-edgent
/**
* Test split(enum) with integer type enum.
* @throws Exception on failure
*/
@Test(expected = IllegalArgumentException.class)
public void testSplitWithEnumForZeroSizeClass() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("Test");
s.split(EnumClassWithZerosize.class, e -> EnumClassWithZerosize.valueOf("Test"));
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void tesFlattMapWithNullIterator() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("mary had a little lamb", "NOTUPLES",
"its fleece was white as snow");
TStream<String> w = s.flatMap(tuple->tuple.equals("NOTUPLES") ? null : Arrays.asList(tuple.split(" ")));
assertStream(t, w);
Condition<List<String>> contents = t.getTester().streamContents(w, "mary", "had",
"a", "little", "lamb", "its", "fleece", "was", "white", "as",
"snow");
complete(t, contents);
assertTrue(contents.getResult().toString(), contents.valid());
}
代码示例来源:origin: apache/incubator-edgent
@Test(expected=IllegalArgumentException.class)
public void testRegisterNullTopologyName() {
DirectProvider direct = new DirectProvider();
ApplicationService appService = AppService.createAndRegister(direct, direct);
appService.registerTopology(null, (t,c) -> t.strings("a"));
}
代码示例来源:origin: apache/incubator-edgent
@Test(expected = IllegalStateException.class)
public void testTooManySendersNeg() {
Topology t = newTopology("testTooManySendersNeg");
TStream<String> s1 = t.strings(getStr1(), getStr2());
TStream<String> s2 = t.strings(getStr1(), getStr2());
Properties config = getConfig();
WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
wsClient.sendString(s1);
wsClient.sendString(s2); // should throw
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testNoStringContants() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings();
Condition<Long> tc = t.getTester().tupleCount(s, 0);
complete(t, tc);
assertTrue(tc.valid());
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testFilter() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("a", "b", "c");
s = s.filter(tuple -> "b".equals(tuple));
assertStream(t, s);
Condition<Long> tc = t.getTester().tupleCount(s, 1);
Condition<List<String>> contents = t.getTester().streamContents(s, "b");
complete(t, tc);
assertTrue(contents.valid());
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testModify() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("a", "b", "c");
TStream<String> i = s.modify(tuple -> tuple.concat("M"));
assertStream(t, i);
Condition<Long> tc = t.getTester().tupleCount(i, 3);
Condition<List<String>> contents = t.getTester().streamContents(i, "aM", "bM", "cM");
complete(t, tc);
assertTrue(contents.valid());
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testMap() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("32", "423", "-746");
TStream<Integer> i = s.map(Integer::valueOf);
assertStream(t, i);
Condition<Long> tc = t.getTester().tupleCount(i, 3);
Condition<List<Integer>> contents = t.getTester().streamContents(i, 32, 423, -746);
complete(t, tc);
assertTrue(contents.getResult().toString(), contents.valid());
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testModifyWithDrops() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("32", "423", "-746");
TStream<Integer> i = s.map(Integer::valueOf);
i = i.modify(tuple -> tuple < 0 ? null : tuple + 27);
assertStream(t, i);
Condition<Long> tc = t.getTester().tupleCount(i, 2);
Condition<List<Integer>> contents = t.getTester().streamContents(i, 59, 450);
complete(t, tc);
assertTrue(contents.getResult().toString(), contents.valid());
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testStringContants() throws Exception {
Topology t = newTopology();
TStream<String> s = t.strings("a", "b", "c");
assertStream(t, s);
Condition<Long> tc = t.getTester().tupleCount(s, 3);
Condition<List<String>> contents = t.getTester().streamContents(s, "a", "b", "c");
complete(t, tc);
assertTrue(contents.valid());
}
内容来源于网络,如有侵权,请联系作者删除!