### Question:
TransitiveClosure { public static TransitiveClosure getUpstreamVerticesForCollection(List<Vertex> vertices, boolean includeNonProbabilistic) { Predicate<Vertex> shouldAdd = includeNonProbabilistic ? ADD_ALL : PROBABILISTIC_OR_OBSERVED_ONLY; Set<Vertex> upstreamVertices = getVertices( vertices, Vertex::getParents, v -> false, shouldAdd ); return new TransitiveClosure(upstreamVertices); } private  TransitiveClosure(Set<Vertex> allVertices); static TransitiveClosure getUpstreamVertices(Vertex<?, ?> aVertex, boolean includeNonProbabilistic); static TransitiveClosure getDownstreamVertices(Vertex<?, ?> aVertex, boolean includeNonProbabilistic); static TransitiveClosure getUpstreamVerticesForCollection(List<Vertex> vertices, boolean includeNonProbabilistic); static TransitiveClosure getDownstreamVerticesForCollection(List<Vertex> vertices, boolean includeNonProbabilistic);  }### Answer:
@Test public void doesGetUpstreamProbabilisticVerticesOfCollection() { TransitiveClosure transitiveClosure = TransitiveClosure.getUpstreamVerticesForCollection(Arrays.asList(C, cSigma), false); assertThat(transitiveClosure.getLatentAndObservedVertices(), containsInAnyOrder(A, B, C)); }
@Test public void doesGetAllUpstreamVerticesOfCollection() { TransitiveClosure transitiveClosure = TransitiveClosure.getUpstreamVerticesForCollection(Arrays.asList(C, cSigma), true); assertThat(transitiveClosure.getAllVertices(), containsInAnyOrder(Amu, Asigma, Bmu, Bsigma, A, B, aPlusB, cSigma, C)); }