RangerServiceDefServiceBase extends RangerBaseModelService<T, V> { public XXAccessTypeDef populateRangerAccessTypeDefToXX(RangerAccessTypeDef vObj, XXAccessTypeDef xObj, XXServiceDef serviceDef, int operationContext) { if(serviceDef == null) { LOG.error("RangerServiceDefServiceBase.populateRangerAccessTypeDefToXX, serviceDef can not be null"); throw restErrorUtil.createRESTException("RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND); } xObj = rangerAuditFields.populateAuditFields(xObj, serviceDef); xObj.setDefid(serviceDef.getId()); xObj.setItemId(vObj.getItemId()); xObj.setName(vObj.getName()); xObj.setLabel(vObj.getLabel()); xObj.setRbkeylabel(vObj.getRbKeyLabel()); xObj.setOrder(AppConstants.DEFAULT_SORT_ORDER); return xObj; } RangerServiceDefServiceBase(); XXServiceConfigDef populateRangerServiceConfigDefToXX(RangerServiceConfigDef vObj, XXServiceConfigDef xObj,
			XXServiceDef serviceDef, int operationContext); RangerServiceConfigDef populateXXToRangerServiceConfigDef(XXServiceConfigDef xObj); XXResourceDef populateRangerResourceDefToXX(RangerResourceDef vObj, XXResourceDef xObj,
			XXServiceDef serviceDef, int operationContext); RangerResourceDef populateXXToRangerResourceDef(XXResourceDef xObj); XXAccessTypeDef populateRangerAccessTypeDefToXX(RangerAccessTypeDef vObj, XXAccessTypeDef xObj,
			XXServiceDef serviceDef, int operationContext); RangerAccessTypeDef populateXXToRangerAccessTypeDef(XXAccessTypeDef xObj); XXPolicyConditionDef populateRangerPolicyConditionDefToXX(RangerPolicyConditionDef vObj,
			XXPolicyConditionDef xObj, XXServiceDef serviceDef, int operationContext); RangerPolicyConditionDef populateXXToRangerPolicyConditionDef(XXPolicyConditionDef xObj); XXContextEnricherDef populateRangerContextEnricherDefToXX(RangerContextEnricherDef vObj,
			XXContextEnricherDef xObj, XXServiceDef serviceDef, int operationContext); RangerContextEnricherDef populateXXToRangerContextEnricherDef(XXContextEnricherDef xObj); XXEnumDef populateRangerEnumDefToXX(RangerEnumDef vObj, XXEnumDef xObj, XXServiceDef serviceDef,
			int operationContext); RangerEnumDef populateXXToRangerEnumDef(XXEnumDef xObj); XXEnumElementDef populateRangerEnumElementDefToXX(RangerEnumElementDef vObj, XXEnumElementDef xObj,
			XXEnumDef enumDef, int operationContext); RangerEnumElementDef populateXXToRangerEnumElementDef(XXEnumElementDef xObj); XXDataMaskTypeDef populateRangerDataMaskDefToXX(RangerDataMaskTypeDef vObj, XXDataMaskTypeDef xObj,
														   XXServiceDef serviceDef, int operationContext); RangerDataMaskTypeDef populateXXToRangerDataMaskTypeDef(XXDataMaskTypeDef xObj); RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter); String objectToJson(Serializable obj); DST jsonToObject(String jsonStr, Class<DST> clz);  }
@Test public void test7populateRangerAccessTypeDefToXX() { RangerAccessTypeDef rangerAccessTypeDefObj = new RangerAccessTypeDef(); rangerAccessTypeDefObj.setLabel("Read"); rangerAccessTypeDefObj.setName("read"); rangerAccessTypeDefObj.setRbKeyLabel(null); XXAccessTypeDef accessTypeDefObj = new XXAccessTypeDef(); accessTypeDefObj.setAddedByUserId(Id); accessTypeDefObj.setCreateTime(new Date()); accessTypeDefObj.setDefid(Id); accessTypeDefObj.setId(Id); accessTypeDefObj.setLabel("Read"); accessTypeDefObj.setName("read"); accessTypeDefObj.setOrder(null); accessTypeDefObj.setRbkeylabel(null); accessTypeDefObj.setUpdatedByUserId(Id); accessTypeDefObj.setUpdateTime(new Date()); XXServiceDef serviceDefObj = new XXServiceDef(); serviceDefObj.setAddedByUserId(Id); serviceDefObj.setCreateTime(new Date()); serviceDefObj.setDescription("HDFS Repository"); serviceDefObj.setGuid("1427365526516_835_0"); serviceDefObj.setId(Id); Mockito.when( (XXAccessTypeDef) rangerAuditFields.populateAuditFields( accessTypeDefObj, serviceDefObj)).thenReturn( accessTypeDefObj); XXAccessTypeDef dbAccessTypeDef = rangerServiceDefService .populateRangerAccessTypeDefToXX(rangerAccessTypeDefObj, accessTypeDefObj, serviceDefObj, 1); Assert.assertNotNull(dbAccessTypeDef); Assert.assertEquals(dbAccessTypeDef, accessTypeDefObj); Assert.assertEquals(dbAccessTypeDef.getName(), accessTypeDefObj.getName()); Assert.assertEquals(dbAccessTypeDef.getLabel(), accessTypeDefObj.getLabel()); Assert.assertEquals(dbAccessTypeDef.getRbkeylabel(), accessTypeDefObj.getRbkeylabel()); Assert.assertEquals(dbAccessTypeDef.getDefid(), accessTypeDefObj.getDefid()); Assert.assertEquals(dbAccessTypeDef.getId(), accessTypeDefObj.getId()); Assert.assertEquals(dbAccessTypeDef.getCreateTime(), accessTypeDefObj.getCreateTime()); Assert.assertEquals(dbAccessTypeDef.getOrder(), accessTypeDefObj.getOrder()); }
@Test public void test8populateRangerAccessTypeDefToXXNullValue() { RangerAccessTypeDef rangerAccessTypeDefObj = null; XXAccessTypeDef accessTypeDefObj = null; XXServiceDef serviceDefObj = null; Mockito.when( restErrorUtil.createRESTException( "RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND)).thenThrow( new WebApplicationException()); thrown.expect(WebApplicationException.class); XXAccessTypeDef dbAccessTypeDef = rangerServiceDefService .populateRangerAccessTypeDefToXX(rangerAccessTypeDefObj, accessTypeDefObj, serviceDefObj, 1); Assert.assertNull(dbAccessTypeDef); }