TopicsMessagesBroadcaster { void checkMessageTopic(UserContext ctx, String topic, Object payload, JsTopicMessageController msgControl) throws NotRecipientException { if (null != msgControl) { msgControl.checkRight(ctx, topic, payload); } }  int sendMessageToTopic(MessageToClient mtc, Object payload); int sendMessageToTopic(Collection<Session> sessionTargets, MessageToClient mtc, Object payload);  }
@Test public void checkMessageTopicTest() throws NotRecipientException { System.out.println("checkMessageTopic"); UserContext userContext = mock(UserContext.class); JsTopicMessageController jtmc = mock(JsTopicMessageController.class); doNothing().when(jtmc).checkRight(eq(userContext), eq(TOPIC), eq(PAYLOAD)); instance.checkMessageTopic(userContext, TOPIC, PAYLOAD, jtmc); }
@Test(expected = NotRecipientException.class) public void checkMessageTopicTestFail() throws NotRecipientException { System.out.println("checkMessageTopic"); UserContext userContext = mock(UserContext.class); JsTopicMessageController jtmc = mock(JsTopicMessageController.class); doThrow(NotRecipientException.class).when(jtmc).checkRight(eq(userContext), eq(TOPIC), eq(PAYLOAD)); instance.checkMessageTopic(userContext, TOPIC, PAYLOAD, jtmc); }