Search in sources :

Example 1 with MessageEnums

use of org.apache.ranger.common.MessageEnums in project ranger by apache.

the class TestXUserREST method test50getXAuditMapVXAuditMapNull.

@Test
public void test50getXAuditMapVXAuditMapNull() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    Mockito.when(xUserMgr.getXAuditMap(testvXAuditMap.getResourceId())).thenReturn(testvXAuditMap);
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    VXAuditMap retVXAuditMap = xUserRest.getXAuditMap(testvXAuditMap.getResourceId());
    assertEquals(testvXAuditMap.getId(), retVXAuditMap.getId());
    assertEquals(testvXAuditMap.getClass(), retVXAuditMap.getClass());
    assertNotNull(retVXAuditMap);
    Mockito.verify(xUserMgr).getXAuditMap(testvXAuditMap.getResourceId());
    Mockito.verify(xResourceService).readResource(null);
    Mockito.verify(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()));
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) MessageEnums(org.apache.ranger.common.MessageEnums) VXAuditMap(org.apache.ranger.view.VXAuditMap) Test(org.junit.Test)

Example 2 with MessageEnums

use of org.apache.ranger.common.MessageEnums in project ranger by apache.

the class TestXUserREST method test54createXAuditMapVxResourceNull.

@Test
public void test54createXAuditMapVxResourceNull() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    testvXAuditMap.setResourceId(null);
    Mockito.when(xResourceService.readResource(testvXAuditMap.getResourceId())).thenReturn(null);
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    VXAuditMap retvXAuditMap = xUserRest.createXAuditMap(testvXAuditMap);
    assertEquals(testvXAuditMap.getId(), retvXAuditMap.getId());
    assertEquals(testvXAuditMap.getClass(), retvXAuditMap.getClass());
    assertNotNull(retvXAuditMap);
    Mockito.verify(xUserMgr).createXAuditMap(testvXAuditMap);
    Mockito.verify(xResourceService).readResource(testvXAuditMap.getResourceId());
    Mockito.verify(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()));
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) MessageEnums(org.apache.ranger.common.MessageEnums) VXAuditMap(org.apache.ranger.view.VXAuditMap) Test(org.junit.Test)

Example 3 with MessageEnums

use of org.apache.ranger.common.MessageEnums in project ranger by apache.

the class TestXUserREST method test57updateXAuditMapNull.

@Test
public void test57updateXAuditMapNull() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    VXAuditMap retvXAuditMap = xUserRest.updateXAuditMap(testvXAuditMap);
    assertNull(retvXAuditMap);
    Mockito.verify(xUserMgr).updateXAuditMap(testvXAuditMap);
    Mockito.verify(xResourceService).readResource(null);
    Mockito.verify(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()));
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) MessageEnums(org.apache.ranger.common.MessageEnums) VXAuditMap(org.apache.ranger.view.VXAuditMap) Test(org.junit.Test)

Aggregations

WebApplicationException (javax.ws.rs.WebApplicationException)3 MessageEnums (org.apache.ranger.common.MessageEnums)3 VXAuditMap (org.apache.ranger.view.VXAuditMap)3 Test (org.junit.Test)3