PathAnalyzer { public Analysis analyze() throws Exception { AtomicReference<String> error = new AtomicReference<String>(null); Map<String, PathComplete> loadedPaths = loadedPaths(paths, error); if ( error.get() != null ) { return new Analysis(error.get(), Lists.<PathComplete>newArrayList(), Lists.<Set<String>>newArrayList()); } List<Node> resourceAllocationGraph = buildResourceAllocationGraph(loadedPaths); List<Set<String>> possibleCycles = checkForCycles(resourceAllocationGraph, loadedPaths); return new Analysis(null, loadedPaths.values(), possibleCycles); } PathAnalyzer(Exhibitor exhibitor, List<PathAndMax> paths); Analysis analyze();  }
@Test public void testBasic() throws Exception { final Map<PathAndMax, List<String>> data = Maps.newHashMap(); data.put(new PathAndMax("/r1", 1), Arrays.asList("p1-0001", "p2-0002")); data.put(new PathAndMax("/r2", 1), Arrays.asList("p4-0001", "p1-0002")); data.put(new PathAndMax("/r3", 1), Arrays.asList("p2-0001", "p5-0002")); data.put(new PathAndMax("/r4", 1), Arrays.asList("p2-0001", "p3-0002")); data.put(new PathAndMax("/r5", 1), Arrays.asList("p3-0001", "p4-0002")); Exhibitor mockExhibitor = Mockito.mock(Exhibitor.class); PathAnalyzer pathAnalyzer = new PathAnalyzer(mockExhibitor, Lists.newArrayList(data.keySet())) { @Override protected List<String> getChildren(String path) throws Exception { List<String> l = data.get(new PathAndMax(path, 0)); return (l != null) ? l : Lists.<String>newArrayList(); } @Override protected String getId(String fullPath) throws Exception { return fullPath.substring(4, 6); } }; Analysis analysis = pathAnalyzer.analyze(); System.out.println("Details:"); System.out.println(analysis.getCompleteData()); System.out.println(); System.out.println("Cycles:"); System.out.println(analysis.getPossibleCycles()); }