Application { public void pushToClients(final Object message) { for (final UIContext uiContext : getUIContexts()) { log.debug("Pushing to {}", uiContext); try { uiContext.pushToClient(message); } catch (final Throwable throwable) { log.error("Cannot flush message on the session {}", uiContext, throwable); } } } Application(final String id, final HttpSession session, final ApplicationConfiguration configuration); void registerUIContext(final UIContext uiContext); void deregisterUIContext(final int uiContextID); void destroy(); UIContext getUIContext(final int uiContextID); Collection<UIContext> getUIContexts(); void pushToClients(final Object message); void setAttribute(final String name, final Object value); T getAttribute(final String name); ApplicationConfiguration getOptions(); String getId(); int countUIContexts(); @Override String toString();  }
@Test public void testPushToClients() { final int uiContextID1 = 1; final UIContext uiContext1 = Mockito.mock(UIContext.class); Mockito.when(uiContext1.getID()).thenReturn(uiContextID1); application.registerUIContext(uiContext1); final Object message = new Object(); application.pushToClients(message); Mockito.verify(uiContext1).pushToClient(message); }