### Question:
RangerServiceDefHelper { public boolean isResourceGraphValid() { return _delegate.isResourceGraphValid(); } RangerServiceDefHelper(RangerServiceDef serviceDef);  RangerServiceDefHelper(RangerServiceDef serviceDef, boolean useCache); Set<List<RangerResourceDef>> getResourceHierarchies(); Map<String, RangerResourceDef> getResorceMap(); Set<String> getMandatoryResourceNames(List<RangerResourceDef> hierarchy); Set<String> getAllResourceNames(List<RangerResourceDef> hierarchy); List<String> getAllResourceNamesOrdered(List<RangerResourceDef> hierarchy); boolean isResourceGraphValid();  }### Answer:
@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()); }