Search in sources :

Example 16 with VXPermMap

use of org.apache.ranger.view.VXPermMap in project ranger by apache.

the class TestXUserREST method test38getXPermMapVXResourceNull.

@Test
public void test38getXPermMapVXResourceNull() throws Exception {
    VXPermMap permMap = testcreateXPermMap();
    Mockito.when(xUserMgr.getXPermMap(id)).thenReturn(permMap);
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    VXPermMap retVxGroup = xUserRest.getXPermMap(id);
    Mockito.verify(xUserMgr).getXPermMap(id);
    Mockito.verify(xResourceService).readResource(null);
    Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any());
    assertEquals(permMap.getId(), retVxGroup.getId());
    assertEquals(permMap.getClass(), retVxGroup.getClass());
    assertNotNull(retVxGroup);
}
Also used : VXPermMap(org.apache.ranger.view.VXPermMap) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 17 with VXPermMap

use of org.apache.ranger.view.VXPermMap in project ranger by apache.

the class TestXUserREST method test44updateXPermMap.

@Test
public void test44updateXPermMap() {
    VXPermMap permMap = testcreateXPermMap();
    VXResource testVxResource = new VXResource();
    Mockito.when(xResourceService.readResource(id)).thenReturn(testVxResource);
    Mockito.when(xUserMgr.updateXPermMap(permMap)).thenReturn(permMap);
    VXPermMap retVxGroup = xUserRest.updateXPermMap(permMap);
    assertEquals(permMap.getId(), retVxGroup.getId());
    assertEquals(permMap.getClass(), retVxGroup.getClass());
    assertNotNull(retVxGroup);
    Mockito.verify(xUserMgr).updateXPermMap(permMap);
    Mockito.verify(xResourceService).readResource(permMap.getResourceId());
}
Also used : VXPermMap(org.apache.ranger.view.VXPermMap) VXResource(org.apache.ranger.view.VXResource) Test(org.junit.Test)

Example 18 with VXPermMap

use of org.apache.ranger.view.VXPermMap in project ranger by apache.

the class TestXUserREST method test43createXPermMapNullVXResource.

@Test
public void test43createXPermMapNullVXResource() {
    VXPermMap permMap = testcreateXPermMap();
    permMap.setResourceId(null);
    Mockito.when(xUserMgr.createXPermMap(permMap)).thenReturn(permMap);
    VXResource testVxResource = new VXResource();
    Mockito.when(xResourceService.readResource(permMap.getResourceId())).thenReturn(testVxResource);
    VXPermMap retVxGroup = xUserRest.createXPermMap(permMap);
    assertEquals(permMap.getId(), retVxGroup.getId());
    assertEquals(permMap.getClass(), retVxGroup.getClass());
    assertNotNull(retVxGroup);
    Mockito.verify(xUserMgr).createXPermMap(permMap);
    Mockito.verify(xResourceService).readResource(permMap.getResourceId());
}
Also used : VXPermMap(org.apache.ranger.view.VXPermMap) VXResource(org.apache.ranger.view.VXResource) Test(org.junit.Test)

Example 19 with VXPermMap

use of org.apache.ranger.view.VXPermMap in project ranger by apache.

the class TestXUserREST method test39getXPermMapNotNull.

@Test
public void test39getXPermMapNotNull() throws Exception {
    VXPermMap permMap = testcreateXPermMap();
    Mockito.when(xUserMgr.getXPermMap(id)).thenReturn(permMap);
    VXResource testVxResource = new VXResource();
    Mockito.when(xResourceService.readResource(id)).thenReturn(testVxResource);
    VXPermMap retVxGroup = xUserRest.getXPermMap(id);
    assertEquals(permMap.getId(), retVxGroup.getId());
    assertEquals(permMap.getClass(), retVxGroup.getClass());
    assertNotNull(retVxGroup);
    Mockito.verify(xUserMgr).getXPermMap(id);
    Mockito.verify(xResourceService).readResource(id);
}
Also used : VXPermMap(org.apache.ranger.view.VXPermMap) VXResource(org.apache.ranger.view.VXResource) Test(org.junit.Test)

Example 20 with VXPermMap

use of org.apache.ranger.view.VXPermMap in project ranger by apache.

the class TestXUserREST method test40getXPermMapNull.

@Test
public void test40getXPermMapNull() {
    Mockito.when(xUserMgr.getXPermMap(id)).thenReturn(null);
    VXPermMap retVxGroup = xUserRest.getXPermMap(id);
    assertNull(retVxGroup);
    Mockito.verify(xUserMgr).getXPermMap(id);
}
Also used : VXPermMap(org.apache.ranger.view.VXPermMap) Test(org.junit.Test)

Aggregations

VXPermMap (org.apache.ranger.view.VXPermMap)25 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)10 HashMap (java.util.HashMap)7 List (java.util.List)6 VXResource (org.apache.ranger.view.VXResource)6 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)5 VXPermMapList (org.apache.ranger.view.VXPermMapList)5 VXPermObj (org.apache.ranger.view.VXPermObj)5 VXPolicyList (org.apache.ranger.view.VXPolicyList)5 Date (java.util.Date)4 SearchCriteria (org.apache.ranger.common.SearchCriteria)4 VXAuditMap (org.apache.ranger.view.VXAuditMap)4 LinkedHashMap (java.util.LinkedHashMap)3 Random (java.util.Random)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 RangerPolicyItemAccess (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess)3 VXAuditMapList (org.apache.ranger.view.VXAuditMapList)3 VXResourceList (org.apache.ranger.view.VXResourceList)3 Map (java.util.Map)2