use of org.graylog2.indexer.messages.MessagesAdapter in project graylog2-server by Graylog2.
the class MessagesBulkIndexRetryingTest method bulkIndexingShouldNotRetryForIndexMappingErrors.
@Test
public void bulkIndexingShouldNotRetryForIndexMappingErrors() throws Exception {
final String messageId = "BOOMID";
final List<Messages.IndexingError> errorResult = ImmutableList.of(errorResultItem(messageId, Messages.IndexingError.ErrorType.MappingError, "failed to parse [http_response_code]"));
when(messagesAdapter.bulkIndex(any())).thenReturn(errorResult).thenThrow(new IllegalStateException("JestResult#execute should not be called twice."));
final Message mockedMessage = mock(Message.class);
when(mockedMessage.getId()).thenReturn(messageId);
when(mockedMessage.getTimestamp()).thenReturn(DateTime.now(DateTimeZone.UTC));
final List<Map.Entry<IndexSet, Message>> messageList = messageListWith(mockedMessage);
final List<String> result = messages.bulkIndex(messageList);
assertThat(result).hasSize(1);
verify(messagesAdapter, times(1)).bulkIndex(any());
}