RangerServiceDefServiceBase extends RangerBaseModelService<T, V> { public XXEnumDef populateRangerEnumDefToXX(RangerEnumDef vObj, XXEnumDef xObj, XXServiceDef serviceDef, int operationContext) { if(serviceDef == null) { LOG.error("RangerServiceDefServiceBase.populateRangerEnumDefToXX, 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.setDefaultindex(vObj.getDefaultIndex()); 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 test16populateRangerEnumDefToXX() { RangerEnumDef rangerEnumDefObj = new RangerEnumDef(); rangerEnumDefObj.setName("authnType"); rangerEnumDefObj.setDefaultIndex(0); XXEnumDef enumDefObj = new XXEnumDef(); enumDefObj.setAddedByUserId(Id); enumDefObj.setCreateTime(new Date()); enumDefObj.setDefaultindex(0); enumDefObj.setDefid(Id); enumDefObj.setId(Id); enumDefObj.setName("authnType"); enumDefObj.setUpdatedByUserId(Id); enumDefObj.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( (XXEnumDef) rangerAuditFields.populateAuditFields(enumDefObj, serviceDefObj)).thenReturn(enumDefObj); XXEnumDef dbEnumDef = rangerServiceDefService .populateRangerEnumDefToXX(rangerEnumDefObj, enumDefObj, serviceDefObj,1); Assert.assertNotNull(dbEnumDef); Assert.assertEquals(dbEnumDef, enumDefObj); Assert.assertEquals(dbEnumDef.getName(), enumDefObj.getName()); Assert.assertEquals(dbEnumDef.getDefid(), enumDefObj.getDefid()); Assert.assertEquals(dbEnumDef.getId(), enumDefObj.getId()); Assert.assertEquals(dbEnumDef.getCreateTime(), enumDefObj.getCreateTime()); }
@Test public void test17populateRangerEnumDefToXXnullValue() { RangerEnumDef rangerEnumDefObj = null; XXEnumDef enumDefObj = null; XXServiceDef serviceDefObj = null; Mockito.when( restErrorUtil.createRESTException( "RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND)).thenThrow( new WebApplicationException()); thrown.expect(WebApplicationException.class); XXEnumDef dbEnumDef = rangerServiceDefService .populateRangerEnumDefToXX(rangerEnumDefObj, enumDefObj, serviceDefObj, 1); Assert.assertNull(dbEnumDef); }