@Test
public void testRepairProcessingMessagesMany() throws Exception {

    List<Message> messages = new LinkedList<>();
    messages.addAll(Arrays.asList(createAndSaveMessages(70, MsgStateEnum.PROCESSING)));
    messages.addAll(Arrays.asList(createAndSaveMessages(30, MsgStateEnum.NEW)));
    messages.addAll(Arrays.asList(createAndSaveMessages(28, MsgStateEnum.IN_QUEUE)));
    // 3 times because MAX_MESSAGES_IN_ONE_QUERY=50
    messageService.repairProcessingMessages();
    messageService.repairProcessingMessages();
    messageService.repairProcessingMessages();
    for (Message message : messages) {
        LOG.info("Verifying message {}", message);
        Message found = messageDao.findMessage(message.getMsgId());
        assertThat(found, notNullValue());
        assertThat(found.getState(), is(MsgStateEnum.PARTLY_FAILED));
    }
}