### Question:
SyncTrainer implements ITrainer { public void train() { episodeCount = 0; stepCount = 0; while (!stoppingCondition.test(this)) { agentLearner.run(); ++episodeCount; stepCount += agentLearner.getEpisodeStepCount(); } } @lombok.Builder  SyncTrainer(@NonNull Builder<IAgentLearner<ACTION>> agentLearnerBuilder,
                       @NonNull Predicate<SyncTrainer<ACTION>> stoppingCondition); void train();  }### Answer:
@Test public void when_training_expect_stoppingConditionWillStopTraining() { Predicate<SyncTrainer> stoppingCondition = t -> t.getEpisodeCount() >= 5; setup(stoppingCondition); sut.train(); assertEquals(5, sut.getEpisodeCount()); }
@Test public void when_training_expect_agentIsRun() { Predicate<SyncTrainer> stoppingCondition = t -> t.getEpisodeCount() >= 5; setup(stoppingCondition); sut.train(); verify(agentLearnerMock, times(5)).run(); }
@Test public void when_training_expect_countsAreReset() { Predicate<SyncTrainer> stoppingCondition = t -> t.getEpisodeCount() >= 5; setup(stoppingCondition); sut.train(); sut.train(); assertEquals(5, sut.getEpisodeCount()); assertEquals(50, sut.getStepCount()); }