RangerServiceDefServiceBase extends RangerBaseModelService<T, V> { public RangerResourceDef populateXXToRangerResourceDef(XXResourceDef xObj) { RangerResourceDef vObj = new RangerResourceDef(); vObj.setItemId(xObj.getItemId()); vObj.setName(xObj.getName()); vObj.setType(xObj.getType()); vObj.setLevel(xObj.getLevel()); vObj.setMandatory(xObj.getMandatory()); vObj.setLookupSupported(xObj.getLookupsupported()); vObj.setRecursiveSupported(xObj.getRecursivesupported()); vObj.setExcludesSupported(xObj.getExcludessupported()); vObj.setMatcher(xObj.getMatcher()); Map<String, String> matcherOptions = jsonStringToMap(xObj.getMatcheroptions()); if (MapUtils.isNotEmpty(matcherOptions)) { String optionAccessTypeRestrictions = matcherOptions.remove(OPTION_RESOURCE_ACCESS_TYPE_RESTRICTIONS); String optionIsValidLeaf = matcherOptions.remove(OPTION_RESOURCE_IS_VALID_LEAF); if (StringUtils.isNotBlank(optionAccessTypeRestrictions)) { Set<String> accessTypeRestrictions = new HashSet<>(); accessTypeRestrictions = jsonToObject(optionAccessTypeRestrictions, accessTypeRestrictions.getClass()); vObj.setAccessTypeRestrictions(accessTypeRestrictions); } if (StringUtils.isNotBlank(optionIsValidLeaf)) { Boolean isValidLeaf = jsonToObject(optionIsValidLeaf, Boolean.class); vObj.setIsValidLeaf(isValidLeaf); } } vObj.setMatcherOptions(matcherOptions); vObj.setValidationRegEx(xObj.getValidationRegEx()); vObj.setValidationMessage(xObj.getValidationMessage()); vObj.setUiHint(xObj.getUiHint()); vObj.setLabel(xObj.getLabel()); vObj.setDescription(xObj.getDescription()); vObj.setRbKeyLabel(xObj.getRbkeylabel()); vObj.setRbKeyDescription(xObj.getRbkeydescription()); vObj.setRbKeyValidationMessage(xObj.getRbKeyValidationMessage()); XXResourceDef parent = daoMgr.getXXResourceDef().getById(xObj.getParent()); String parentName = (parent != null) ? parent.getName() : null; vObj.setParent(parentName); return vObj; } 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 test6populateXXToRangerResourceDef() { XXResourceDefDao xResourceDefDao = Mockito.mock(XXResourceDefDao.class); XXResourceDef resourceDefObj = new XXResourceDef(); resourceDefObj.setAddedByUserId(Id); resourceDefObj.setCreateTime(new Date()); resourceDefObj.setDefid(Id); resourceDefObj.setDescription("HDFS Repository"); resourceDefObj.setId(Id); Mockito.when(daoManager.getXXResourceDef()).thenReturn(xResourceDefDao); RangerResourceDef dbRangerResourceDef = rangerServiceDefService .populateXXToRangerResourceDef(resourceDefObj); Assert.assertNotNull(dbRangerResourceDef); Assert.assertEquals(dbRangerResourceDef.getName(), resourceDefObj.getName()); Assert.assertEquals(dbRangerResourceDef.getDescription(), resourceDefObj.getDescription()); Assert.assertEquals(dbRangerResourceDef.getType(), resourceDefObj.getType()); Assert.assertEquals(dbRangerResourceDef.getRbKeyDescription(), resourceDefObj.getRbkeydescription()); Mockito.verify(daoManager).getXXResourceDef(); }