### Question:
Dag implements Serializable { public Set<String> parentsOf(String stage) { return parentsOf(stage, ImmutableSet.<String>of()); } Dag(Collection<Connection> connections); protected  Dag(SetMultimap<String, String> outgoingConnections, SetMultimap<String, String> incomingConnections); protected  Dag(Dag other); Set<Dag> splitByControlNodes(Set<String> conditionNodes, Set<String> actionNodes); Set<String> getNodes(); Set<String> getSources(); Set<String> getSinks(); Set<String> getNodeOutputs(String node); Set<String> getNodeInputs(String node); Set<String> accessibleFrom(String stage); Set<String> accessibleFrom(String stage, Set<String> stopNodes); Set<String> accessibleFrom(Set<String> stages, Set<String> stopNodes); Set<String> parentsOf(String stage); Set<String> parentsOf(String stage, final Set<String> stopNodes); Dag subsetFrom(String stage); Dag subsetFrom(String stage, Set<String> stopNodes); Dag subsetFrom(Set<String> stages); Dag subsetFrom(Set<String> stages, Set<String> stopNodes); Dag subsetAround(String stage, Set<String> childStopNodes, Set<String> parentStopNodes); Dag createSubDag(Set<String> nodes); List<String> getTopologicalOrder(); List<String> getBranch(final String node, final Set<String> stopNodes); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testParentsOf() { Dag dag = new Dag(ImmutableSet.of( new Connection("n1", "n2"), new Connection("n2", "n4"), new Connection("n3", "n4"), new Connection("n4", "n8"), new Connection("n5", "n4"), new Connection("n5", "n6"), new Connection("n6", "n7"))); Assert.assertEquals(ImmutableSet.of("n1"), dag.parentsOf("n1")); Assert.assertEquals(ImmutableSet.of("n1", "n2"), dag.parentsOf("n2")); Assert.assertEquals(ImmutableSet.of("n3"), dag.parentsOf("n3")); Assert.assertEquals(ImmutableSet.of("n1", "n2", "n3", "n4", "n5"), dag.parentsOf("n4")); Assert.assertEquals(ImmutableSet.of("n5"), dag.parentsOf("n5")); Assert.assertEquals(ImmutableSet.of("n5", "n6"), dag.parentsOf("n6")); Assert.assertEquals(ImmutableSet.of("n5", "n6", "n7"), dag.parentsOf("n7")); Assert.assertEquals(ImmutableSet.of("n1", "n2", "n3", "n4", "n5", "n8"), dag.parentsOf("n8")); Assert.assertEquals(ImmutableSet.of("n1", "n2", "n3", "n4", "n5", "n8"), dag.parentsOf("n8", ImmutableSet.of("n6", "n7"))); Assert.assertEquals(ImmutableSet.of("n5", "n6", "n7"), dag.parentsOf("n7", ImmutableSet.of("n4"))); Assert.assertEquals(ImmutableSet.of("n6", "n7"), dag.parentsOf("n7", ImmutableSet.of("n5", "n6"))); Assert.assertEquals(ImmutableSet.of("n2", "n3", "n5", "n4", "n8"), dag.parentsOf("n8", ImmutableSet.of("n2", "n3"))); Assert.assertEquals(ImmutableSet.of("n2", "n3", "n4", "n5"), dag.parentsOf("n4", ImmutableSet.of("n2", "n3"))); }