MessageToClientManager { Object getDataService(T session, Class cls) throws DataServiceException { String dataServiceClassName = cls.getName(); logger.debug("Looking for dataservice : {}", dataServiceClassName); if (cls.isAnnotationPresent(DataService.class)) { return _getDataService(session, cls); } else { throw new DataServiceException(dataServiceClassName + " is not annotated with @" + DataService.class.getSimpleName()); } }  abstract Map<String, Object> getSessionBeans(T session); MessageToClient createMessageToClient(MessageFromClient message, T session);  }
@Test public void testGetDataService() throws Exception { System.out.println("getDataService"); Class cls = ClassAsDataService.class; Session session = mock(Session.class); ClassAsDataService expected = new ClassAsDataService(); doReturn(expected).when(instance)._getDataService(any(Session.class), any(Class.class)); Object result = instance.getDataService(session, cls); assertThat(result).isEqualTo(expected); }
@Test(expected = DataServiceException.class) public void testGetDataServiceFail() throws DataServiceException { System.out.println("getDataServiceFail"); Class cls = ClassAsNotDataService.class; Session session = mock(Session.class); instance.getDataService(session, cls); }