@Test public void aggregateFlotSeries() { FlotSeriesAggregator seriesAggregator1 = mock(FlotSeriesAggregator.class); FlotSeriesAggregator seriesAggregator2 = mock(FlotSeriesAggregator.class); when(seriesAggregator1.handles(NUMBER)).thenReturn(false); when(seriesAggregator2.handles(NUMBER)).thenReturn(true); List<FlotSeriesAggregator> flotSeriesAggregators = Lists.newArrayList(seriesAggregator1, seriesAggregator2); flotSeriesAggregatorManager.setFlotSeriesAggregators(flotSeriesAggregators); FlotSeries series = mock(FlotSeries.class); FlotSeries aggrSeries = mock(FlotSeries.class); when(seriesAggregator2.aggregateFlotSeries(series, 0)).thenReturn(aggrSeries); FlotSeries retSeries = flotSeriesAggregatorManager.aggregateFlotSeries(series, 0, NUMBER); assertTrue(aggrSeries == retSeries); }
public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType) { Preconditions.checkNotNull(flotSeries); Preconditions.checkNotNull(uiyValueType); List<FlotSeriesAggregator> handlingAggregators = flotSeriesAggregators.stream().filter(a->a.handles(uiyValueType)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(handlingAggregators)) { throw new IllegalArgumentException("no " + FlotSeriesAggregator.class.getName() + " handling " + uiyValueType.name()); } return handlingAggregators.get(0).aggregateFlotSeries(flotSeries, flotSeriesIndex); }
FlotSeriesAggregatorManager { public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType) { Preconditions.checkNotNull(flotSeries); Preconditions.checkNotNull(uiyValueType); List<FlotSeriesAggregator> handlingAggregators = flotSeriesAggregators.stream().filter(a->a.handles(uiyValueType)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(handlingAggregators)) { throw new IllegalArgumentException("no " + FlotSeriesAggregator.class.getName() + " handling " + uiyValueType.name()); } return handlingAggregators.get(0).aggregateFlotSeries(flotSeries, flotSeriesIndex); } }
FlotSeriesAggregatorManager { public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType) { Preconditions.checkNotNull(flotSeries); Preconditions.checkNotNull(uiyValueType); List<FlotSeriesAggregator> handlingAggregators = flotSeriesAggregators.stream().filter(a->a.handles(uiyValueType)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(handlingAggregators)) { throw new IllegalArgumentException("no " + FlotSeriesAggregator.class.getName() + " handling " + uiyValueType.name()); } return handlingAggregators.get(0).aggregateFlotSeries(flotSeries, flotSeriesIndex); }  }
FlotSeriesAggregatorManager { public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType) { Preconditions.checkNotNull(flotSeries); Preconditions.checkNotNull(uiyValueType); List<FlotSeriesAggregator> handlingAggregators = flotSeriesAggregators.stream().filter(a->a.handles(uiyValueType)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(handlingAggregators)) { throw new IllegalArgumentException("no " + FlotSeriesAggregator.class.getName() + " handling " + uiyValueType.name()); } return handlingAggregators.get(0).aggregateFlotSeries(flotSeries, flotSeriesIndex); }  FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType); @Autowired void setFlotSeriesAggregators(List<FlotSeriesAggregator> flotSeriesAggregators); }
FlotSeriesAggregatorManager { public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType) { Preconditions.checkNotNull(flotSeries); Preconditions.checkNotNull(uiyValueType); List<FlotSeriesAggregator> handlingAggregators = flotSeriesAggregators.stream().filter(a->a.handles(uiyValueType)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(handlingAggregators)) { throw new IllegalArgumentException("no " + FlotSeriesAggregator.class.getName() + " handling " + uiyValueType.name()); } return handlingAggregators.get(0).aggregateFlotSeries(flotSeries, flotSeriesIndex); }  FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex, UiyValueType uiyValueType); @Autowired void setFlotSeriesAggregators(List<FlotSeriesAggregator> flotSeriesAggregators);  }