Search in sources :

Example 1 with RangerTagDef

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

the class RangerTagDefService method postUpdate.

@Override
public RangerTagDef postUpdate(XXTagDef tagDef) {
    RangerTagDef ret = super.postUpdate(tagDef);
    daoMgr.getXXServiceVersionInfo().updateServiceVersionInfoForTagDefUpdate(tagDef.getId(), tagDef.getUpdateTime());
    return ret;
}
Also used : RangerTagDef(org.apache.ranger.plugin.model.RangerTagDef)

Example 2 with RangerTagDef

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

the class TestTagREST method test3createTagDef.

@Test
public void test3createTagDef() {
    RangerTagDef oldTagDef = new RangerTagDef();
    RangerTagDef newTagDef = new RangerTagDef();
    oldTagDef.setId(null);
    newTagDef.setId(id);
    newTagDef.setName(name);
    try {
        Mockito.when(validator.preCreateTagDef(oldTagDef, true)).thenReturn(oldTagDef);
    } catch (Exception e) {
    }
    try {
        Mockito.when(tagStore.updateTagDef(oldTagDef)).thenReturn(newTagDef);
    } catch (Exception e) {
    }
    RangerTagDef rangerTagDef = tagREST.createTagDef(oldTagDef, true);
    Assert.assertNotNull(rangerTagDef);
    Assert.assertEquals(rangerTagDef.getId(), newTagDef.getId());
    Assert.assertEquals(rangerTagDef.getName(), newTagDef.getName());
    Assert.assertNotEquals(rangerTagDef.getName(), oldTagDef.getName());
    try {
        Mockito.verify(validator).preCreateTagDef(oldTagDef, true);
    } catch (Exception e) {
    }
    try {
        Mockito.verify(tagStore).updateTagDef(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 3 with RangerTagDef

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

the class TestTagREST method test6deleteTagDefByGuid.

@Test
public void test6deleteTagDefByGuid() {
    RangerTagDef oldTagDef = new RangerTagDef();
    oldTagDef.setId(id);
    oldTagDef.setGuid(gId);
    try {
        Mockito.when(tagStore.getTagDefByGuid(oldTagDef.getGuid())).thenReturn(oldTagDef);
    } catch (Exception e) {
    }
    try {
        Mockito.doNothing().when(tagStore).deleteTagDef(oldTagDef.getId());
    } catch (Exception e) {
    }
    tagREST.deleteTagDefByGuid(oldTagDef.getGuid());
    Assert.assertNotNull(oldTagDef.getId());
    Assert.assertNotNull(oldTagDef.getGuid());
    try {
        Mockito.verify(tagStore).getTagDefByGuid(oldTagDef.getGuid());
    } catch (Exception e) {
    }
    try {
        Mockito.verify(tagStore).deleteTagDef(oldTagDef.getId());
    } 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 4 with RangerTagDef

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

the class TestTagREST method test10getTagDefByGuid.

@Test
public void test10getTagDefByGuid() {
    RangerTagDef oldTagDef = new RangerTagDef();
    oldTagDef.setId(id);
    oldTagDef.setGuid(gId);
    try {
        Mockito.when(tagStore.getTagDefByGuid(gId)).thenReturn(oldTagDef);
    } catch (Exception e) {
    }
    RangerTagDef rangerTagDef = tagREST.getTagDefByGuid(gId);
    Assert.assertNotNull(oldTagDef.getGuid());
    Assert.assertEquals(rangerTagDef.getGuid(), oldTagDef.getGuid());
    Assert.assertEquals(rangerTagDef.getId(), oldTagDef.getId());
    try {
        Mockito.verify(tagStore).getTagDefByGuid(gId);
    } 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 5 with RangerTagDef

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

the class TestTagREST method test12getTagDefByName.

@Test
public void test12getTagDefByName() {
    RangerTagDef oldTagDef = new RangerTagDef();
    oldTagDef.setId(id);
    oldTagDef.setName(name);
    try {
        Mockito.when(tagStore.getTagDefByName(name)).thenReturn(oldTagDef);
    } catch (Exception e) {
    }
    RangerTagDef rangerTagDef = tagREST.getTagDefByName(name);
    Assert.assertNotNull(rangerTagDef.getName());
    Assert.assertEquals(rangerTagDef.getName(), oldTagDef.getName());
    Assert.assertEquals(rangerTagDef.getId(), oldTagDef.getId());
    try {
        Mockito.verify(tagStore).getTagDefByName(name);
    } 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)

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