use of org.graylog2.indexer.IndexFailureService in project graylog2-server by Graylog2.
the class DefaultFailureHandlerTest method handle_allFailuresHandedOverToIndexFailureService.
@Test
public void handle_allFailuresHandedOverToIndexFailureService() {
// given
final DateTime ts = DateTime.now(DateTimeZone.UTC);
final Indexable indexable1 = mock(Indexable.class);
when(indexable1.getId()).thenReturn("msg-1");
when(indexable1.getTimestamp()).thenReturn(ts);
final Indexable indexable2 = mock(Indexable.class);
when(indexable2.getId()).thenReturn("msg-2");
when(indexable2.getTimestamp()).thenReturn(ts);
final IndexingFailure indexingFailure1 = new IndexingFailure(IndexingFailureCause.MappingError, "indexingFailureMessage1", "indexingFailureDetails1", Tools.nowUTC(), indexable1, "index1");
final IndexingFailure indexingFailure2 = new IndexingFailure(IndexingFailureCause.MappingError, "indexingFailureMessage2", "indexingFailureDetails2", Tools.nowUTC(), indexable2, "index2");
final FailureBatch indexingFailureBatch = FailureBatch.indexingFailureBatch(ImmutableList.of(indexingFailure1, indexingFailure2));
// when
underTest.handle(indexingFailureBatch);
// then
verify(indexFailureService, times(2)).saveWithoutValidation(any());
verify(indexFailureService, times(1)).saveWithoutValidation(argThat(arg -> arg.asMap().get("letter_id").equals("msg-1") && arg.asMap().get("index").equals("index1") && arg.asMap().get("type").equals("indexing") && arg.asMap().get("message").equals("indexingFailureDetails1") && arg.asMap().get("timestamp") != null));
verify(indexFailureService, times(1)).saveWithoutValidation(argThat(arg -> arg.asMap().get("letter_id").equals("msg-2") && arg.asMap().get("index").equals("index2") && arg.asMap().get("type").equals("indexing") && arg.asMap().get("message").equals("indexingFailureDetails2") && arg.asMap().get("timestamp") != null));
}
Aggregations