use of org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef in project ranger by apache.
the class TestRangerServiceDefService method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test18populateXXToRangerEnumDef.
@Test
public void test18populateXXToRangerEnumDef() {
XXEnumElementDefDao xEnumElementDefDao = Mockito.mock(XXEnumElementDefDao.class);
List<XXEnumElementDef> enumElementDefList = new ArrayList<XXEnumElementDef>();
XXEnumElementDef enumElementDefObj = new XXEnumElementDef();
enumElementDefObj.setAddedByUserId(Id);
enumElementDefObj.setCreateTime(new Date());
enumElementDefObj.setEnumdefid(Id);
enumElementDefObj.setId(Id);
enumElementDefObj.setLabel("Simple");
enumElementDefObj.setName("simple");
enumElementDefObj.setOrder(0);
enumElementDefObj.setUpdatedByUserId(Id);
enumElementDefObj.setUpdateTime(new Date());
enumElementDefList.add(enumElementDefObj);
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());
Mockito.when(daoManager.getXXEnumElementDef()).thenReturn(xEnumElementDefDao);
Mockito.when(xEnumElementDefDao.findByEnumDefId(enumDefObj.getId())).thenReturn(enumElementDefList);
RangerEnumDef dbRangerEnumDef = rangerServiceDefService.populateXXToRangerEnumDef(enumDefObj);
Assert.assertNotNull(dbRangerEnumDef);
Assert.assertEquals(dbRangerEnumDef.getName(), enumDefObj.getName());
Mockito.verify(daoManager).getXXEnumElementDef();
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test16populateRangerEnumDefToXX.
@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());
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test17populateRangerEnumDefToXXnullValue.
@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);
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef in project ranger by apache.
the class TestAssetREST method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
Aggregations