### Question:
AbstractAnalysisCriterion implements AnalysisCriterion { @Override public Strategy chooseBest(TimeSeries series, List<Strategy> strategies) { Strategy bestStrategy = strategies.get(0); double bestCriterionValue = calculate(series, series.run(bestStrategy)); for (int i = 1; i < strategies.size(); i++) { Strategy currentStrategy = strategies.get(i); double currentCriterionValue = calculate(series, series.run(currentStrategy)); if (betterThan(currentCriterionValue, bestCriterionValue)) { bestStrategy = currentStrategy; bestCriterionValue = currentCriterionValue; } } return bestStrategy; }  @Override Strategy chooseBest(TimeSeries series, List<Strategy> strategies); @Override String toString();  }### Answer:
@Test public void bestShouldBeAlwaysOperateOnProfit() { MockTimeSeries series = new MockTimeSeries(6.0, 9.0, 6.0, 6.0); Strategy bestStrategy = new TotalProfitCriterion().chooseBest(series, strategies); assertEquals(alwaysStrategy, bestStrategy); }
@Test public void bestShouldBeBuyAndHoldOnLoss() { MockTimeSeries series = new MockTimeSeries(6.0, 3.0, 6.0, 6.0); Strategy bestStrategy = new TotalProfitCriterion().chooseBest(series, strategies); assertEquals(buyAndHoldStrategy, bestStrategy); }