Search in sources :

Example 1 with RangerTagResourceMap

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

the class RangerTagResourceMapService method postUpdate.

@Override
public RangerTagResourceMap postUpdate(XXTagResourceMap tagResMap) {
    RangerTagResourceMap ret = super.postUpdate(tagResMap);
    daoMgr.getXXServiceVersionInfo().updateServiceVersionInfoForServiceResourceUpdate(tagResMap.getResourceId(), tagResMap.getUpdateTime());
    return ret;
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap)

Example 2 with RangerTagResourceMap

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

the class TestTagREST method test43deleteTagResourceMap.

@Test
public void test43deleteTagResourceMap() {
    RangerTagResourceMap oldTagResourceMap = new RangerTagResourceMap();
    oldTagResourceMap.setId(id);
    try {
        Mockito.when(validator.preDeleteTagResourceMap(tagGuid, resourceGuid)).thenReturn(oldTagResourceMap);
    } catch (Exception e) {
    }
    try {
        Mockito.doNothing().when(tagStore).deleteTagResourceMap(oldTagResourceMap.getId());
    } catch (Exception e) {
    }
    tagREST.deleteTagResourceMap(tagGuid, resourceGuid);
    try {
        Mockito.verify(validator).preDeleteTagResourceMap(tagGuid, resourceGuid);
    } catch (Exception e) {
    }
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 3 with RangerTagResourceMap

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

the class TestTagREST method test61deleteServiceResourceByGuid.

@Test
public void test61deleteServiceResourceByGuid() {
    RangerServiceResource oldRSR = new RangerServiceResource();
    oldRSR.setId(id);
    oldRSR.setGuid(gId);
    List<RangerTagResourceMap> tagResourceMaps = new ArrayList<RangerTagResourceMap>();
    try {
        Mockito.when(validator.preDeleteServiceResourceByGuid(gId, true)).thenReturn(oldRSR);
    } catch (Exception e) {
    }
    try {
        Mockito.when(tagStore.getTagResourceMapsForResourceGuid(oldRSR.getGuid())).thenReturn(tagResourceMaps);
    } catch (Exception e) {
    }
    tagREST.deleteServiceResourceByGuid(gId, true);
    try {
        Mockito.verify(validator).preDeleteServiceResourceByGuid(gId, true);
    } catch (Exception e) {
    }
    try {
        Mockito.verify(tagStore).getTagResourceMapsForResourceGuid(oldRSR.getGuid());
    } catch (Exception e) {
    }
}
Also used : RangerServiceResource(org.apache.ranger.plugin.model.RangerServiceResource) ArrayList(java.util.ArrayList) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 4 with RangerTagResourceMap

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

the class TestTagREST method test46getTagResourceMap.

@Test
public void test46getTagResourceMap() {
    RangerTagResourceMap oldTagResourceMap = new RangerTagResourceMap();
    oldTagResourceMap.setId(id);
    oldTagResourceMap.setTagId(id);
    try {
        Mockito.when(tagStore.getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid)).thenReturn(oldTagResourceMap);
    } catch (Exception e) {
    }
    RangerTagResourceMap rangerTagResourceMap = tagREST.getTagResourceMap(tagGuid, resourceGuid);
    Assert.assertNotNull(rangerTagResourceMap.getId());
    Assert.assertEquals(rangerTagResourceMap.getId(), oldTagResourceMap.getId());
    Assert.assertEquals(rangerTagResourceMap.getTagId(), oldTagResourceMap.getTagId());
    try {
        Mockito.verify(tagStore).getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid);
    } catch (Exception e) {
    }
}
Also used : RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 5 with RangerTagResourceMap

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

the class TestTagREST method test39createTagResourceMap.

@Test
public void test39createTagResourceMap() {
    RangerTagResourceMap oldTagResourceMap = new RangerTagResourceMap();
    try {
        Mockito.when(tagStore.getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid)).thenReturn(oldTagResourceMap);
    } catch (Exception e) {
    }
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    tagREST.createTagResourceMap(tagGuid, resourceGuid, false);
    try {
        Mockito.verify(tagStore).getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid);
    } catch (Exception e) {
    }
    Mockito.verify(restErrorUtil).createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean());
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RangerTagResourceMap(org.apache.ranger.plugin.model.RangerTagResourceMap) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Aggregations

RangerTagResourceMap (org.apache.ranger.plugin.model.RangerTagResourceMap)34 WebApplicationException (javax.ws.rs.WebApplicationException)16 Test (org.junit.Test)14 ExpectedException (org.junit.rules.ExpectedException)12 ArrayList (java.util.ArrayList)11 RangerServiceResource (org.apache.ranger.plugin.model.RangerServiceResource)9 XXTagResourceMap (org.apache.ranger.entity.XXTagResourceMap)8 HashMap (java.util.HashMap)5 RangerTag (org.apache.ranger.plugin.model.RangerTag)5 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 RangerTagDef (org.apache.ranger.plugin.model.RangerTagDef)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 List (java.util.List)3 DELETE (javax.ws.rs.DELETE)3 Predicate (org.apache.commons.collections.Predicate)3 RangerServiceResourceSignature (org.apache.ranger.plugin.store.RangerServiceResourceSignature)3 Map (java.util.Map)2 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)2 TagStore (org.apache.ranger.plugin.store.TagStore)2