TopicsMessagesBroadcaster { public int sendMessageToTopic(MessageToClient mtc, Object payload) { return sendMessageToTopic(null, mtc, payload); }  int sendMessageToTopic(MessageToClient mtc, Object payload); int sendMessageToTopic(Collection<Session> sessionTargets, MessageToClient mtc, Object payload);  }
@Test public void testSendMessageToTopic() throws SessionException { System.out.println("testSendMessageToTopic"); doReturn(5).when(instance).sendMessageToTopic(anyList(), any(MessageToClient.class), eq(PAYLOAD)); int result = instance.sendMessageToTopic(new MessageToClient(), PAYLOAD); assertThat(result).isEqualTo(5); }
@Test public void testSendMessageToTopicNoSessions() throws SessionException { System.out.println("testSendMessageToTopicNoSessions"); Collection<Session> sessions = new ArrayList<>(); when(topicManager.getSessionsForTopic(anyString())).thenReturn(null).thenReturn(sessions); int result = instance.sendMessageToTopic(null, new MessageToClient(), PAYLOAD); assertThat(result).isEqualTo(0); result = instance.sendMessageToTopic(null, new MessageToClient(), PAYLOAD); assertThat(result).isEqualTo(0); }