### Question:
Graph { public Collection<Edge> getEdgesBySource(String iri, boolean includeParentRelations) { Collection<Edge> ret; if (edges != null) { ret = edges.stream() .filter(e -> iri.equals(e.getSource())) .filter(e -> includeParentRelations || !e.isChildRelation()) .collect(Collectors.toList()); } else { ret = Collections.emptyList(); } return ret; } Graph(@JsonProperty("nodes") List<Node> nodes, @JsonProperty("edges") List<Edge> edges); List<Node> getNodes(); List<Edge> getEdges(); Collection<Edge> getEdgesBySource(String iri, boolean includeParentRelations);  }### Answer:
@Test public void getEdgesBySource_nullEdges() throws Exception { Graph graph = new Graph(null, null); Collection<Edge> edges = graph.getEdgesBySource("http: assertNotNull(edges); assertEquals(0, edges.size()); }
@Test public void getEdgesBySource_badSource() throws Exception { Graph graph = new Graph(null, Collections.emptyList()); Collection<Edge> edges = graph.getEdgesBySource("http: assertNotNull(edges); assertEquals(0, edges.size()); }
@Test public void getEdgesBySource_includeChildren() throws Exception { Graph graph = readGraphFromFile(GRAPH_FILE); Collection<Edge> edges = graph.getEdgesBySource("http: assertNotNull(edges); assertEquals(4, edges.size()); }
@Test public void getEdgesBySource_ignoreChildren() throws Exception { Graph graph = readGraphFromFile(GRAPH_FILE); List<Edge> edges = new ArrayList<>(graph.getEdgesBySource("http: assertNotNull(edges); assertEquals(1, edges.size()); assertEquals("has_disease_location", edges.get(0).getLabel()); }