use of mockit.Verifications in project streamline by hortonworks.
the class EventCorrelatingOutputCollectorTest method testResetTimeout.
@Test
public void testResetTimeout() throws Exception {
setupExpectationsForTuple();
setupExpectationsForTopologyContextNoEmit();
EventCorrelatingOutputCollector sut = getSystemUnderTest();
Tuple anchor = new TupleImpl(mockedTopologyContext, new Values(PARENT_STREAMLINE_EVENT), TASK_0, Utils.DEFAULT_STREAM_ID);
sut.resetTimeout(anchor);
new Verifications() {
{
mockedOutputCollector.resetTimeout(anchor);
times = 1;
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class EventCorrelatingOutputCollectorTest method testFail.
@Test
public void testFail() throws Exception {
setupExpectationsForTuple();
setupExpectationsForTopologyContextNoEmit();
EventCorrelatingOutputCollector sut = getSystemUnderTest();
Tuple anchor = new TupleImpl(mockedTopologyContext, new Values(PARENT_STREAMLINE_EVENT), TASK_0, Utils.DEFAULT_STREAM_ID);
sut.fail(anchor);
new Verifications() {
{
mockedOutputCollector.fail(anchor);
times = 1;
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class EventCorrelatingOutputCollectorTest method emitDirectWithAnchor.
@Test
public void emitDirectWithAnchor() throws Exception {
setupExpectationsForTuple();
setupExpectationsForTopologyContextEmit();
setupExpectationsForEventCorrelationInjector();
EventCorrelatingOutputCollector sut = getSystemUnderTest();
StreamlineEvent parentEvent = eventCorrelationInjector.injectCorrelationInformation(PARENT_STREAMLINE_EVENT, Collections.emptyList(), TEST_COMPONENT_NAME_FOR_STORM);
Tuple anchor = new TupleImpl(mockedTopologyContext, new Values(parentEvent), TASK_0, Utils.DEFAULT_STREAM_ID);
int testTaskId = TASK_1;
String testStreamId = "testStreamId";
final List<Tuple> anchors = Collections.singletonList(anchor);
final Values tuple = new Values(INPUT_STREAMLINE_EVENT);
// int taskId, String streamId, Tuple anchor, List<Object> anchor
new Expectations() {
{
mockedOutputCollector.emitDirect(testTaskId, testStreamId, anchor, withAny(tuple));
}
};
sut.emitDirect(testTaskId, testStreamId, anchor, tuple);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(testTaskId, testStreamId, anchor, capturedValues = withCapture());
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockStormEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(1, capturedParents.size());
assertEquals(anchor, capturedParents.get(0));
}
};
// int taskId, Collection<Tuple> anchors, List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emitDirect(testTaskId, anchors, withAny(tuple));
}
};
sut.emitDirect(testTaskId, anchors, tuple);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(testTaskId, anchors, capturedValues = withCapture());
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockStormEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(1, capturedParents.size());
assertEquals(anchor, capturedParents.get(0));
}
};
// int taskId, Tuple anchor, List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emitDirect(testTaskId, anchor, withAny(tuple));
}
};
sut.emitDirect(testTaskId, anchor, tuple);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(testTaskId, anchor, capturedValues = withCapture());
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockStormEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(1, capturedParents.size());
assertEquals(anchor, capturedParents.get(0));
}
};
// int taskId, String streamId, Collection<Tuple> anchors, List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emitDirect(testTaskId, testStreamId, anchors, withAny(tuple));
}
};
sut.emitDirect(testTaskId, testStreamId, anchors, tuple);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(testTaskId, testStreamId, anchors, capturedValues = withCapture());
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockStormEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(1, capturedParents.size());
assertEquals(anchor, capturedParents.get(0));
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class StreamsShellBoltTest method testStreamsShellBoltTest.
@Test
public void testStreamsShellBoltTest() throws Exception {
setUpExpectations();
copyFiles(readFile("/splitsentence.py"), new File("/tmp/splitsentence.py"));
copyFiles(readFile("/streamline.py"), new File("/tmp/streamline.py"));
String command = "python splitsentence.py";
StreamsShellBolt streamsShellBolt = new StreamsShellBolt(command, 60000);
streamsShellBolt = streamsShellBolt.withOutputStreams(Arrays.asList("stream1"));
streamsShellBolt.prepare(new HashMap(), mockContext, mockCollector);
streamsShellBolt.execute(getNextTuple(1));
new Verifications() {
{
String streamId;
Tuple anchor;
List<List<Object>> tuples = new ArrayList<>();
mockCollector.emit(streamId = withCapture(), anchor = withCapture(), withCapture(tuples));
Assert.assertEquals("stream", streamId);
Assert.assertEquals(4, tuples.size());
Map<String, Object> fieldsAndValues = ((StreamlineEvent) tuples.get(0).get(0));
Assert.assertEquals("THIS", fieldsAndValues.get("word"));
fieldsAndValues = ((StreamlineEvent) tuples.get(1).get(0));
Assert.assertEquals("IS", fieldsAndValues.get("word"));
fieldsAndValues = ((StreamlineEvent) tuples.get(2).get(0));
Assert.assertEquals("RANDOM", fieldsAndValues.get("word"));
fieldsAndValues = ((StreamlineEvent) tuples.get(3).get(0));
Assert.assertEquals("SENTENCE1", fieldsAndValues.get("word"));
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testOverwriteExistingStreamingEngineMappingViaSetServicesToClusterInNamespace.
@Test
public void testOverwriteExistingStreamingEngineMappingViaSetServicesToClusterInNamespace() throws Exception {
Long testNamespaceId = 1L;
Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
new Expectations() {
{
environmentService.getNamespace(testNamespaceId);
result = testNamespace;
environmentService.listServiceClusterMapping(testNamespaceId);
result = existingMappings;
}
};
namespaceCatalogResource.setServicesToClusterInNamespace(testNamespaceId, new ArrayList<>(existingMappings), securityContext);
new Verifications() {
{
catalogService.listTopologies();
times = 0;
topologyActionsService.getRuntimeTopologyId(withAny(new Topology()), anyString);
times = 0;
environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
times = existingMappings.size();
environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
times = existingMappings.size();
}
};
}
Aggregations