use of org.graylog.storage.elasticsearch6.MessagesAdapterES6.INDEX_BLOCK_REASON in project graylog2-server by Graylog2.
the class MessagesAdapterES6Test method parsesErrorTypesAndReturnsIndexingErrors.
@Test
public void parsesErrorTypesAndReturnsIndexingErrors() throws IOException {
final BulkResult errorResult = mock(BulkResult.class);
final BulkResult.BulkResultItem indexBlockedError = errorResultItem("blocked-id", INDEX_BLOCK_ERROR, INDEX_BLOCK_REASON);
final BulkResult.BulkResultItem otherError = errorResultItem("other-error-id", "something else", "something else");
when(errorResult.getFailedItems()).thenReturn(ImmutableList.of(indexBlockedError, otherError));
when(jestClient.execute(any())).thenReturn(errorResult);
final List<Messages.IndexingError> result = messagesAdapter.bulkIndex(messagesWithIds("blocked-id", "other-error-id"));
verify(jestClient, times(1)).execute(any());
assertThat(result).extracting(indexingError -> indexingError.message().getId(), Messages.IndexingError::errorType, Messages.IndexingError::errorMessage).containsExactlyInAnyOrder(tuple("blocked-id", Messages.IndexingError.ErrorType.IndexBlocked, INDEX_BLOCK_REASON), tuple("other-error-id", Messages.IndexingError.ErrorType.Unknown, "something else"));
}
Aggregations