@Test
public void test_technicalCountLimit() {

    // set technicalLimit
    ReflectionTestUtils.setField(messagesProcessingService, "messagesTechnicalLimit", new FixedConfigurationItem<>(2L));
    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;
        }
    });
    messagesProcessingService.processMessages();
    // verify only two of the three eligible messages were processed, as technical limit is reached
    verify(finalMessageProcessor, times(2)).processMessage(any(Message.class));
}