use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestKafkaResourceMapper method testKafkaResourceFromMissingAttribs.
@Test
public void testKafkaResourceFromMissingAttribs() throws Exception {
Map<String, Object> entAttribs = new HashMap<String, Object>();
RangerAtlasEntity entity = getKafkaTopicEntity(entAttribs);
try {
RangerServiceResource resource = resourceMapper.buildResource(entity);
Assert.fail("expected exception. Found " + resource);
} catch (Exception excp) {
// ignore
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test27createServiceResource.
@Test
public void test27createServiceResource() {
RangerServiceResource oldRSR = null;
RangerServiceResource newRSR = new RangerServiceResource();
newRSR.setId(id);
newRSR.setGuid(gId);
try {
Mockito.when(validator.preCreateServiceResource(oldRSR)).thenReturn(oldRSR);
} catch (Exception e) {
}
try {
Mockito.when(tagStore.createServiceResource(oldRSR)).thenReturn(newRSR);
} catch (Exception e) {
}
RangerServiceResource rangerServiceResource = tagREST.createServiceResource(oldRSR, false);
Assert.assertNotNull(rangerServiceResource.getId());
Assert.assertEquals(rangerServiceResource.getId(), newRSR.getId());
Assert.assertEquals(rangerServiceResource.getGuid(), newRSR.getGuid());
try {
Mockito.verify(validator).preCreateServiceResource(oldRSR);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).createServiceResource(oldRSR);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test49deleteServiceResourceByGuid.
@Test
public void test49deleteServiceResourceByGuid() {
RangerServiceResource oldRSR = new RangerServiceResource();
oldRSR.setId(id);
oldRSR.setGuid(gId);
try {
Mockito.when(validator.preDeleteServiceResourceByGuid(gId, false)).thenReturn(oldRSR);
} catch (Exception e) {
}
try {
Mockito.doNothing().when(tagStore).deleteServiceResource(oldRSR.getId());
} catch (Exception e) {
}
tagREST.deleteServiceResourceByGuid(gId, false);
try {
Mockito.verify(validator).preDeleteServiceResourceByGuid(gId, false);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test30updateServiceResourceByGuid.
@Test
public void test30updateServiceResourceByGuid() {
RangerServiceResource oldSRS = new RangerServiceResource();
RangerServiceResource newSRS = new RangerServiceResource();
oldSRS.setId(id);
oldSRS.setGuid(gId);
newSRS.setId(id);
newSRS.setGuid(gId);
newSRS.setVersion(5L);
try {
Mockito.doNothing().when(validator).preUpdateServiceResourceByGuid(gId, oldSRS);
} catch (Exception e) {
}
try {
Mockito.when(tagStore.updateServiceResource(oldSRS)).thenReturn(newSRS);
} catch (Exception e) {
}
RangerServiceResource rangerServiceResource = tagREST.updateServiceResourceByGuid(gId, oldSRS);
Assert.assertEquals(oldSRS.getId(), newSRS.getId());
Assert.assertEquals(oldSRS.getGuid(), newSRS.getGuid());
Assert.assertNotEquals(oldSRS.getVersion(), newSRS.getVersion());
Assert.assertEquals(rangerServiceResource.getVersion(), newSRS.getVersion());
try {
Mockito.verify(validator).preUpdateServiceResourceByGuid(gId, oldSRS);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).updateServiceResource(oldSRS);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerServiceResource in project ranger by apache.
the class TestTagREST method test35getServiceResourcesByService.
@Test
public void test35getServiceResourcesByService() {
List<RangerServiceResource> oldSRS = new ArrayList<RangerServiceResource>();
RangerServiceResource rangerServiceResource = new RangerServiceResource();
rangerServiceResource.setId(id);
rangerServiceResource.setServiceName(serviceName);
oldSRS.add(rangerServiceResource);
try {
Mockito.when(tagStore.getServiceResourcesByService(serviceName)).thenReturn(oldSRS);
} catch (Exception e) {
}
List<RangerServiceResource> result = tagREST.getServiceResourcesByService(serviceName);
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 1);
Assert.assertEquals(result.get(0).getId(), id);
Assert.assertEquals(result.get(0).getServiceName(), serviceName);
try {
Mockito.verify(tagStore).getServiceResourcesByService(serviceName);
} catch (Exception e) {
}
}
Aggregations