MessageToClientManager { public MessageToClient createMessageToClient(MessageFromClient message, T session) { return _createMessageToClient(message, session); }  abstract Map<String, Object> getSessionBeans(T session); MessageToClient createMessageToClient(MessageFromClient message, T session);  }
@Test public void testCreateMessageToClient() throws Exception { String methodname = "methodReturnString"; System.out.println("_createMessageToClient("+methodname+")"); Class cls = ClassAsDataService.class; MessageFromClient message = new MessageFromClient(); message.setDataService(cls.getName()); message.setOperation(methodname); message.setParameters(Arrays.asList("\"v\"")); message.setId(UUID.randomUUID().toString()); Session session = mock(Session.class); Method method = cls.getMethod(methodname, String.class); ClassAsDataService obj = new ClassAsDataService(); doReturn(obj).when(instance).getDataService(any(Session.class), any(Class.class)); doReturn(Arrays.asList("v")).when(instance).getArrayList(); when(methodServices.getMethodFromDataService(any(Class.class), any(MessageFromClient.class), anyList())).thenReturn(method); doNothing().when(instance).injectSession(any(Class[].class), anyList(), anyObject()); when(methodServices.getNonProxiedMethod(any(Class.class), anyString(), any(Class[].class))).thenReturn(method); MessageToClient result = instance.createMessageToClient(message, session); assertThat(result.getResponse()).isEqualTo(obj.methodReturnString("v")); }
@Test public void testCreateMessageToClient5() throws Exception { String methodname = "methodReturnString"; System.out.println("_createMessageToClient("+methodname+") Failed"); Session session = mock(Session.class); Fault fault = mock(Fault.class); Class cls = ClassAsDataService.class; MessageFromClient message = new MessageFromClient(); message.setDataService("BadClass"); when(faultServices.buildFault(any(Throwable.class))).thenReturn(fault); MessageToClient result = instance.createMessageToClient(message, session); assertThat(result.getResponse()).isEqualTo(fault); }