### Question:
PrintVertex extends VertexImpl<T, GenericVertex<T>> implements GenericVertex<T>, NonProbabilistic<T> { public static <T> T print(T parentValue, String message, boolean printData) { final String dataOutput = printData ? parentValue.toString() + "\n" : ""; printStream.print(message + dataOutput); return parentValue; } @ExportVertexToPythonBindings  PrintVertex(@LoadVertexParam(PARENT) Vertex<T, ?> parent,
                       @LoadVertexParam(MESSAGE) final String message,
                       @LoadVertexParam(PRINT_DATA) boolean printData);  PrintVertex(Vertex<T, ?> parent); static void setPrintStream(PrintStream printStream); @Override T calculate(); static T print(T parentValue, String message, boolean printData); @SaveVertexParam(PARENT) Vertex<T, ?> getParent(); @SaveVertexParam(MESSAGE) String getMessage(); @SaveVertexParam(PRINT_DATA) boolean getPrintData();  }### Answer:
@Test public void whenRunningMetropolisHastingsThenSamplesArePrinted() { final DoubleVertex temperature = new UniformVertex(20., 30.); new PrintVertex<>(temperature); KeanuProbabilisticModel model = new KeanuProbabilisticModel(temperature.getConnectedGraph()); final int nSamples = 100; MetropolisHastings .withDefaultConfig() .getPosteriorSamples(model, model.getLatentVariables(), nSamples); verify(printStream, atLeast(nSamples)).print(anyString()); }
@Test public void whenPrintIsCalledAddsPrintVertexAsChild() { final UniformVertex A = new UniformVertex(0, 1); A.print(); final Vertex printVertex = Iterables.getOnlyElement(A.getChildren()); assertThat(printVertex, instanceOf(PrintVertex.class)); }