use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.
the class TestTagREST method test38createTagResourceMap.
@Test
public void test38createTagResourceMap() {
RangerTagResourceMap oldTagResourceMap = null;
RangerTagResourceMap newTagResourceMap = new RangerTagResourceMap();
newTagResourceMap.setTagId(id);
newTagResourceMap.setResourceId(id);
try {
Mockito.when(tagStore.getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid)).thenReturn(oldTagResourceMap);
} catch (Exception e) {
}
try {
Mockito.when(validator.preCreateTagResourceMap(tagGuid, resourceGuid)).thenReturn(newTagResourceMap);
} catch (Exception e) {
}
try {
Mockito.when(tagStore.createTagResourceMap(newTagResourceMap)).thenReturn(newTagResourceMap);
} catch (Exception e) {
}
RangerTagResourceMap rangerTagResourceMap = tagREST.createTagResourceMap(tagGuid, resourceGuid, false);
Assert.assertEquals(rangerTagResourceMap.getTagId(), newTagResourceMap.getTagId());
Assert.assertEquals(rangerTagResourceMap.getResourceId(), newTagResourceMap.getResourceId());
try {
Mockito.verify(tagStore).getTagResourceMapForTagAndResourceGuid(tagGuid, resourceGuid);
} catch (Exception e) {
}
try {
Mockito.verify(validator).preCreateTagResourceMap(tagGuid, resourceGuid);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).createTagResourceMap(newTagResourceMap);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerTagResourceMap in project ranger by apache.
the class TestTagREST method test42deleteTagResourceMapByGuid.
@Test
public void test42deleteTagResourceMapByGuid() {
RangerTagResourceMap oldTagResourceMap = new RangerTagResourceMap();
oldTagResourceMap.setId(id);
oldTagResourceMap.setGuid(gId);
try {
Mockito.when(validator.preDeleteTagResourceMapByGuid(gId)).thenReturn(oldTagResourceMap);
} catch (Exception e) {
}
try {
Mockito.doNothing().when(tagStore).deleteServiceResource(oldTagResourceMap.getId());
} catch (Exception e) {
}
tagREST.deleteTagResourceMapByGuid(gId);
Assert.assertNotNull(oldTagResourceMap.getId());
Assert.assertNotNull(oldTagResourceMap.getGuid());
try {
Mockito.verify(validator).preDeleteTagResourceMapByGuid(gId);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).deleteServiceResource(oldTagResourceMap.getId());
} catch (Exception e) {
}
}
Aggregations