Search in sources :

Example 81 with Verifications

use of mockit.Verifications in project streamline by hortonworks.

the class EventLoggingSpoutOutputCollectorTest method emitDirect.

@Test
public void emitDirect() throws Exception {
    setupExpectationsForTopologyContextEmitDirect();
    sut = new EventLoggingSpoutOutputCollector(mockedTopologyContext, mockedOutputCollector, mockedEventLogger);
    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, tuple);
        }
    };
    sut.emitDirect(TASK_1, testStreamId, tuple);
    new Verifications() {

        {
            mockedOutputCollector.emitDirect(TASK_1, testStreamId, tuple);
        }
    };
    verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, Collections.singleton(TEST_TARGET_COMPONENT_FOR_TASK_1));
    // int taskId, List<Object> tuple
    new Expectations() {

        {
            mockedOutputCollector.emitDirect(TASK_1, tuple);
        }
    };
    sut.emitDirect(TASK_1, tuple);
    new Verifications() {

        {
            mockedOutputCollector.emitDirect(TASK_1, tuple);
        }
    };
    verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, Collections.singleton(TEST_TARGET_COMPONENT_FOR_TASK_1));
    // int taskId, String streamId, List<Object> tuple, Object messageId
    new Expectations() {

        {
            mockedOutputCollector.emitDirect(TASK_1, testStreamId, tuple, messageId);
        }
    };
    sut.emitDirect(TASK_1, testStreamId, tuple, messageId);
    new Verifications() {

        {
            mockedOutputCollector.emitDirect(TASK_1, testStreamId, tuple, messageId);
        }
    };
    verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, Collections.singleton(TEST_TARGET_COMPONENT_FOR_TASK_1));
    // int taskId, List<Object> tuple, Object messageId
    new Expectations() {

        {
            mockedOutputCollector.emitDirect(TASK_1, tuple, messageId);
        }
    };
    sut.emitDirect(TASK_1, tuple, messageId);
    new Verifications() {

        {
            mockedOutputCollector.emitDirect(TASK_1, tuple, messageId);
        }
    };
    verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, Collections.singleton(TEST_TARGET_COMPONENT_FOR_TASK_1));
}
Also used : Expectations(mockit.Expectations) Values(org.apache.storm.tuple.Values) Verifications(mockit.Verifications) Test(org.junit.Test)

Example 82 with Verifications

use of mockit.Verifications in project streamline by hortonworks.

the class RulesBoltConditionTest method testSimpleCondition.

@Test
public void testSimpleCondition() throws Exception {
    doTest(readFile("/simple-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);
        }
    };
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Verifications(mockit.Verifications) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Example 83 with Verifications

use of mockit.Verifications in project streamline by hortonworks.

the class RulesBoltConditionTest method testSimpleConditionNoMatch.

@Test
public void testSimpleConditionNoMatch() throws Exception {
    doTest(readFile("/simple-rule.json"), getTuple(5));
    new Verifications() {

        {
            String streamId;
            Tuple anchor;
            List<List<Object>> tuples = new ArrayList<>();
            mockCollector.emit(streamId = withCapture(), anchor = withCapture(), withCapture(tuples));
            times = 0;
        }
    };
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Verifications(mockit.Verifications) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Example 84 with Verifications

use of mockit.Verifications in project streamline by hortonworks.

the class RulesBoltConditionTest method testComplex1.

// select temperature, humidity, city from inputstream where temperature + humidity > 100 OR TRIM(city) = 'SFO'
// city = SFO, temperature = 0, humidity = 0
@Test
public void testComplex1() throws Exception {
    doTest(readFile("/streamline-complex-condition.json"), getWeather("SFO", 0, 0));
    new Verifications() {

        {
            String streamId;
            Tuple anchor;
            List<List<Object>> tuples = new ArrayList<>();
            mockCollector.emit(streamId = withCapture(), anchor = withCapture(), withCapture(tuples));
            Assert.assertEquals("outputstream", streamId);
            Assert.assertEquals("CITY SFO TEMPERATURE 0 HUMIDITY 0", ((StreamlineEvent) tuples.get(0).get(0)).get("body"));
        }
    };
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Verifications(mockit.Verifications) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Example 85 with Verifications

use of mockit.Verifications in project streamline by hortonworks.

the class RulesBoltConditionTest method testSimpleRuleStringLiteral.

@Test
public void testSimpleRuleStringLiteral() throws Exception {
    StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(ImmutableMap.<String, Object>of("foo", "Normal", "bar", "abc", "baz", 200)).dataSourceId("dsrcid").build();
    Tuple tuple = new TupleImpl(mockContext, new Values(event), 1, "inputstream");
    doTest(readFile("/simple-rule-string-literal.json"), tuple);
    new Verifications() {

        {
            String streamId;
            Tuple anchor;
            List<List<Object>> tuples = new ArrayList<>();
            mockCollector.emit(streamId = withCapture(), anchor = withCapture(), withCapture(tuples));
            times = 0;
        }
    };
}
Also used : StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) Values(org.apache.storm.tuple.Values) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Verifications(mockit.Verifications) TupleImpl(org.apache.storm.tuple.TupleImpl) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Aggregations

Verifications (mockit.Verifications)329 Test (org.junit.Test)326 NonStrictExpectations (mockit.NonStrictExpectations)163 Expectations (mockit.Expectations)52 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)34 Tuple (org.apache.storm.tuple.Tuple)28 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)24 AmqpResponseVerification (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification)22 HttpConnection (com.microsoft.azure.sdk.iot.service.transport.http.HttpConnection)21 HttpMethod (com.microsoft.azure.sdk.iot.service.transport.http.HttpMethod)21 ArrayList (java.util.ArrayList)21 List (java.util.List)21 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)20 FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)18 MqttDeviceMethod (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod)17 HashMap (java.util.HashMap)16 MqttIotHubConnection (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection)14 IOException (java.io.IOException)14 Values (org.apache.storm.tuple.Values)14 SaslListenerImpl (com.microsoft.azure.sdk.iot.deps.transport.amqp.SaslListenerImpl)13