### Question:
RangerServiceService extends RangerServiceServiceBase<XXService, RangerService> { public List<RangerService> getAllServices() { List<XXService> xxServiceList = daoMgr.getXXService().getAll(); List<RangerService> serviceList = new ArrayList<RangerService>(); for(XXService xxService : xxServiceList) { RangerService service = populateViewBean(xxService); serviceList.add(service); } return serviceList; } RangerServiceService(); RangerService getPopulatedViewObject(XXService xService); List<RangerService> getAllServices(); List<XXTrxLog> getTransactionLog(RangerService vService, int action); List<XXTrxLog> getTransactionLog(RangerService vObj, XXService mObj, int action); Map<String, String> getConfigsWithDecryptedPassword(RangerService service);  }### Answer:
@Test public void test5GetAllServices() { XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class); XXPortalUserDao xPortalUserDao = Mockito.mock(XXPortalUserDao.class); XXServiceConfigMapDao xServiceConfigMapDao = Mockito .mock(XXServiceConfigMapDao.class); XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class); String name = "fdfdfds"; List<XXServiceConfigMap> svcConfigMapList = new ArrayList<XXServiceConfigMap>(); XXServiceConfigMap xConfMap = new XXServiceConfigMap(); xConfMap.setAddedByUserId(null); xConfMap.setConfigkey(name); xConfMap.setConfigvalue(name); xConfMap.setCreateTime(new Date()); xConfMap.setServiceId(null); xConfMap.setUpdatedByUserId(null); xConfMap.setUpdateTime(new Date()); svcConfigMapList.add(xConfMap); List<XXService> xServiceList = new ArrayList<XXService>(); XXService xService = xService(); xServiceList.add(xService); XXPortalUser tUser = new XXPortalUser(); tUser.setAddedByUserId(userId); tUser.setCreateTime(new Date()); tUser.setEmailAddress("test@gmail.com"); tUser.setFirstName(name); tUser.setId(userId); tUser.setLastName(name); XXServiceDef xServiceDef = new XXServiceDef(); xServiceDef.setAddedByUserId(userId); xServiceDef.setCreateTime(new Date()); xServiceDef.setDescription("test"); xServiceDef.setGuid("1427365526516_835_0"); xServiceDef.setId(userId); Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao); Mockito.when(xServiceDao.getAll()).thenReturn(xServiceList); Mockito.when(daoManager.getXXPortalUser()).thenReturn(xPortalUserDao); Mockito.when(xPortalUserDao.getById(userId)).thenReturn(tUser); Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao); Mockito.when(xServiceDefDao.getById(xService.getType())).thenReturn( xServiceDef); Mockito.when(daoManager.getXXServiceConfigMap()).thenReturn( xServiceConfigMapDao); Mockito.when(xServiceConfigMapDao.findByServiceId(xService.getId())) .thenReturn(svcConfigMapList); List<RangerService> dbServiceList = serviceService.getAllServices(); Assert.assertNotNull(dbServiceList); Mockito.verify(daoManager).getXXServiceDef(); Mockito.verify(daoManager).getXXServiceConfigMap(); }