RangerServiceDefHelper { public boolean isResourceGraphValid() { return _delegate.isResourceGraphValid(); } RangerServiceDefHelper(RangerServiceDef serviceDef);  RangerServiceDefHelper(RangerServiceDef serviceDef, boolean useCache);  RangerServiceDefHelper(RangerServiceDef serviceDef, boolean useCache, boolean checkForCycles); static RangerServiceDef getServiceDefForPolicyFiltering(RangerServiceDef serviceDef); static Map<String, String> getFilterResourcesForAncestorPolicyFiltering(RangerServiceDef serviceDef, Map<String, String> filterResources); RangerServiceDef getServiceDef(); void patchServiceDefWithDefaultValues(); Set<List<RangerResourceDef>> getResourceHierarchies(Integer policyType); Set<List<RangerResourceDef>> filterHierarchies_containsOnlyMandatoryResources(Integer policyType); Set<List<RangerResourceDef>> getResourceHierarchies(Integer policyType, Collection<String> keys); boolean hierarchyHasAllResources(List<RangerResourceDef> hierarchy, Collection<String> resourceNames); Set<String> getMandatoryResourceNames(List<RangerResourceDef> hierarchy); Set<String> getAllResourceNames(List<RangerResourceDef> hierarchy); List<String> getAllResourceNamesOrdered(List<RangerResourceDef> hierarchy); boolean isResourceGraphValid();  }
@Test public final void test_isResourceGraphValid_detectCycle() { RangerResourceDef A = createResourceDef("A", "D"); RangerResourceDef B = createResourceDef("B", "C"); RangerResourceDef C = createResourceDef("C", "D"); RangerResourceDef D = createResourceDef("D", "A"); List<RangerResourceDef> resourceDefs = Lists.newArrayList(A, B, C, D); when(_serviceDef.getResources()).thenReturn(resourceDefs); _helper = new RangerServiceDefHelper(_serviceDef); assertFalse("Graph was valid!", _helper.isResourceGraphValid()); }
@Test public void test_invalid_resourceHierarchies_with_leaf_specification() { RangerResourceDef Database = createResourceDef("Database", "", false); RangerResourceDef UDF = createResourceDef("UDF", "Database"); RangerResourceDef Table = createResourceDef("Table", "Database", true); RangerResourceDef Column = createResourceDef("Column", "Table", false); RangerResourceDef Table_Attribute = createResourceDef("Table-Attribute", "Table", true); List<RangerResourceDef> resourceDefs = Lists.newArrayList(Column, Database, Table, Table_Attribute, UDF); when(_serviceDef.getResources()).thenReturn(resourceDefs); _helper = new RangerServiceDefHelper(_serviceDef); assertFalse(_helper.isResourceGraphValid()); }