use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test48deleteServiceResourceByGuid.
@Test
public void test48deleteServiceResourceByGuid() {
RangerServiceResource oldRSR = new RangerServiceResource();
oldRSR.setId(id);
oldRSR.setGuid(gId);
List<RangerTagResourceMap> tagResourceMaps = new ArrayList<RangerTagResourceMap>();
RangerTagResourceMap rangerTagResourceMap = new RangerTagResourceMap();
rangerTagResourceMap.setId(id);
rangerTagResourceMap.setTagId(id);
tagResourceMaps.add(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) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test31deleteServiceResource.
@Test
public void test31deleteServiceResource() {
RangerServiceResource oldSRS = new RangerServiceResource();
oldSRS.setId(id);
try {
Mockito.when(validator.preDeleteServiceResource(id)).thenReturn(oldSRS);
} catch (Exception e) {
}
try {
Mockito.doNothing().when(tagStore).deleteServiceResource(id);
} catch (Exception e) {
}
tagREST.deleteServiceResource(id);
Assert.assertNotNull(oldSRS.getId());
try {
Mockito.verify(validator).preDeleteServiceResource(id);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).deleteServiceResource(id);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test28createServiceResource.
@Test
public void test28createServiceResource() {
RangerServiceResource oldRSR = new RangerServiceResource();
RangerServiceResource newRSR = new RangerServiceResource();
oldRSR.setId(id);
newRSR.setId(id);
newRSR.setVersion(5L);
try {
Mockito.when(validator.preCreateServiceResource(oldRSR)).thenReturn(oldRSR);
} catch (Exception e) {
}
try {
Mockito.doNothing().when(validator).preUpdateServiceResource(oldRSR.getId(), oldRSR);
} catch (Exception e) {
}
try {
Mockito.when(tagStore.updateServiceResource(oldRSR)).thenReturn(newRSR);
} catch (Exception e) {
}
RangerServiceResource rangerServiceResource = tagREST.createServiceResource(oldRSR, true);
Assert.assertNotEquals(oldRSR.getVersion(), newRSR.getVersion());
Assert.assertEquals(rangerServiceResource.getId(), newRSR.getId());
Assert.assertEquals(rangerServiceResource.getId(), oldRSR.getId());
try {
Mockito.verify(validator).preCreateServiceResource(oldRSR);
} catch (Exception e) {
}
try {
Mockito.verify(validator).preUpdateServiceResource(oldRSR.getId(), oldRSR);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).updateServiceResource(oldRSR);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test34getServiceResourcesByService.
@Test
public void test34getServiceResourcesByService() {
List<RangerServiceResource> ret = new ArrayList<RangerServiceResource>();
RangerServiceResource rangerServiceResource = new RangerServiceResource();
rangerServiceResource.setId(id);
rangerServiceResource.setServiceName(serviceName);
ret.add(rangerServiceResource);
try {
Mockito.when(tagStore.getServiceResourcesByService(serviceName)).thenReturn(ret);
} catch (Exception e) {
}
List<RangerServiceResource> reslut = tagREST.getServiceResourcesByService(serviceName);
Assert.assertNotNull(reslut.get(0).getId());
Assert.assertEquals(reslut.get(0).getId(), ret.get(0).getId());
Assert.assertEquals(reslut.get(0).getServiceName(), ret.get(0).getServiceName());
try {
Mockito.verify(tagStore).getServiceResourcesByService(serviceName);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test33getServiceResourceByGuid.
@Test
public void test33getServiceResourceByGuid() {
RangerServiceResource oldSRS = new RangerServiceResource();
oldSRS.setId(id);
oldSRS.setGuid(gId);
try {
Mockito.when(tagStore.getServiceResourceByGuid(gId)).thenReturn(oldSRS);
} catch (Exception e) {
}
RangerServiceResource rangerServiceResource = tagREST.getServiceResourceByGuid(gId);
Assert.assertNotNull(rangerServiceResource);
Assert.assertEquals(rangerServiceResource.getGuid(), oldSRS.getGuid());
Assert.assertEquals(rangerServiceResource.getId(), oldSRS.getId());
try {
Mockito.verify(tagStore).getServiceResourceByGuid(gId);
} catch (Exception e) {
}
}
Aggregations