@Test public void shouldPrintMessagesInCorrectOrder() throws Exception { List<LogMessage> shuffledMessages = new ArrayList<>(orderedMessages); Collections.shuffle(shuffledMessages); for (LogMessage logMessage : shuffledMessages) { logMessagesHandler.onMessageReceived(logMessage); } InOrder inOrder = inOrder(builderConsolePresenter); for (LogMessage logMessage : orderedMessages) { inOrder.verify(builderConsolePresenter, times(1)).print(logMessage.text); } }
@Override protected void onMessageReceived(LogMessage result) { if (result.num == lastPrintedMessageNum + 1) { flushTimer.cancel(); printLine(result); } else if (result.num > lastPrintedMessageNum) { postponedMessages.put(result.num, result); } printNextPostponedMessages(); flushTimer.schedule(5000); }
LogMessagesHandler extends SubscriptionHandler<LogMessage> { @Override protected void onMessageReceived(LogMessage result) { if (result.num == lastPrintedMessageNum + 1) { flushTimer.cancel(); printLine(result); } else if (result.num > lastPrintedMessageNum) { postponedMessages.put(result.num, result); } printNextPostponedMessages(); flushTimer.schedule(5000); } }
LogMessagesHandler extends SubscriptionHandler<LogMessage> { @Override protected void onMessageReceived(LogMessage result) { if (result.num == lastPrintedMessageNum + 1) { flushTimer.cancel(); printLine(result); } else if (result.num > lastPrintedMessageNum) { postponedMessages.put(result.num, result); } printNextPostponedMessages(); flushTimer.schedule(5000); } LogMessagesHandler(BuildTaskDescriptor buildTaskDescriptor, BuilderConsolePresenter console, MessageBus messageBus); }
LogMessagesHandler extends SubscriptionHandler<LogMessage> { @Override protected void onMessageReceived(LogMessage result) { if (result.num == lastPrintedMessageNum + 1) { flushTimer.cancel(); printLine(result); } else if (result.num > lastPrintedMessageNum) { postponedMessages.put(result.num, result); } printNextPostponedMessages(); flushTimer.schedule(5000); } LogMessagesHandler(BuildTaskDescriptor buildTaskDescriptor, BuilderConsolePresenter console, MessageBus messageBus);  }
LogMessagesHandler extends SubscriptionHandler<LogMessage> { @Override protected void onMessageReceived(LogMessage result) { if (result.num == lastPrintedMessageNum + 1) { flushTimer.cancel(); printLine(result); } else if (result.num > lastPrintedMessageNum) { postponedMessages.put(result.num, result); } printNextPostponedMessages(); flushTimer.schedule(5000); } LogMessagesHandler(BuildTaskDescriptor buildTaskDescriptor, BuilderConsolePresenter console, MessageBus messageBus);   }