@Test
public void testPublishEvent() {

    MessageSummary actualEvent = mock(MessageSummary.class);
    String eventType = actualEvent.getClass().getSimpleName();
    ChatAlyticsEvent event = new ChatAlyticsEvent(DateTime.now(), eventType, actualEvent);
    Async asyncRemote = mock(Async.class);
    when(session.getAsyncRemote()).thenReturn(asyncRemote);
    // open two sockets make one open and one closed
    ConnectionType type = ConnectionType.SUBSCRIBER;
    underTest.openSocket(type, session);
    verify(session).getId();
    verify(session).setMaxIdleTimeout(0);
    verifyNoMoreInteractions(session);
    Session closedSession = mock(Session.class);
    when(closedSession.getId()).thenReturn("id2");
    when(closedSession.isOpen()).thenReturn(false);
    underTest.openSocket(type, closedSession);
    verify(closedSession).getId();
    verify(closedSession).setMaxIdleTimeout(0);
    verifyNoMoreInteractions(closedSession);
    verify(session).isOpen();
    verifyNoMoreInteractions(session);
    assertEquals(2, underTest.numSessions());
    underTest.publishEvent(event);
    verify(session, times(2)).isOpen();
    verify(session).getAsyncRemote();
    verifyNoMoreInteractions(session);
    verify(asyncRemote).sendObject(event);
    verifyNoMoreInteractions(asyncRemote);
    verify(closedSession).isOpen();
    verifyNoMoreInteractions(closedSession);
    assertEquals(1, underTest.numSessions());
}