use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TestTagREST method test18createTag.
@Test
public void test18createTag() {
RangerTag oldTag = new RangerTag();
RangerTag newTag = new RangerTag();
oldTag.setId(id);
newTag.setId(id);
newTag.setVersion(5L);
try {
Mockito.when(validator.preCreateTag(oldTag)).thenReturn(oldTag);
} catch (Exception e) {
}
try {
Mockito.doNothing().when(validator).preUpdateTag(oldTag.getId(), oldTag);
} catch (Exception e1) {
}
try {
Mockito.when(tagStore.updateTag(oldTag)).thenReturn(newTag);
} catch (Exception e) {
}
RangerTag rangerTag = tagREST.createTag(oldTag, true);
Assert.assertEquals(rangerTag.getVersion(), newTag.getVersion());
Assert.assertNotNull(newTag.getVersion());
Assert.assertNotEquals(oldTag.getVersion(), newTag.getVersion());
Assert.assertEquals(oldTag.getId(), newTag.getId());
try {
Mockito.verify(validator).preCreateTag(oldTag);
} catch (Exception e) {
}
try {
Mockito.verify(validator).preUpdateTag(oldTag.getId(), oldTag);
} catch (Exception e1) {
}
try {
Mockito.verify(tagStore).updateTag(oldTag);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TestTagREST method test24getTagByGuid.
@Test
public void test24getTagByGuid() {
RangerTag oldTag = new RangerTag();
oldTag.setId(id);
oldTag.setGuid(gId);
try {
Mockito.when(tagStore.getTagByGuid(gId)).thenReturn(oldTag);
} catch (Exception e) {
}
RangerTag rangerTag = tagREST.getTagByGuid(gId);
Assert.assertNotNull(oldTag.getGuid());
Assert.assertEquals(rangerTag.getGuid(), oldTag.getGuid());
Assert.assertEquals(rangerTag.getId(), oldTag.getId());
Assert.assertNotNull(rangerTag.getId());
try {
Mockito.verify(tagStore).getTagByGuid(gId);
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TestTagREST method test26getAllTags.
@Test
public void test26getAllTags() {
List<RangerTag> ret = new ArrayList<RangerTag>();
RangerTag rangerTag = new RangerTag();
rangerTag.setId(id);
rangerTag.setGuid(gId);
ret.add(rangerTag);
try {
Mockito.when(tagStore.getTags((SearchFilter) Mockito.any())).thenReturn(ret);
} catch (Exception e) {
}
List<RangerTag> result = tagREST.getAllTags();
Assert.assertEquals(result.get(0).getId(), ret.get(0).getId());
Assert.assertEquals(result.get(0).getVersion(), ret.get(0).getVersion());
Assert.assertNotNull(result.get(0).getId());
try {
Mockito.verify(tagStore).getTags((SearchFilter) Mockito.any());
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TestTagREST method test22deleteTagByGuid.
@Test
public void test22deleteTagByGuid() {
RangerTag oldTag = new RangerTag();
oldTag.setId(id);
oldTag.setGuid(gId);
try {
Mockito.when(validator.preDeleteTagByGuid(gId)).thenReturn(oldTag);
} catch (Exception e) {
}
try {
Mockito.doNothing().when(tagStore).deleteTag(oldTag.getId());
} catch (Exception e) {
}
tagREST.deleteTagByGuid(gId);
Assert.assertNotNull(oldTag.getId());
Assert.assertNotNull(oldTag.getGuid());
try {
Mockito.verify(validator).preDeleteTagByGuid(gId);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).deleteTag(oldTag.getId());
} catch (Exception e) {
}
}
use of org.apache.ranger.plugin.model.RangerTag in project ranger by apache.
the class TestTagREST method test20updateTagByGuid.
@Test
public void test20updateTagByGuid() {
RangerTag oldTag = new RangerTag();
RangerTag newTag = new RangerTag();
oldTag.setGuid(gId);
newTag.setGuid(gId);
newTag.setVersion(5L);
try {
Mockito.doNothing().when(validator).preUpdateTagByGuid(gId, oldTag);
} catch (Exception e) {
}
try {
Mockito.when(tagStore.updateTag(oldTag)).thenReturn(newTag);
} catch (Exception e) {
}
RangerTag rangerTag = tagREST.updateTagByGuid(gId, oldTag);
Assert.assertEquals(oldTag.getGuid(), newTag.getGuid());
Assert.assertNotEquals(rangerTag.getVersion(), oldTag.getVersion());
Assert.assertEquals(rangerTag.getVersion(), newTag.getVersion());
try {
Mockito.verify(validator).preUpdateTagByGuid(gId, oldTag);
} catch (Exception e) {
}
try {
Mockito.verify(tagStore).updateTag(oldTag);
} catch (Exception e) {
}
}
Aggregations