### Question:
ForwardSampler implements SamplingAlgorithm { @Override public void sample(Map<VariableReference, List<?>> samples, List<Double> logOfMasterPForEachSample) { step(); takeSamples(samples, variablesToSampleFrom); double logProb = calculateSampleProbability ? network.getLogOfMasterP() : LOG_PROB_OF_PRIOR; logOfMasterPForEachSample.add(logProb); } ForwardSampler(BayesianNetwork network, List<? extends Variable> variablesToSampleFrom, List<Vertex> topologicallySortedVertices, KeanuRandom random, boolean calculateSampleProbability); @Override void step(); @Override void sample(Map<VariableReference, List<?>> samples, List<Double> logOfMasterPForEachSample); @Override NetworkSample sample();  }### Answer:
@Test public void nonProbabilisticVerticesAreRecomputedDuringForwardSample() { GaussianVertex A = mock(GaussianVertex.class); NonProbabilisticVertex B = mock(NonProbabilisticVertex.class); when(A.getChildren()).thenReturn(Collections.singleton(B)); when(A.getId()).thenReturn(new VertexId()); when(A.sample()).thenReturn(DoubleTensor.scalar(1.)); when(A.getConnectedGraph()).thenReturn(new HashSet<>(Arrays.asList(A, B))); when(B.getId()).thenReturn(new VertexId()); when(B.calculate()).thenReturn(DoubleTensor.scalar(0.)); ProbabilisticModel model = new KeanuProbabilisticModel(Arrays.asList(A, B)); Keanu.Sampling.Forward.withDefaultConfig(random).getPosteriorSamples(model, Arrays.asList(A, B), 20); verify(B, times(20)).setValue(DoubleTensor.scalar(0.)); }