use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method createTestRunSource.
private TestRunSource createTestRunSource(StreamlineSource originSource) {
Map<String, List<Map<String, Object>>> testRecordsMap = new HashMap<>();
for (Stream stream : originSource.getOutputStreams()) {
testRecordsMap.put(stream.getId(), TopologyTestHelper.createTestRecords());
}
TestRunSource testRunSource = new TestRunSource(originSource.getOutputStreams(), testRecordsMap, 1, 0L, "");
testRunSource.setName(originSource.getName());
return testRunSource;
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitProcessor_connectedFromSource.
@Test
public void visitProcessor_connectedFromSource() throws Exception {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
StreamlineProcessor originProcessor = TopologyTestHelper.createStreamlineProcessor("2");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originSource);
originTopologyDag.add(originProcessor);
originTopologyDag.addEdge(new Edge("e1", originSource, originProcessor, "default", Stream.Grouping.SHUFFLE));
TestRunSource testSource = createTestRunSource(originSource);
TestRunProcessor testProcessor = createTestRunProcessor(originProcessor);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.singletonMap(originProcessor.getName(), testProcessor), Collections.emptyMap(), Collections.emptyMap());
visitor.visit(originSource);
visitor.visit(originProcessor);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testProcessors = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunProcessor && o.getName().equals(originProcessor.getName()))).collect(toList());
List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
TestRunProcessor testRunProcessor = (TestRunProcessor) testProcessors.get(0);
TestRunSource testRunSource = (TestRunSource) testSources.get(0);
assertEquals(1, testTopologyDag.getEdgesFrom(testRunSource).size());
assertEquals(1, testTopologyDag.getEdgesTo(testRunProcessor).size());
assertTrue(testTopologyDag.getEdgesFrom(testRunSource).get(0) == testTopologyDag.getEdgesTo(testRunProcessor).get(0));
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitSource.
@Test
public void visitSource() throws Exception {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originSource);
TestRunSource testSource = createTestRunSource(originSource);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
visitor.visit(originSource);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
assertEquals(1, testSources.size());
TestRunSource testRunSource = (TestRunSource) testSources.get(0);
assertEquals(originSource.getId(), testRunSource.getId());
assertEquals(testSource.getTestRecordsForEachStream(), testRunSource.getTestRecordsForEachStream());
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitRulesProcessor_connectedFromSource.
@Test
public void visitRulesProcessor_connectedFromSource() throws Exception {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
RulesProcessor rulesProcessor = TopologyTestHelper.createRulesProcessor("2");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originSource);
originTopologyDag.add(rulesProcessor);
originTopologyDag.addEdge(new Edge("e1", originSource, rulesProcessor, "default", Stream.Grouping.SHUFFLE));
TestRunSource testSource = createTestRunSource(originSource);
TestRunRulesProcessor testRulesProcessor = createTestRunRulesProcessor(rulesProcessor);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.emptyMap(), Collections.singletonMap(rulesProcessor.getName(), testRulesProcessor), Collections.emptyMap());
visitor.visit(originSource);
visitor.visit(rulesProcessor);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testRulesProcessors = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunRulesProcessor && o.getName().equals(rulesProcessor.getName()))).collect(toList());
List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
TestRunRulesProcessor testRunRulesProcessor = (TestRunRulesProcessor) testRulesProcessors.get(0);
TestRunSource testRunSource = (TestRunSource) testSources.get(0);
assertEquals(1, testTopologyDag.getEdgesFrom(testRunSource).size());
assertEquals(1, testTopologyDag.getEdgesTo(testRunRulesProcessor).size());
assertTrue(testTopologyDag.getEdgesFrom(testRunSource).get(0) == testTopologyDag.getEdgesTo(testRunRulesProcessor).get(0));
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitSink_connectedFromSource.
@Test
public void visitSink_connectedFromSource() throws Exception {
StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
StreamlineSink originSink = TopologyTestHelper.createStreamlineSink("2");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originSource);
originTopologyDag.add(originSink);
originTopologyDag.addEdge(new Edge("e1", originSource, originSink, "default", Stream.Grouping.SHUFFLE));
TestRunSource testSource = createTestRunSource(originSource);
TestRunSink testSink = createTestRunSink(originSink);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.emptyMap(), Collections.emptyMap(), Collections.singletonMap(originSink.getName(), testSink));
visitor.visit(originSource);
visitor.visit(originSink);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
List<InputComponent> testSinks = testTopologyDag.getInputComponents().stream().filter(o -> (o instanceof TestRunSink && o.getName().equals(originSink.getName()))).collect(toList());
assertEquals(1, testSinks.size());
TestRunSource testRunSource = (TestRunSource) testSources.get(0);
TestRunSink testRunSink = (TestRunSink) testSinks.get(0);
assertEquals(originSink.getId(), testRunSink.getId());
assertEquals(testSink.getOutputFilePath(), testRunSink.getOutputFilePath());
assertEquals(1, testTopologyDag.getEdgesFrom(testRunSource).size());
assertEquals(1, testTopologyDag.getEdgesTo(testRunSink).size());
assertTrue(testTopologyDag.getEdgesFrom(testRunSource).get(0) == testTopologyDag.getEdgesTo(testRunSink).get(0));
}
Aggregations