improvements
- split the 'sortby' select field into two fields - sort by average - legend shows plotted and total values in the date range - removed InlineDataSeries, because it was not used anymore
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
public class DataSeriesStatsTest {
|
||||
@DataProvider
|
||||
public Object[][] providerAverage() {
|
||||
final List<Object[]> result = new ArrayList<>();
|
||||
|
||||
{
|
||||
final List<DataSeriesStats> stats = Arrays.asList(//
|
||||
new DataSeriesStats(10, 0, 0, 5.0)//
|
||||
);
|
||||
final double expected = 5.0;
|
||||
result.add(new Object[] { stats, expected });
|
||||
}
|
||||
{
|
||||
final List<DataSeriesStats> stats = Arrays.asList(//
|
||||
new DataSeriesStats(0, 0, 0, 5.0)//
|
||||
);
|
||||
final double expected = 0.0; // no values
|
||||
result.add(new Object[] { stats, expected });
|
||||
}
|
||||
|
||||
{
|
||||
final List<DataSeriesStats> stats = Arrays.asList(//
|
||||
new DataSeriesStats(10, 0, 0, 5.0), //
|
||||
new DataSeriesStats(40, 0, 0, 1.0)//
|
||||
);
|
||||
final double expected = 1.8; // 90 / 50
|
||||
result.add(new Object[] { stats, expected });
|
||||
}
|
||||
{
|
||||
final List<DataSeriesStats> stats = Arrays.asList(//
|
||||
new DataSeriesStats(5, 0, 0, 7.0), //
|
||||
new DataSeriesStats(0, 0, 0, 5.0), // // no values
|
||||
new DataSeriesStats(20, 0, 0, 2.0)//
|
||||
);
|
||||
final double expected = 3.0; // (35+40) / 25
|
||||
result.add(new Object[] { stats, expected });
|
||||
}
|
||||
|
||||
return result.toArray(new Object[0][]);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "providerAverage")
|
||||
public void testAverage(final Collection<DataSeriesStats> stats, final double expected) {
|
||||
|
||||
final double actual = DataSeriesStats.average(stats);
|
||||
Assert.assertEquals(actual, expected, 0.01);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user