### Question:
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @Override @SuppressWarnings("unchecked") protected RangerService mapEntityToViewBean(RangerService vObj, XXServiceBase xObj) { XXServiceDef xServiceDef = daoMgr.getXXServiceDef().getById(xObj.getType()); vObj.setType(xServiceDef.getName()); vObj.setGuid(xObj.getGuid()); vObj.setVersion(xObj.getVersion()); vObj.setName(xObj.getName()); vObj.setDescription(xObj.getDescription()); vObj.setPolicyVersion(xObj.getPolicyVersion()); vObj.setPolicyUpdateTime(xObj.getPolicyUpdateTime()); vObj.setIsEnabled(xObj.getIsenabled()); return vObj; } RangerServiceServiceBase(); @SuppressWarnings("unchecked") RangerServiceList searchRangerServices(SearchFilter searchFilter);  }### Answer:
@Test public void test2mapEntityToViewBean() { XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class); XXServiceDef xServiceDef = Mockito.mock(XXServiceDef.class); RangerService rangerService = rangerService(); XXService service = service(); Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao); Mockito.when(xServiceDefDao.getById(service.getType())).thenReturn( xServiceDef); RangerService dbRangerService = rangerServiceService .mapEntityToViewBean(rangerService, service); Assert.assertNotNull(dbRangerService); Assert.assertEquals(dbRangerService, rangerService); Assert.assertEquals(dbRangerService.getDescription(), rangerService.getDescription()); Assert.assertEquals(dbRangerService.getGuid(), rangerService.getGuid()); Assert.assertEquals(dbRangerService.getName(), rangerService.getName()); Assert.assertEquals(dbRangerService.getId(), rangerService.getId()); Assert.assertEquals(dbRangerService.getVersion(), rangerService.getVersion()); Assert.assertEquals(dbRangerService.getType(), rangerService.getType()); Mockito.verify(daoManager).getXXServiceDef(); }