@Test
public void test_errorsAreSkipped() {

    createAndSaveMessages(3, (message, order) -> {
        switch (order) {
            case 1:
                message.setState(MsgStateEnum.OK);
                message.setLastUpdateTimestamp(Instant.now().minusSeconds(okSaveTimeInSec + 1));
                break;
            case 2:
                message.setState(MsgStateEnum.OK);
                message.setLastUpdateTimestamp(Instant.now().minusSeconds(okSaveTimeInSec + 1));
                break;
            case 3:
                message.setState(MsgStateEnum.OK);
                message.setLastUpdateTimestamp(Instant.now().minusSeconds(okSaveTimeInSec + 1));
                break;
        }
    });
    // processor will throw an exception
    doThrow(new RuntimeException("General exception")).when(finalMessageProcessor).processMessage(any(Message.class));
    messagesProcessingService.processMessages();
    // verify all messages were processed regardless
    verify(finalMessageProcessor, times(3)).processMessage(any(Message.class));
}