### Question:
CrossingMA implements Filter { @Override public Outcome accept(String ticker) { List<BigDecimal> ma1Values = provider.getMAValues(ticker, firstMAType, firstMAPeriods, timeFrame, lastPeriods); List<BigDecimal> ma2Values = provider.getMAValues(ticker, secondMAType, secondMAPeriods, timeFrame, lastPeriods); boolean isUpAtStart = ma1Values.get(0).compareTo(ma2Values.get(0)) > 0; for (int i = 1; i < ma1Values.size(); i++) { boolean isCurrentlyUp = ma1Values.get(i).compareTo(ma2Values.get(i)) > 0; if (isUpAtStart != isCurrentlyUp) return Outcome.ok; } return Outcome.ko; } CrossingMA(MAProvider provider, TimeFrame timeFrame, MAType firstMAType, int firstMAPeriods,
			MAType secondMAType, int secondMAPeriods, int lastPeriods); TimeFrame getTimeFrame(); MAType getFirstMAType(); int getFirstMAPeriods(); MAType getSecondMAType(); int getSecondMAPeriods(); int getLastPeriods(); @Override Outcome accept(String ticker);  }### Answer:
@Test public void positive() { List<BigDecimal> ma1values = toBigDecimals(1, 2); List<BigDecimal> ma2values = toBigDecimals(2, 1); context.checking(new Expectations() {{ oneOf(maProvider).getMAValues("GBX", MAType.sma, 30, TimeFrame.week, 2); will(returnValue(ma1values)); oneOf(maProvider).getMAValues("GBX", MAType.sma, 10, TimeFrame.week, 2); will(returnValue(ma2values)); }}); Assert.assertEquals(Outcome.ok, crossingma.accept("GBX")); }
@Test public void negative() { List<BigDecimal> ma1values = toBigDecimals(1, 2); List<BigDecimal> ma2values = toBigDecimals(3, 4); context.checking(new Expectations() {{ oneOf(maProvider).getMAValues("GBX", MAType.sma, 30, TimeFrame.week, 2); will(returnValue(ma1values)); oneOf(maProvider).getMAValues("GBX", MAType.sma, 10, TimeFrame.week, 2); will(returnValue(ma2values)); }}); Assert.assertEquals(Outcome.ko, crossingma.accept("GBX")); }