### Question:
RangerServiceService extends RangerServiceServiceBase<XXService, RangerService> { public RangerService getPopulatedViewObject(XXService xService) { return this.populateViewBean(xService); } 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 test4GetPopulatedViewObject() { XXServiceConfigMapDao xServiceConfigMapDao = Mockito .mock(XXServiceConfigMapDao.class); XXPortalUserDao xPortalUserDao = Mockito.mock(XXPortalUserDao.class); XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class); XXService xService = xService(); 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); 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.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); RangerService dbService = serviceService .getPopulatedViewObject(xService); Assert.assertNotNull(dbService); Assert.assertEquals(userId, dbService.getId()); Assert.assertEquals(xService.getAddedByUserId(), dbService.getId()); Assert.assertEquals(xService.getId(), dbService.getId()); Assert.assertEquals(xService.getDescription(), dbService.getDescription()); Assert.assertEquals(xService.getGuid(), dbService.getGuid()); Assert.assertEquals(xService.getName(), dbService.getName()); Assert.assertEquals(xService.getPolicyUpdateTime(), dbService.getPolicyUpdateTime()); Assert.assertEquals(xService.getPolicyVersion(), dbService.getPolicyVersion()); Assert.assertEquals(xService.getVersion(), dbService.getVersion()); Mockito.verify(daoManager).getXXServiceDef(); Mockito.verify(daoManager).getXXServiceConfigMap(); }