### Question:
TextMessaging { public static TextMessagingResults run() { final TextMessagingData data = ReadCsv.fromResources("text_messaging_data.csv") .asVectorizedColumnsDefinedBy(TextMessagingData.class) .load(); final int numberOfDays = (int) data.numberOfMessages.getLength(); final double alpha = 10; ExponentialVertex earlyRate = new ExponentialVertex(alpha); ExponentialVertex lateRate = new ExponentialVertex(alpha); UniformIntVertex switchPoint = new UniformIntVertex(0, numberOfDays); IntegerVertex days = ConstantVertex.of(data.day); DoubleVertex rateForDay = If.isTrue(new GreaterThanVertex<>(switchPoint, days)) .then(earlyRate) .orElse(lateRate); PoissonVertex textsForDay = new PoissonVertex(rateForDay); textsForDay.observe(data.numberOfMessages); BayesianNetwork net = new BayesianNetwork(textsForDay.getConnectedGraph()); net.probeForNonZeroProbability(1000); KeanuProbabilisticModel model = new KeanuProbabilisticModel(net); final int numSamples = 1000; NetworkSamples posteriorSamples = Keanu.Sampling.MetropolisHastings.withDefaultConfig() .generatePosteriorSamples(model, model.getLatentVariables()) .dropCount(numSamples / 2) .downSampleInterval(model.getLatentVariables().size()) .generate(numSamples); return new TextMessagingResults( posteriorSamples.getIntegerTensorSamples(switchPoint).getScalarMode(), posteriorSamples.getDoubleTensorSamples(earlyRate).getAverages().scalar(), posteriorSamples.getDoubleTensorSamples(lateRate).getMode().scalar() ); }  static TextMessagingResults run();  }### Answer:
@Test public void testWhenTextMessagingScenarioIsRunThenSwitchPointIsAccurate() { TextMessaging.TextMessagingResults output = TextMessaging.run(); log.info("Switch Point Mode " + output.switchPointMode); log.info("Early Rate Mean " + output.earlyRateMean); log.info("Late Rate Mean " + output.lateRateMean); assertThat(output.switchPointMode).isCloseTo(43, within(2)); assertThat(output.earlyRateMean).isCloseTo(18, within(2d)); assertThat(output.lateRateMean).isCloseTo(23, within(2d)); }