@Test
public void addMessage() {

    String messageId = "some-message-id";
    Message message = new Message();
    message.setId(messageId);
    message.setPayload("some-payload");
    message.setReceipt("some-receipt");
    indexDAO.addMessage("some-queue", message);
    await()
            .atMost(5, TimeUnit.SECONDS)
            .untilAsserted(() -> {
                SearchResponse searchResponse = searchObjectIdsViaExpression(
                        LOG_INDEX_PREFIX + "*",
                        "messageId='" + messageId + "'",
                        0,
                        10000,
                        null,
                        "*",
                        MSG_DOC_TYPE
                );
                assertTrue("should return 1 or more search results", searchResponse.getHits().getTotalHits() > 0);
                SearchHit searchHit = searchResponse.getHits().getAt(0);
                String resourcePath =
                        String.format("/%s/%s/%s", searchHit.getIndex(), MSG_DOC_TYPE, searchHit.getId());
                Response response = restClient.performRequest(HttpMethod.GET, resourcePath);
                String responseBody = IOUtils.toString(response.getEntity().getContent());
                logger.info("responseBody: {}", responseBody);
                TypeReference<HashMap<String, Object>> typeRef =
                        new TypeReference<HashMap<String, Object>>() {};
                Map<String, Object> responseMap = objectMapper.readValue(responseBody, typeRef);
                Map<String, Object> source = (Map<String, Object>) responseMap.get("_source");
                assertEquals("indexed message id should match", messageId, source.get("messageId"));
                assertEquals("indexed payload should match", "some-payload", source.get("payload"));
            });
    List<Message> messages = indexDAO.getMessages("some-queue");
    assertEquals(1, messages.size());
    assertEquals(message.getId(), messages.get(0).getId());
    assertEquals(message.getPayload(), messages.get(0).getPayload());
}