@Test public void aggregateFlotSeries() { FlotSeries flotSeries = new FlotSeries(); flotSeries.addPoint(new Integer[]{0, 10}); flotSeries.addPoint(new Integer[]{1, 20}); flotSeries.addPoint(new Integer[]{2, 30}); when(aggregatedSeriesXValueGenerator.generateXValue(0)).thenReturn(1); FlotSeries aggregatedSeries = seriesAggregator.aggregateFlotSeries(flotSeries, 0); assertNotNull(aggregatedSeries); assertNotNull(aggregatedSeries.getPoints()); assertEquals(1, aggregatedSeries.getPoints().size()); assertEquals(1, aggregatedSeries.getPoints().get(0)[0]); assertTrue(Math.abs(aggregatedSeries.getPoints().get(0)[1].floatValue() - 20) < 0.001); }
@Override public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex) { FlotSeries aggregatedFlotSeries = new FlotSeries(); float sum = 0; for (Number[] point : flotSeries.getPoints()) { sum += point[1].floatValue(); } aggregatedFlotSeries.addPoint(new Number[]{aggregatedSeriesXValueGenerator.generateXValue(flotSeriesIndex), sum/flotSeries.getPoints().size()}); return aggregatedFlotSeries; }
RateFlotSeriesAggregator implements FlotSeriesAggregator { @Override public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex) { FlotSeries aggregatedFlotSeries = new FlotSeries(); float sum = 0; for (Number[] point : flotSeries.getPoints()) { sum += point[1].floatValue(); } aggregatedFlotSeries.addPoint(new Number[]{aggregatedSeriesXValueGenerator.generateXValue(flotSeriesIndex), sum/flotSeries.getPoints().size()}); return aggregatedFlotSeries; } }
RateFlotSeriesAggregator implements FlotSeriesAggregator { @Override public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex) { FlotSeries aggregatedFlotSeries = new FlotSeries(); float sum = 0; for (Number[] point : flotSeries.getPoints()) { sum += point[1].floatValue(); } aggregatedFlotSeries.addPoint(new Number[]{aggregatedSeriesXValueGenerator.generateXValue(flotSeriesIndex), sum/flotSeries.getPoints().size()}); return aggregatedFlotSeries; }  }
RateFlotSeriesAggregator implements FlotSeriesAggregator { @Override public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex) { FlotSeries aggregatedFlotSeries = new FlotSeries(); float sum = 0; for (Number[] point : flotSeries.getPoints()) { sum += point[1].floatValue(); } aggregatedFlotSeries.addPoint(new Number[]{aggregatedSeriesXValueGenerator.generateXValue(flotSeriesIndex), sum/flotSeries.getPoints().size()}); return aggregatedFlotSeries; }  @Override FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex); @Override boolean handles(UiyValueType uiyValueType); @Autowired void setAggregatedSeriesXValueGenerator(AggregatedSeriesXValueGenerator aggregatedSeriesXValueGenerator); }
RateFlotSeriesAggregator implements FlotSeriesAggregator { @Override public FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex) { FlotSeries aggregatedFlotSeries = new FlotSeries(); float sum = 0; for (Number[] point : flotSeries.getPoints()) { sum += point[1].floatValue(); } aggregatedFlotSeries.addPoint(new Number[]{aggregatedSeriesXValueGenerator.generateXValue(flotSeriesIndex), sum/flotSeries.getPoints().size()}); return aggregatedFlotSeries; }  @Override FlotSeries aggregateFlotSeries(FlotSeries flotSeries, int flotSeriesIndex); @Override boolean handles(UiyValueType uiyValueType); @Autowired void setAggregatedSeriesXValueGenerator(AggregatedSeriesXValueGenerator aggregatedSeriesXValueGenerator);  }