### Question:
DepthFirstAnalysis { public Collection<Edge> getEdges(int type) { Collection<Edge> typed = null; for (Object node : _graph.getNodes()) { for (Edge edge : _graph.getEdgesFrom(node)) { if (edge.getType() == type) { if (typed == null) typed = new ArrayList<>(); typed.add(edge); } } } if(typed == null ) { typed = Collections.emptyList(); } return typed; } DepthFirstAnalysis(Graph graph); void setNodeComparator(Comparator<Object> comp); List<Object> getSortedNodes(); Collection<Edge> getEdges(int type); int getFinishedTime(Object node); boolean hasNoCycles();  }### Answer:
@Test public void testEdgeTyping() { Collection edges = _dfa.getEdges(Edge.TYPE_BACK); assertEquals(2, edges.size()); Iterator itr = edges.iterator(); Edge edge0 = (Edge) itr.next(); Edge edge1 = (Edge) itr.next(); assertTrue((edge0.getTo().equals(edge0.getFrom())) || edge1.getTo().equals(edge1.getFrom())); }
@Test public void testBackEdges() { setUpGraph2(); Collection edges = _dfa.getEdges(Edge.TYPE_BACK); assertEquals(2, edges.size()); Iterator itr = edges.iterator(); Edge edge0 = (Edge) itr.next(); Edge edge1 = (Edge) itr.next(); if (edge0.getTo().equals(edge0.getFrom())) { assertTrue(edge0.getCycle() != null && edge0.getCycle().size() == 1); List cycle = edge1.getCycle(); assertTrue(cycle != null && cycle.size() == 4); assertTrue(((Edge)cycle.get(0)).getFrom().equals( ((Edge)cycle.get(3)).getTo())); } else if (edge1.getTo().equals(edge1.getFrom())) { assertTrue(edge1.getCycle() != null && edge1.getCycle().size() == 1); assertTrue(edge1 == edge1.getCycle()); List cycle = edge0.getCycle(); assertTrue(cycle != null && cycle.size() == 4); assertTrue(((Edge)cycle.get(0)).getFrom().equals( ((Edge)cycle.get(3)).getTo())); } else { assertFalse(true); } }
@Test public void testForwardEdges() { setUpGraph2(); Collection edges = _dfa.getEdges(Edge.TYPE_FORWARD); assertEquals(2, edges.size()); Iterator itr = edges.iterator(); Edge edge0 = (Edge) itr.next(); Edge edge1 = (Edge) itr.next(); if (edge0.getCycle() == null) { List cycle = edge1.getCycle(); assertTrue(cycle != null && cycle.size() == 3); assertTrue(((Edge)cycle.get(0)).getFrom().equals( ((Edge)cycle.get(2)).getTo())); } else if (edge1.getCycle() == null) { List cycle = edge0.getCycle(); assertTrue(cycle != null && cycle.size() == 3); assertTrue(((Edge)cycle.get(0)).getFrom().equals( ((Edge)cycle.get(2)).getTo())); } else { assertFalse(true); } }