use of mockit.Verifications in project streamline by hortonworks.
the class RulesBoltConditionTest method testPassThrough.
@Test
public void testPassThrough() throws Exception {
doTest(readFile("/passthrough-rule.json"), getTuple(20));
new Verifications() {
{
String streamId;
Tuple anchor;
List<List<Object>> tuples = new ArrayList<>();
mockCollector.emit(streamId = withCapture(), anchor = withCapture(), withCapture(tuples));
System.out.println(streamId);
System.out.println(anchor);
System.out.println(tuples);
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class EventCorrelatingSpoutOutputCollectorTest method emitDirect.
@Test
public void emitDirect() throws Exception {
setupExpectationsForTopologyContextEmit();
setupExpectationsForEventCorrelationInjector();
sut = new EventCorrelatingSpoutOutputCollector(mockedTopologyContext, mockedOutputCollector);
Deencapsulation.setField(sut, "eventCorrelationInjector", mockEventCorrelationInjector);
String testStreamId = "testStreamId";
final Values tuple = new Values(INPUT_STREAMLINE_EVENT);
String messageId = "testMessageId";
// int taskId, String streamId, List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emitDirect(TASK_1, testStreamId, withAny(tuple));
}
};
sut.emitDirect(TASK_1, testStreamId, tuple);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(TASK_1, testStreamId, capturedValues = withCapture());
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(0, capturedParents.size());
}
};
// int taskId, List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emitDirect(TASK_1, withAny(tuple));
}
};
sut.emitDirect(TASK_1, tuple);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(TASK_1, capturedValues = withCapture());
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(0, capturedParents.size());
}
};
// int taskId, String streamId, List<Object> tuple, Object messageId
new Expectations() {
{
mockedOutputCollector.emitDirect(TASK_1, testStreamId, withAny(tuple), messageId);
}
};
sut.emitDirect(TASK_1, testStreamId, tuple, messageId);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(TASK_1, testStreamId, capturedValues = withCapture(), messageId);
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(0, capturedParents.size());
}
};
// int taskId, List<Object> tuple, Object messageId
new Expectations() {
{
mockedOutputCollector.emitDirect(TASK_1, withAny(tuple), messageId);
}
};
sut.emitDirect(TASK_1, tuple, messageId);
new Verifications() {
{
List<Object> capturedValues;
mockedOutputCollector.emitDirect(TASK_1, capturedValues = withCapture(), messageId);
StreamlineEventTestUtil.assertEventIsProperlyCopied((StreamlineEvent) capturedValues.get(0), INPUT_STREAMLINE_EVENT);
List<Tuple> capturedParents;
mockEventCorrelationInjector.injectCorrelationInformation(tuple, capturedParents = withCapture(), TEST_COMPONENT_NAME_FOR_STORM);
assertEquals(0, capturedParents.size());
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class HBaseBundleHintProviderTest method testGetHintsOnCluster.
// FIXME: below hint needs to access HBase and currently it doesn't work with secure cluster
// FIXME: hence can't add HBase sink to the topology
// FIXME: so we should mark this test to ignore until it is fixed
@Ignore
@Test
public void testGetHintsOnCluster() throws Exception {
List<String> tables = Lists.newArrayList("test1", "test2", "test3");
new Expectations() {
{
hbaseMetadataService.getHBaseTables();
result = new Tables(tables);
}
};
Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setName("cluster1");
Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
Assert.assertNotNull(hints);
Assert.assertEquals(1, hints.size());
Assert.assertEquals(tables, hints.get(HBaseBundleHintProvider.FIELD_NAME_TABLE));
new Verifications() {
{
hbaseMetadataService.getHBaseTables();
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationReceiverTest method receiveAsync.
// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_012: [ The function shall create an async wrapper around the receive() function call using the default timeout ]
@Test
public void receiveAsync() throws Exception {
// Arrange
final String hostName = "xxx";
final String userName = "xxx";
final String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol, mockedProxyOptions, mockedSslContext);
// Act
CompletableFuture<FileUploadNotification> completableFuture = fileUploadNotificationReceiver.receiveAsync();
completableFuture.get();
// Assert
new Verifications() {
{
amqpFileUploadNotificationReceive.receive(Deencapsulation.getField(fileUploadNotificationReceiver, "DEFAULT_TIMEOUT_MS"));
times = 1;
fileUploadNotificationReceiver.receive();
times = 1;
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationReceiverTest method receiveWithTimeoutAsync.
// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_013: [ The function shall create an async wrapper around the receive(long timeoutMs) function call ]
@Test
public void receiveWithTimeoutAsync() throws Exception {
// Arrange
long timeoutMs = 1000;
final String hostName = "xxx";
final String userName = "xxx";
final String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol, mockedProxyOptions, mockedSslContext);
// Act
CompletableFuture<FileUploadNotification> completableFuture = fileUploadNotificationReceiver.receiveAsync(timeoutMs);
completableFuture.get();
// Assert
new Verifications() {
{
amqpFileUploadNotificationReceive.receive(timeoutMs);
times = 1;
fileUploadNotificationReceiver.receive(anyLong);
times = 1;
}
};
}
Aggregations