WSController implements IWSController { @Override public void receiveCommandMessage(Session client, String json) { MessageFromClient message = MessageFromClient.createFromJson(json); logger.debug("Receive call message in websocket '{}' for session '{}'", message.getId(), client.getId()); callServiceManager.sendMessageToClient(message, client); }  @Override void handleOpenConnexion(Session session, EndpointConfig config); @Override void onError(Session session, Throwable t); @Override void handleClosedConnexion(Session session, CloseReason closeReason); @Override void receiveCommandMessage(Session client, String json);  }
@Test public void testReceiveCommandMessage() { System.out.println("receiveCommandMessage"); Session client = mock(Session.class); String[] parameters = new String[]{"\"toto\"", "5", "true"}; String json = String.format("{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":%s}", Constants.Message.ID, "111", Constants.Message.DATASERVICE, "ClassName", Constants.Message.OPERATION, "methodName", Constants.Message.ARGUMENTS, Arrays.toString(parameters)); instance.receiveCommandMessage(client, json); ArgumentCaptor<MessageFromClient> captureMsg = ArgumentCaptor.forClass(MessageFromClient.class); ArgumentCaptor<Session> captureSession = ArgumentCaptor.forClass(Session.class); verify(callServiceManager).sendMessageToClient(captureMsg.capture(), captureSession.capture()); MessageFromClient result = captureMsg.getValue(); assertThat(result.getId()).isEqualTo("111"); assertThat(result.getDataService()).isEqualTo("ClassName"); assertThat(result.getOperation()).isEqualTo("methodName"); assertThat(result.getParameters()).containsExactly("\"toto\"", "5", "true"); }