Search in sources :

Example 1 with RangerEnumDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 2 with RangerEnumDef

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();
}
Also used : XXEnumElementDef(org.apache.ranger.entity.XXEnumElementDef) XXEnumDef(org.apache.ranger.entity.XXEnumDef) ArrayList(java.util.ArrayList) XXEnumElementDefDao(org.apache.ranger.db.XXEnumElementDefDao) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) Date(java.util.Date) Test(org.junit.Test)

Example 3 with RangerEnumDef

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());
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXEnumDef(org.apache.ranger.entity.XXEnumDef) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) Date(java.util.Date) Test(org.junit.Test)

Example 4 with RangerEnumDef

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);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) WebApplicationException(javax.ws.rs.WebApplicationException) XXEnumDef(org.apache.ranger.entity.XXEnumDef) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) Test(org.junit.Test)

Example 5 with RangerEnumDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Aggregations

RangerEnumDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef)20 ArrayList (java.util.ArrayList)10 RangerAccessTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef)10 RangerContextEnricherDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef)10 RangerPolicyConditionDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef)10 RangerResourceDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)10 RangerServiceConfigDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef)10 Date (java.util.Date)8 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)8 XXEnumDef (org.apache.ranger.entity.XXEnumDef)5 RangerEnumElementDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumElementDef)5 Test (org.junit.Test)5 XXServiceDef (org.apache.ranger.entity.XXServiceDef)4 XXEnumElementDefDao (org.apache.ranger.db.XXEnumElementDefDao)3 XXEnumElementDef (org.apache.ranger.entity.XXEnumElementDef)3 ValidationErrorCode (org.apache.ranger.plugin.errors.ValidationErrorCode)3 RangerDataMaskDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerDataMaskDef)3 RangerDataMaskTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerDataMaskTypeDef)3 RangerRowFilterDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerRowFilterDef)3 VXString (org.apache.ranger.view.VXString)3