@Test public void listenerIsNotifiedAboutTestStartEvent() throws Exception { final RobotAgentEventListener listener = mock(RobotAgentEventListener.class); when(listener.isHandlingEvents()).thenReturn(true); final RobotAgentEventDispatcher dispatcher = new RobotAgentEventDispatcher(null, listener); final Map<String, Object> attributes = ImmutableMap.of("longname", "suite-a-b-test", "vars_scopes", newArrayList(ImmutableMap.of("a", newArrayList("t", 1, "test"), "b", newArrayList("t", 2, "local"))), "template", ""); final String json = toJson(ImmutableMap.of("start_test", newArrayList("test", attributes))); dispatcher.runEventsLoop(readerFor(json)); verify(listener).eventsProcessingAboutToStart(); verify(listener, atLeast(1)).isHandlingEvents(); verify(listener).handleTestStarted(new TestStartedEvent("test", "test", "suite-a-b-test", "")); verify(listener).eventsProcessingFinished(); verifyNoMoreInteractions(listener); }
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);   }