@Test public void passesNonEmptyIndicatorDataToSmootherAndReturnsResult() { when(indicator.indicate(any(BasicMarketData.class))).thenReturn(optPrice(56)).thenReturn(empty()) .thenReturn(optPrice(92)); when(smoother.smooth(new Price(56))).thenReturn(optPrice(560)); when(smoother.smooth(new Price(92))).thenReturn(optPrice(920)); assertThat(cut.indicate(SOME_MARKET_DATA)).contains(new Price(560)); assertThat(cut.indicate(SOME_MARKET_DATA)).isEmpty(); assertThat(cut.indicate(SOME_MARKET_DATA)).contains(new Price(920)); }
@Override public Optional<V> indicate(final MP marketPrice) { return indicator.indicate(marketPrice).flatMap(value -> smoother.smooth(value)); }
IndicatorSmoother implements Indicator<V, MP> { @Override public Optional<V> indicate(final MP marketPrice) { return indicator.indicate(marketPrice).flatMap(value -> smoother.smooth(value)); } }
IndicatorSmoother implements Indicator<V, MP> { @Override public Optional<V> indicate(final MP marketPrice) { return indicator.indicate(marketPrice).flatMap(value -> smoother.smooth(value)); } IndicatorSmoother(final Indicator<V, MP> indicator, final Smoother<V> smoother); }
IndicatorSmoother implements Indicator<V, MP> { @Override public Optional<V> indicate(final MP marketPrice) { return indicator.indicate(marketPrice).flatMap(value -> smoother.smooth(value)); } IndicatorSmoother(final Indicator<V, MP> indicator, final Smoother<V> smoother); @Override Optional<V> indicate(final MP marketPrice); }
IndicatorSmoother implements Indicator<V, MP> { @Override public Optional<V> indicate(final MP marketPrice) { return indicator.indicate(marketPrice).flatMap(value -> smoother.smooth(value)); } IndicatorSmoother(final Indicator<V, MP> indicator, final Smoother<V> smoother); @Override Optional<V> indicate(final MP marketPrice);  }