Search in sources :

Example 11 with RangerTagDef

use of org.apache.ranger.plugin.model.RangerTagDef in project ranger by apache.

the class RangerTagDefService method getTagDefsByServiceId.

public List<RangerTagDef> getTagDefsByServiceId(Long serviceId) {
    List<RangerTagDef> ret = new ArrayList<RangerTagDef>();
    List<XXTagDef> xxTagDefs = daoMgr.getXXTagDef().findByServiceId(serviceId);
    if (CollectionUtils.isNotEmpty(xxTagDefs)) {
        for (XXTagDef xxTagDef : xxTagDefs) {
            RangerTagDef tagDef = populateViewBean(xxTagDef);
            ret.add(tagDef);
        }
    }
    return ret;
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) ArrayList(java.util.ArrayList)

Example 12 with RangerTagDef

use of org.apache.ranger.plugin.model.RangerTagDef in project ranger by apache.

the class TestRangerTagDefService method test2validateForUpdate.

@Test
public void test2validateForUpdate() {
    RangerTagDef rangerServiceDef = new RangerTagDef();
    XXTagDef xXTagDef = new XXTagDef();
    rangerTagDefService.validateForUpdate(rangerServiceDef, xXTagDef);
    Assert.assertNotNull(rangerServiceDef);
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) Test(org.junit.Test)

Example 13 with RangerTagDef

use of org.apache.ranger.plugin.model.RangerTagDef in project ranger by apache.

the class TestRangerTagDefService method test3postUpdate.

@Test
public void test3postUpdate() {
    XXTagDef tagDef = new XXTagDef();
    tagDef.setId(id);
    tagDef.setName(name);
    tagDef.setUpdateTime(new Date());
    List<XXTagAttributeDef> tagAttrDefList = new ArrayList<XXTagAttributeDef>();
    XXTagAttributeDef xxTagAttributeDef = new XXTagAttributeDef();
    xxTagAttributeDef.setId(id);
    xxTagAttributeDef.setName(name);
    tagAttrDefList.add(xxTagAttributeDef);
    RangerTagDef result = rangerTagDefService.postUpdate(tagDef);
    Assert.assertEquals(result.getId(), tagAttrDefList.get(0).getId());
    Assert.assertEquals(result.getName(), tagAttrDefList.get(0).getName());
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 14 with RangerTagDef

use of org.apache.ranger.plugin.model.RangerTagDef in project ranger by apache.

the class TestRangerTagDefService method test4getTagDefByGuid.

@Test
public void test4getTagDefByGuid() {
    XXTagDef xxTagDef = new XXTagDef();
    xxTagDef.setId(id);
    xxTagDef.setName(name);
    xxTagDef.setUpdateTime(new Date());
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByGuid(guid)).thenReturn(xxTagDef);
    List<XXTagAttributeDef> tagAttrDefList = new ArrayList<XXTagAttributeDef>();
    XXTagAttributeDef xxTagAttributeDef = new XXTagAttributeDef();
    xxTagAttributeDef.setId(id);
    xxTagAttributeDef.setName(name);
    tagAttrDefList.add(xxTagAttributeDef);
    RangerTagDef result = rangerTagDefService.getTagDefByGuid(guid);
    Assert.assertEquals(result.getId(), tagAttrDefList.get(0).getId());
    Assert.assertEquals(result.getName(), tagAttrDefList.get(0).getName());
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByGuid(guid);
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) ArrayList(java.util.ArrayList) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Date(java.util.Date) Test(org.junit.Test)

Example 15 with RangerTagDef

use of org.apache.ranger.plugin.model.RangerTagDef in project ranger by apache.

the class TestRangerTagDefService method test6getTagDefByName.

@Test
public void test6getTagDefByName() {
    RangerTagDef oldTagDef = new RangerTagDef();
    oldTagDef.setId(id);
    oldTagDef.setName(name);
    XXTagDef xxTagDef = new XXTagDef();
    xxTagDef.setId(id);
    xxTagDef.setName(name);
    xxTagDef.setUpdateTime(new Date());
    XXTagDefDao xXTagDefDao = Mockito.mock(XXTagDefDao.class);
    Mockito.when(daoMgr.getXXTagDef()).thenReturn(xXTagDefDao);
    Mockito.when(xXTagDefDao.findByName(name)).thenReturn(xxTagDef);
    List<XXTagAttributeDef> tagAttrDefList = new ArrayList<XXTagAttributeDef>();
    XXTagAttributeDef xxTagAttributeDef = new XXTagAttributeDef();
    xxTagAttributeDef.setId(id);
    xxTagAttributeDef.setName(name);
    tagAttrDefList.add(xxTagAttributeDef);
    RangerTagDef result = rangerTagDefService.getTagDefByName(name);
    Assert.assertEquals(result.getId(), tagAttrDefList.get(0).getId());
    Assert.assertEquals(result.getName(), tagAttrDefList.get(0).getName());
    Mockito.verify(daoMgr).getXXTagDef();
    Mockito.verify(xXTagDefDao).findByName(name);
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef) XXTagAttributeDef(org.apache.ranger.entity.XXTagAttributeDef) ArrayList(java.util.ArrayList) XXTagDefDao(org.apache.ranger.db.XXTagDefDao) Date(java.util.Date) Test(org.junit.Test)

Aggregations

RangerTagDef (org.apache.ranger.plugin.model.RangerTagDef)39 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)15 XXTagDef (org.apache.ranger.entity.XXTagDef)14 HashMap (java.util.HashMap)10 RangerTag (org.apache.ranger.plugin.model.RangerTag)10 WebApplicationException (javax.ws.rs.WebApplicationException)9 RangerServiceResource (org.apache.ranger.plugin.model.RangerServiceResource)9 ExpectedException (org.junit.rules.ExpectedException)9 XXTagDefDao (org.apache.ranger.db.XXTagDefDao)7 ServiceTags (org.apache.ranger.plugin.util.ServiceTags)6 List (java.util.List)5 Map (java.util.Map)5 XXTagAttributeDef (org.apache.ranger.entity.XXTagAttributeDef)5 Date (java.util.Date)4 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)4 RangerTagResourceMap (org.apache.ranger.plugin.model.RangerTagResourceMap)4 TagStore (org.apache.ranger.plugin.store.TagStore)4 Predicate (org.apache.commons.collections.Predicate)3 RangerServiceResourceSignature (org.apache.ranger.plugin.store.RangerServiceResourceSignature)3