use of org.apache.ranger.plugin.model.RangerPolicyResourceSignature.ResourceSerializer in project ranger by apache.
the class TestRangerPolicyResourceSignature method test_RangerPolicyResourceView_toString.
@Test
public void test_RangerPolicyResourceView_toString() {
// null resource
RangerPolicyResource resource = null;
ResourceSerializer serializer = new ResourceSerializer(resource);
Assert.assertEquals("{}", serializer.toString());
// non-null policy resource with null values/recursive flag
resource = createPolicyResource(null, null, null);
serializer = new ResourceSerializer(resource);
Assert.assertEquals("{values=,excludes=false,recursive=false}", serializer.toString());
// valid values in non-asending order
resource = createPolicyResource(new String[] { "b", "a", "d", "c" }, true, false);
serializer = new ResourceSerializer(resource);
Assert.assertEquals("{values=[a, b, c, d],excludes=false,recursive=true}", serializer.toString());
// recursive flag is false and different variation of values to show lexicographic ordering
resource = createPolicyResource(new String[] { "9", "A", "e", "_" }, false, true);
serializer = new ResourceSerializer(resource);
Assert.assertEquals("{values=[9, A, _, e],excludes=true,recursive=false}", serializer.toString());
}
Aggregations