Search in sources :

Example 1 with ResourceSerializer

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());
}
Also used : RangerPolicyResource(org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource) ResourceSerializer(org.apache.ranger.plugin.model.RangerPolicyResourceSignature.ResourceSerializer) Test(org.junit.Test)

Aggregations

RangerPolicyResource (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource)1 ResourceSerializer (org.apache.ranger.plugin.model.RangerPolicyResourceSignature.ResourceSerializer)1 Test (org.junit.Test)1