@Test public void testDoesPolicyExist() { final String resourceIdentifier1 = "resource1"; RangerPolicy.RangerPolicyResource resource1 = new RangerPolicy.RangerPolicyResource(resourceIdentifier1); final Map<String, RangerPolicy.RangerPolicyResource> policy1Resources = new HashMap<>(); policy1Resources.put(resourceIdentifier1, resource1); final RangerPolicy policy1 = new RangerPolicy(); policy1.setResources(policy1Resources); final String resourceIdentifier2 = "resource2"; RangerPolicy.RangerPolicyResource resource2 = new RangerPolicy.RangerPolicyResource(resourceIdentifier2); final Map<String, RangerPolicy.RangerPolicyResource> policy2Resources = new HashMap<>(); policy2Resources.put(resourceIdentifier2, resource2); final RangerPolicy policy2 = new RangerPolicy(); policy2.setResources(policy2Resources); final List<RangerPolicy> policies = new ArrayList<>(); policies.add(policy1); policies.add(policy2); final ServicePolicies servicePolicies = new ServicePolicies(); servicePolicies.setPolicies(policies); final RangerBasePluginWithPolicies pluginWithPolicies = new RangerBasePluginWithPolicies("nifi", "nifi"); pluginWithPolicies.setPolicies(servicePolicies); Assert.assertTrue(pluginWithPolicies.doesPolicyExist(resourceIdentifier1)); Assert.assertTrue(pluginWithPolicies.doesPolicyExist(resourceIdentifier2)); Assert.assertFalse(pluginWithPolicies.doesPolicyExist("resource3")); }
public boolean doesPolicyExist(String resourceIdentifier) { if (resourceIdentifier == null) { return false; } final Set<String> currResources = resources.get(); if (currResources == null) { return false; } else { return currResources.contains(resourceIdentifier); } }
RangerBasePluginWithPolicies extends RangerBasePlugin { public boolean doesPolicyExist(String resourceIdentifier) { if (resourceIdentifier == null) { return false; } final Set<String> currResources = resources.get(); if (currResources == null) { return false; } else { return currResources.contains(resourceIdentifier); } } }
RangerBasePluginWithPolicies extends RangerBasePlugin { public boolean doesPolicyExist(String resourceIdentifier) { if (resourceIdentifier == null) { return false; } final Set<String> currResources = resources.get(); if (currResources == null) { return false; } else { return currResources.contains(resourceIdentifier); } } RangerBasePluginWithPolicies(String serviceType, String appId); }
RangerBasePluginWithPolicies extends RangerBasePlugin { public boolean doesPolicyExist(String resourceIdentifier) { if (resourceIdentifier == null) { return false; } final Set<String> currResources = resources.get(); if (currResources == null) { return false; } else { return currResources.contains(resourceIdentifier); } } RangerBasePluginWithPolicies(String serviceType, String appId); @Override void setPolicies(ServicePolicies policies); boolean doesPolicyExist(String resourceIdentifier); }
RangerBasePluginWithPolicies extends RangerBasePlugin { public boolean doesPolicyExist(String resourceIdentifier) { if (resourceIdentifier == null) { return false; } final Set<String> currResources = resources.get(); if (currResources == null) { return false; } else { return currResources.contains(resourceIdentifier); } } RangerBasePluginWithPolicies(String serviceType, String appId); @Override void setPolicies(ServicePolicies policies); boolean doesPolicyExist(String resourceIdentifier);  }