use of org.apache.metron.test.error.MetronErrorJSONMatcher in project metron by apache.
the class JoinBoltTest method testExecuteShouldReportError.
@SuppressWarnings("unchecked")
@Test
public void testExecuteShouldReportError() throws ExecutionException {
joinBolt.withMaxCacheSize(100);
joinBolt.withMaxTimeRetain(10000);
joinBolt.prepare(new HashMap(), topologyContext, outputCollector);
when(tuple.getValueByField("key")).thenReturn(key);
when(tuple.getValueByField("message")).thenReturn(new JSONObject());
joinBolt.cache = mock(LoadingCache.class);
when(joinBolt.cache.get(any())).thenThrow(new RuntimeException(new Exception("join exception")));
joinBolt.execute(tuple);
RuntimeException expectedExecutionException = new RuntimeException(new Exception("join exception"));
MetronError error = new MetronError().withErrorType(Constants.ErrorType.ENRICHMENT_ERROR).withMessage("Joining problem: {}").withThrowable(expectedExecutionException).addRawMessage(new JSONObject());
verify(outputCollector, times(1)).emit(eq(Constants.ERROR_STREAM), argThat(new MetronErrorJSONMatcher(error.getJSONObject())));
verify(outputCollector, times(1)).reportError(any(ExecutionException.class));
verify(outputCollector, times(1)).ack(eq(tuple));
verifyNoMoreInteractions(outputCollector);
}
Aggregations