@Test public void test_getResourceSignature_happyPath() { RangerPolicy policy = null; PolicySerializer serializer = new PolicySerializer(policy); Assert.assertTrue("Null policy", serializer.toString() == ""); policy = mock(RangerPolicy.class); when(policy.getPolicyType()).thenReturn(null); Map<String, RangerPolicyResource> policyResources = _utils.createPolicyResourceMap(first); when(policy.getResources()).thenReturn(policyResources); when(policy.getZoneName()).thenReturn(null); serializer = new PolicySerializer(policy); String expectedVersion = "version=1"; String expectedType = "type=0"; String expectedResource = "{" + "col={values=[col1, col2, col3],excludes=false,recursive=true}, " + "db={values=[db1, db2],excludes=false,recursive=false}, " + "table={values=[tbl1, tbl2, tbl3],excludes=true,recursive=false}" + "}"; String serializationFormat = "{%s,%s,resource=%s}"; String expectedFull = String.format(serializationFormat, expectedVersion, expectedType, expectedResource); Assert.assertEquals(expectedFull, serializer.toString()); policyResources = _utils.createPolicyResourceMap(data_second); when(policy.getResources()).thenReturn(policyResources); Assert.assertEquals(expectedFull, serializer.toString()); when(policy.getPolicyType()).thenReturn(1); expectedType="type=1"; expectedFull = String.format(serializationFormat, expectedVersion, expectedType, expectedResource); Assert.assertEquals(expectedFull, serializer.toString()); }
@Override public String toString() { return String.format("%s: %s", _hash, _string); }
RangerPolicyResourceSignature { @Override public String toString() { return String.format("%s: %s", _hash, _string); } }
RangerPolicyResourceSignature { @Override public String toString() { return String.format("%s: %s", _hash, _string); } RangerPolicyResourceSignature(RangerPolicy policy);   RangerPolicyResourceSignature(String string); }
RangerPolicyResourceSignature { @Override public String toString() { return String.format("%s: %s", _hash, _string); } RangerPolicyResourceSignature(RangerPolicy policy);   RangerPolicyResourceSignature(String string); String getSignature(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString(); }
RangerPolicyResourceSignature { @Override public String toString() { return String.format("%s: %s", _hash, _string); } RangerPolicyResourceSignature(RangerPolicy policy);   RangerPolicyResourceSignature(String string); String getSignature(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString();  }