### Question:
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @Override @SuppressWarnings("unchecked") protected XXServiceBase mapViewToEntityBean(RangerService vObj, XXServiceBase xObj, int OPERATION_CONTEXT) { String guid = (StringUtils.isEmpty(vObj.getGuid())) ? guidUtil.genGUID() : vObj.getGuid(); xObj.setGuid(guid); XXServiceDef xServiceDef = daoMgr.getXXServiceDef().findByName(vObj.getType()); if(xServiceDef == null) { throw restErrorUtil.createRESTException( "No ServiceDefinition found with name :" + vObj.getType(), MessageEnums.INVALID_INPUT_DATA); } xObj.setType(xServiceDef.getId()); xObj.setName(vObj.getName()); xObj.setPolicyVersion(vObj.getPolicyVersion()); xObj.setPolicyUpdateTime(vObj.getPolicyUpdateTime()); xObj.setDescription(vObj.getDescription()); xObj.setIsEnabled(vObj.getIsEnabled()); return xObj; } RangerServiceServiceBase(); @SuppressWarnings("unchecked") RangerServiceList searchRangerServices(SearchFilter searchFilter);  }### Answer:
@Test public void test1MapViewToEntityBean() { XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class); XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class); RangerService rangerService = rangerService(); XXService service = service(); int OPERATION_CONTEXT = 1; Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao); Mockito.when(xServiceDefDao.findByName(rangerService.getType())) .thenReturn(xServiceDef); XXService dbService = rangerServiceService.mapViewToEntityBean( rangerService, service, OPERATION_CONTEXT); Assert.assertNotNull(dbService); Assert.assertEquals(dbService, service); Assert.assertEquals(dbService.getDescription(), service.getDescription()); Assert.assertEquals(dbService.getGuid(), service.getGuid()); Assert.assertEquals(dbService.getName(), service.getName()); Assert.assertEquals(dbService.getAddedByUserId(), service.getAddedByUserId()); Assert.assertEquals(dbService.getId(), service.getId()); Assert.assertEquals(dbService.getVersion(), service.getVersion()); Assert.assertEquals(dbService.getType(), service.getType()); Assert.assertEquals(dbService.getUpdatedByUserId(), service.getUpdatedByUserId()); Mockito.verify(daoManager).getXXServiceDef(); }