use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test29createServiceResource.
@Test
public void test29createServiceResource() {
RangerServiceResource oldRSR = new RangerServiceResource();
try {
Mockito.when(validator.preCreateServiceResource(oldRSR)).thenReturn(oldRSR);
} catch (Exception e) {
}
Mockito.when(restErrorUtil.createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
tagREST.createServiceResource(oldRSR, false);
try {
Mockito.verify(validator).preCreateServiceResource(oldRSR);
} catch (Exception e) {
}
Mockito.verify(restErrorUtil).createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean());
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test36getServiceResourceByServiceAndResourceSignature.
@Test
public void test36getServiceResourceByServiceAndResourceSignature() {
RangerServiceResource oldSRS = new RangerServiceResource();
oldSRS.setId(id);
oldSRS.setResourceSignature(resourceSignature);
oldSRS.setServiceName(serviceName);
try {
Mockito.when(tagStore.getServiceResourceByServiceAndResourceSignature(serviceName, resourceSignature)).thenReturn(oldSRS);
} catch (Exception e) {
}
RangerServiceResource rangerServiceResource = tagREST.getServiceResourceByServiceAndResourceSignature(serviceName, resourceSignature);
Assert.assertEquals(rangerServiceResource.getId(), oldSRS.getId());
Assert.assertEquals(rangerServiceResource.getServiceName(), oldSRS.getServiceName());
Assert.assertEquals(rangerServiceResource.getResourceSignature(), oldSRS.getResourceSignature());
try {
Mockito.verify(tagStore).getServiceResourceByServiceAndResourceSignature(serviceName, resourceSignature);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test32getServiceResource.
@Test
public void test32getServiceResource() {
RangerServiceResource oldSRS = new RangerServiceResource();
oldSRS.setId(id);
oldSRS.setGuid(gId);
try {
Mockito.when(tagStore.getServiceResource(id)).thenReturn(oldSRS);
} catch (Exception e) {
}
RangerServiceResource rangerServiceResource = tagREST.getServiceResource(id);
Assert.assertNotNull(rangerServiceResource);
Assert.assertEquals(rangerServiceResource.getId(), oldSRS.getId());
Assert.assertEquals(rangerServiceResource.getGuid(), oldSRS.getGuid());
try {
Mockito.verify(tagStore).getServiceResource(id);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test37getAllServiceResources.
@Test
public void test37getAllServiceResources() {
List<RangerServiceResource> ret = new ArrayList<RangerServiceResource>();
RangerServiceResource rangerServiceResource = new RangerServiceResource();
rangerServiceResource.setId(id);
rangerServiceResource.setServiceName(serviceName);
ret.add(rangerServiceResource);
try {
Mockito.when(tagStore.getServiceResources((SearchFilter) Mockito.any())).thenReturn(ret);
} catch (Exception e) {
}
List<RangerServiceResource> result = tagREST.getAllServiceResources();
Assert.assertNotNull(result.get(0).getId());
Assert.assertEquals(result.get(0).getId(), ret.get(0).getId());
Assert.assertEquals(result.get(0).getServiceName(), ret.get(0).getServiceName());
try {
Mockito.verify(tagStore).getServiceResources((SearchFilter) Mockito.any());
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource 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) {
}
}
Aggregations