Search in sources :

Example 6 with XXServiceDef

use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.

the class TestRangerServiceDefServiceBase method test3populateRangerServiceConfigDefToXX.

@Test
public void test3populateRangerServiceConfigDefToXX() {
    RangerServiceConfigDef serviceConfigDefObj = new RangerServiceConfigDef();
    XXServiceConfigDef configDefObj = new XXServiceConfigDef();
    XXServiceDef serviceDefObj = new XXServiceDef();
    Mockito.when((XXServiceConfigDef) rangerAuditFields.populateAuditFields(configDefObj, serviceDefObj)).thenReturn(configDefObj);
    XXServiceConfigDef dbServiceConfigDef = rangerServiceDefService.populateRangerServiceConfigDefToXX(serviceConfigDefObj, configDefObj, serviceDefObj, 1);
    Assert.assertNotNull(dbServiceConfigDef);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) XXServiceConfigDef(org.apache.ranger.entity.XXServiceConfigDef) Test(org.junit.Test)

Example 7 with XXServiceDef

use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.

the class TestRangerServiceDefServiceBase method test2MapEntityToViewBean.

@Test
public void test2MapEntityToViewBean() {
    RangerServiceDef rangerServiceDef = rangerServiceDef();
    XXServiceDef serviceDef = serviceDef();
    RangerServiceDef dbRangerServiceDef = rangerServiceDefService.mapEntityToViewBean(rangerServiceDef, serviceDef);
    Assert.assertNotNull(dbRangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef.getDescription(), rangerServiceDef.getDescription());
    Assert.assertEquals(dbRangerServiceDef.getGuid(), rangerServiceDef.getGuid());
    Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
    Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
    Assert.assertEquals(dbRangerServiceDef.getVersion(), rangerServiceDef.getVersion());
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Test(org.junit.Test)

Example 8 with XXServiceDef

use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.

the class TestRangerServiceDefServiceBase method test11populateRangerPolicyConditionDefToXXnullValue.

@Test
public void test11populateRangerPolicyConditionDefToXXnullValue() {
    RangerPolicyConditionDef rangerConditionDefvObj = null;
    XXPolicyConditionDef policyConditionDefObj = null;
    XXServiceDef serviceDefObj = null;
    Mockito.when(restErrorUtil.createRESTException("RangerServiceDef cannot be null.", MessageEnums.DATA_NOT_FOUND)).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    XXPolicyConditionDef dbPolicyConditionDef = rangerServiceDefService.populateRangerPolicyConditionDefToXX(rangerConditionDefvObj, policyConditionDefObj, serviceDefObj, 1);
    Assert.assertNull(dbPolicyConditionDef);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXPolicyConditionDef(org.apache.ranger.entity.XXPolicyConditionDef) WebApplicationException(javax.ws.rs.WebApplicationException) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Test(org.junit.Test)

Example 9 with XXServiceDef

use of org.apache.ranger.entity.XXServiceDef in project ranger by apache.

the class TestRangerServiceDefServiceBase method test5populateRangerResourceDefToXX.

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

Example 10 with XXServiceDef

use of org.apache.ranger.entity.XXServiceDef 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)

Aggregations

XXServiceDef (org.apache.ranger.entity.XXServiceDef)79 Test (org.junit.Test)38 XXService (org.apache.ranger.entity.XXService)34 RangerService (org.apache.ranger.plugin.model.RangerService)26 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)25 VXString (org.apache.ranger.view.VXString)22 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)21 WebApplicationException (javax.ws.rs.WebApplicationException)20 ArrayList (java.util.ArrayList)14 Date (java.util.Date)14 XXServiceDao (org.apache.ranger.db.XXServiceDao)13 Path (javax.ws.rs.Path)11 Produces (javax.ws.rs.Produces)11 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)11 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)9 RangerAccessTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef)8 RangerPolicyResource (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 IOException (java.io.IOException)6 XXPortalUser (org.apache.ranger.entity.XXPortalUser)6