RangerServiceDefServiceBase extends RangerBaseModelService<T, V> { public XXResourceDef populateRangerResourceDefToXX(RangerResourceDef vObj, XXResourceDef xObj, XXServiceDef serviceDef, int operationContext) { if(serviceDef == null) { LOG.error("RangerServiceDefServiceBase.populateRangerResourceDefToXX, 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.setType(vObj.getType()); xObj.setLevel(vObj.getLevel()); xObj.setMandatory(vObj.getMandatory()); xObj.setLookupsupported(vObj.getLookupSupported()); xObj.setRecursivesupported(vObj.getRecursiveSupported()); xObj.setExcludessupported(vObj.getExcludesSupported()); xObj.setMatcher(vObj.getMatcher()); String accessTypeRestrictions = objectToJson((HashSet<String>)vObj.getAccessTypeRestrictions()); String isValidLeaf = objectToJson(vObj.getIsValidLeaf()); Map<String, String> matcherOptions = vObj.getMatcherOptions(); if (StringUtils.isNotBlank(accessTypeRestrictions)) { matcherOptions.put(OPTION_RESOURCE_ACCESS_TYPE_RESTRICTIONS, accessTypeRestrictions); } else { matcherOptions.remove(OPTION_RESOURCE_ACCESS_TYPE_RESTRICTIONS); } if (StringUtils.isNotBlank(isValidLeaf)) { matcherOptions.put(OPTION_RESOURCE_IS_VALID_LEAF, isValidLeaf); } else { matcherOptions.remove(OPTION_RESOURCE_IS_VALID_LEAF); } xObj.setMatcheroptions(mapToJsonString(matcherOptions)); xObj.setValidationRegEx(vObj.getValidationRegEx()); xObj.setValidationMessage(vObj.getValidationMessage()); xObj.setUiHint(vObj.getUiHint()); xObj.setLabel(vObj.getLabel()); xObj.setDescription(vObj.getDescription()); xObj.setRbkeylabel(vObj.getRbKeyLabel()); xObj.setRbkeydescription(vObj.getRbKeyDescription()); xObj.setRbKeyValidationMessage(vObj.getRbKeyValidationMessage()); 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 test5populateRangerResourceDefToXX() { RangerResourceDef rangerResourceDefObj = new RangerResourceDef(); rangerResourceDefObj.setDescription("HDFS Repository"); rangerResourceDefObj.setExcludesSupported(false); rangerResourceDefObj.setLabel("HDFS Repository"); rangerResourceDefObj.setName("HDFs"); XXResourceDef resourceDefObj = new XXResourceDef(); resourceDefObj.setAddedByUserId(Id); resourceDefObj.setCreateTime(new Date()); resourceDefObj.setDefid(Id); resourceDefObj.setDescription("HDFS Repository"); resourceDefObj.setId(Id); 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( (XXResourceDef) rangerAuditFields.populateAuditFields( resourceDefObj, serviceDefObj)).thenReturn( resourceDefObj); XXResourceDef dbResourceDef = rangerServiceDefService .populateRangerResourceDefToXX(rangerResourceDefObj, resourceDefObj, serviceDefObj, 1); Assert.assertNotNull(dbResourceDef); Assert.assertEquals(dbResourceDef, resourceDefObj); Assert.assertEquals(dbResourceDef.getId(), resourceDefObj.getId()); Assert.assertEquals(dbResourceDef.getLabel(), resourceDefObj.getLabel()); Assert.assertEquals(dbResourceDef.getName(), resourceDefObj.getName()); Assert.assertEquals(dbResourceDef.getDescription(), resourceDefObj.getDescription()); }