@Test public void listenerIsNotifiedAboutSuiteStartEvent() 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 = new HashMap<>(); attributes.put("source", "/a/b/suite.robot"); attributes.put("is_dir", false); attributes.put("suites", newArrayList("s1", "s2")); attributes.put("tests", newArrayList("t1", "t2")); attributes.put("child_paths", new ArrayList<>()); attributes.put("totaltests", 7); attributes.put("vars_scopes", newArrayList(ImmutableMap.of("a", newArrayList("t", 1, "global"), "b", newArrayList("t", 2, "local")))); final String json = toJson(ImmutableMap.of("start_suite", newArrayList("suite", attributes))); dispatcher.runEventsLoop(readerFor(json)); verify(listener).eventsProcessingAboutToStart(); verify(listener, atLeast(1)).isHandlingEvents(); verify(listener).handleSuiteStarted(new SuiteStartedEvent("suite", new URI("file: ExecutionMode.TESTS, 7, newArrayList("s1", "s2"), newArrayList("t1", "t2"), newArrayList(Optional.<URI> empty(), Optional.<URI> empty()))); 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);   }