@Test public void exceptionIsRethrown_whenReaderThrowsIOException() throws Exception { final RobotAgentEventDispatcher dispatcher = new RobotAgentEventDispatcher(null); final BufferedReader reader = mock(BufferedReader.class); when(reader.readLine()).thenThrow(IOException.class); assertThatIOException().isThrownBy(() -> dispatcher.runEventsLoop(reader)); }
void runEventsLoop(final BufferedReader eventReader) throws IOException, RobotAgentEventsListenerException { try { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingAboutToStart(); } eventsLoop(eventReader); } finally { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingFinished(); } } }
RobotAgentEventDispatcher { void runEventsLoop(final BufferedReader eventReader) throws IOException, RobotAgentEventsListenerException { try { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingAboutToStart(); } eventsLoop(eventReader); } finally { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingFinished(); } } } }
RobotAgentEventDispatcher { void runEventsLoop(final BufferedReader eventReader) throws IOException, RobotAgentEventsListenerException { try { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingAboutToStart(); } eventsLoop(eventReader); } finally { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingFinished(); } } } RobotAgentEventDispatcher(final AgentClient client, final RobotAgentEventListener... eventsListeners); }
RobotAgentEventDispatcher { void runEventsLoop(final BufferedReader eventReader) throws IOException, RobotAgentEventsListenerException { try { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingAboutToStart(); } eventsLoop(eventReader); } finally { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingFinished(); } } } RobotAgentEventDispatcher(final AgentClient client, final RobotAgentEventListener... eventsListeners);  }
RobotAgentEventDispatcher { void runEventsLoop(final BufferedReader eventReader) throws IOException, RobotAgentEventsListenerException { try { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingAboutToStart(); } eventsLoop(eventReader); } finally { for (final RobotAgentEventListener listener : eventsListeners) { listener.eventsProcessingFinished(); } } } RobotAgentEventDispatcher(final AgentClient client, final RobotAgentEventListener... eventsListeners);   }