use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method createTestRunProcessor.
private TestRunProcessor createTestRunProcessor(StreamlineProcessor originProcessor) {
TestRunProcessor testRunProcessor = new TestRunProcessor(originProcessor, false, "");
testRunProcessor.setName(originProcessor.getName());
return testRunProcessor;
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor 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.TestRunProcessor in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitor method visit.
@Override
public void visit(StreamlineProcessor processor) {
String id = processor.getId();
String processorName = processor.getName();
if (!testRunProcessorsForEachProcessor.containsKey(processorName)) {
throw new IllegalStateException("Not all processors have corresponding TestRunProcessor instance. processor name: " + processorName);
}
Config config = new Config(processor.getConfig());
TestRunProcessor testRunProcessor = testRunProcessorsForEachProcessor.get(processorName);
testRunProcessor.setId(id);
testRunProcessor.setName(processorName);
testRunProcessor.setConfig(config);
testRunProcessor.setTransformationClass(TestRunProcessorBoltFluxComponent.class.getName());
testTopologyDag.add(testRunProcessor);
processorToReplacedTestProcessorMap.put(processorName, testRunProcessor);
copyEdges(processor);
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitProcessor_connectedFromProcessor.
@Test
public void visitProcessor_connectedFromProcessor() throws Exception {
StreamlineProcessor originProcessor = TopologyTestHelper.createStreamlineProcessor("1");
StreamlineProcessor originProcessor2 = TopologyTestHelper.createStreamlineProcessor("2");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originProcessor);
originTopologyDag.add(originProcessor2);
originTopologyDag.addEdge(new Edge("e1", originProcessor, originProcessor2, "default", Stream.Grouping.SHUFFLE));
TestRunProcessor testProcessor = createTestRunProcessor(originProcessor);
TestRunProcessor testProcessor2 = createTestRunProcessor(originProcessor2);
Map<String, TestRunProcessor> processorMap = new HashMap<>();
processorMap.put(originProcessor.getName(), testProcessor);
processorMap.put(originProcessor2.getName(), testProcessor2);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.emptyMap(), processorMap, Collections.emptyMap(), Collections.emptyMap());
visitor.visit(originProcessor);
visitor.visit(originProcessor2);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testProcessors = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunProcessor)).collect(toList());
Optional<OutputComponent> testRunProcessorOptional = testProcessors.stream().filter(o -> o.getName().equals(originProcessor.getName())).findAny();
Optional<OutputComponent> testRunProcessor2Optional = testProcessors.stream().filter(o -> o.getName().equals(originProcessor2.getName())).findAny();
assertTrue(testRunProcessorOptional.isPresent());
assertTrue(testRunProcessor2Optional.isPresent());
TestRunProcessor testRunProcessor = (TestRunProcessor) testRunProcessorOptional.get();
TestRunProcessor testRunProcessor2 = (TestRunProcessor) testRunProcessor2Optional.get();
assertEquals(1, testTopologyDag.getEdgesFrom(testRunProcessor).size());
assertEquals(1, testTopologyDag.getEdgesTo(testRunProcessor2).size());
assertTrue(testTopologyDag.getEdgesFrom(testRunProcessor).get(0) == testTopologyDag.getEdgesTo(testRunProcessor2).get(0));
}
use of com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitSink_connectedFromProcessor.
@Test
public void visitSink_connectedFromProcessor() throws Exception {
StreamlineProcessor originProcessor = TopologyTestHelper.createStreamlineProcessor("1");
StreamlineSink originSink = TopologyTestHelper.createStreamlineSink("2");
TopologyDag originTopologyDag = new TopologyDag();
originTopologyDag.add(originProcessor);
originTopologyDag.add(originSink);
originTopologyDag.addEdge(new Edge("e1", originProcessor, originSink, "default", Stream.Grouping.SHUFFLE));
TestRunProcessor testProcessor = createTestRunProcessor(originProcessor);
TestRunSink testSink = createTestRunSink(originSink);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.emptyMap(), Collections.singletonMap(originProcessor.getName(), testProcessor), Collections.emptyMap(), Collections.singletonMap(originSink.getName(), testSink));
visitor.visit(originProcessor);
visitor.visit(originSink);
TopologyDag testTopologyDag = visitor.getTestTopologyDag();
List<OutputComponent> testProcessors = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunProcessor && o.getName().equals(originProcessor.getName()))).collect(toList());
List<InputComponent> testSinks = testTopologyDag.getInputComponents().stream().filter(o -> (o instanceof TestRunSink && o.getName().equals(originSink.getName()))).collect(toList());
assertEquals(1, testProcessors.size());
assertEquals(1, testSinks.size());
TestRunProcessor testRunProcessor = (TestRunProcessor) testProcessors.get(0);
assertEquals(originProcessor.getId(), testRunProcessor.getId());
TestRunSink testRunSink = (TestRunSink) testSinks.get(0);
assertEquals(originSink.getId(), testRunSink.getId());
assertEquals(testSink.getOutputFilePath(), testRunSink.getOutputFilePath());
assertEquals(1, testTopologyDag.getEdgesFrom(testProcessor).size());
assertEquals(1, testTopologyDag.getEdgesTo(testRunSink).size());
assertTrue(testTopologyDag.getEdgesFrom(testRunProcessor).get(0) == testTopologyDag.getEdgesTo(testRunSink).get(0));
}
Aggregations