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));
}
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);
}
};
}
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;
}
};
}
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"));
}
};
}
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;
}
};
}
Aggregations