Search in sources :

Example 26 with RangerTagDef

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

the class TestTagREST method test1createTagDef.

@Test
public void test1createTagDef() {
    RangerTagDef oldTagDef = null;
    RangerTagDef newTagDef = new RangerTagDef();
    newTagDef.setId(id);
    newTagDef.setName(name);
    try {
        Mockito.when(validator.preCreateTagDef(oldTagDef, false)).thenReturn(null);
    } catch (Exception e) {
    }
    try {
        Mockito.when(tagStore.createTagDef(oldTagDef)).thenReturn(newTagDef);
    } catch (Exception e) {
    }
    RangerTagDef rangerTagDef = tagREST.createTagDef(oldTagDef, false);
    Assert.assertEquals(rangerTagDef.getId(), newTagDef.getId());
    Assert.assertNotNull(rangerTagDef);
    Assert.assertEquals(rangerTagDef.getName(), newTagDef.getName());
    try {
        Mockito.verify(validator).preCreateTagDef(oldTagDef, false);
    } catch (Exception e) {
    }
    try {
        Mockito.verify(tagStore).createTagDef(oldTagDef);
    } catch (Exception e) {
    }
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 27 with RangerTagDef

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

the class TestTagREST method test14getAllTagDefs.

@Test
public void test14getAllTagDefs() {
    List<RangerTagDef> ret = new ArrayList<RangerTagDef>();
    RangerTagDef rangerTagDef = new RangerTagDef();
    rangerTagDef.setId(id);
    rangerTagDef.setVersion(5L);
    ret.add(rangerTagDef);
    try {
        Mockito.when(tagStore.getTagDefs((SearchFilter) Mockito.any())).thenReturn(ret);
    } catch (Exception e) {
    }
    List<RangerTagDef> result = tagREST.getAllTagDefs();
    Assert.assertNotNull(result);
    Assert.assertEquals(result.get(0).getId(), ret.get(0).getId());
    Assert.assertEquals(result.get(0).getVersion(), ret.get(0).getVersion());
    try {
        Mockito.verify(tagStore).getTagDefs((SearchFilter) Mockito.any());
    } catch (Exception e) {
    }
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) ArrayList(java.util.ArrayList) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 28 with RangerTagDef

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

the class TestTagREST method test8getTagDef.

@Test
public void test8getTagDef() {
    RangerTagDef oldTagDef = new RangerTagDef();
    oldTagDef.setId(id);
    oldTagDef.setName(name);
    try {
        Mockito.when(tagStore.getTagDef(id)).thenReturn(oldTagDef);
    } catch (Exception e) {
    }
    RangerTagDef rangerTagDef = tagREST.getTagDef(id);
    Assert.assertNotNull(rangerTagDef.getId());
    Assert.assertEquals(rangerTagDef.getId(), oldTagDef.getId());
    Assert.assertEquals(rangerTagDef.getName(), oldTagDef.getName());
    try {
        Mockito.verify(tagStore).getTagDef(id);
    } catch (Exception e) {
    }
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 29 with RangerTagDef

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

the class RangerTagDefService method getTagDefByName.

public RangerTagDef getTagDefByName(String name) {
    RangerTagDef ret = null;
    XXTagDef xxTagDef = daoMgr.getXXTagDef().findByName(name);
    if (xxTagDef != null) {
        ret = populateViewBean(xxTagDef);
    }
    return ret;
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef)

Example 30 with RangerTagDef

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

the class RangerTagDefService method getTagDefByGuid.

public RangerTagDef getTagDefByGuid(String guid) {
    RangerTagDef ret = null;
    XXTagDef xxTagDef = daoMgr.getXXTagDef().findByGuid(guid);
    if (xxTagDef != null) {
        ret = populateViewBean(xxTagDef);
    }
    return ret;
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef) XXTagDef(org.apache.ranger.entity.XXTagDef)

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