@Before public void setup() { selector = new TestDoubleColumnSelectorImpl(values); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(selector); EasyMock.replay(colSelectorFactory); }
@Before public void setup() { selector = new TestDoubleColumnSelectorImpl(values); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(selector); EasyMock.replay(colSelectorFactory); }
@Before public void setup() { doubleLastAggFactory = new DoubleLastAggregatorFactory("billy", "nilly"); combiningAggFactory = (DoubleLastAggregatorFactory) doubleLastAggFactory.getCombiningFactory(); timeSelector = new TestLongColumnSelector(times); valueSelector = new TestDoubleColumnSelectorImpl(doubles); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); }
@Before public void setup() { doubleFirstAggFactory = new DoubleFirstAggregatorFactory("billy", "nilly"); combiningAggFactory = (DoubleFirstAggregatorFactory) doubleFirstAggFactory.getCombiningFactory(); timeSelector = new TestLongColumnSelector(times); valueSelector = new TestDoubleColumnSelectorImpl(doubleValues); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); }
@Test public void testComparator() { final TestDoubleColumnSelectorImpl selector = new TestDoubleColumnSelectorImpl(new double[]{0.15d, 0.27d}); DoubleSumAggregator agg = new DoubleSumAggregator(selector); Object first = agg.get(); agg.aggregate(); Comparator comp = new DoubleSumAggregatorFactory("null", "null").getComparator(); Assert.assertEquals(-1, comp.compare(first, agg.get())); Assert.assertEquals(0, comp.compare(first, first)); Assert.assertEquals(0, comp.compare(agg.get(), agg.get())); Assert.assertEquals(1, comp.compare(agg.get(), first)); } }
@Test public void testAggregate() { final TestDoubleColumnSelectorImpl selector1 = new TestDoubleColumnSelectorImpl(new double[]{42.12d, 9d}); final TestDoubleColumnSelectorImpl selector2 = new TestDoubleColumnSelectorImpl(new double[]{2d, 3d}); Map<String, String> script = sumLogATimesBPlusTen; JavaScriptAggregator agg = new JavaScriptAggregator( Arrays.asList(selector1, selector2), JavaScriptAggregatorFactory.compileScript( script.get("fnAggregate"), script.get("fnReset"), script.get("fnCombine") ) ); double val = 10.; Assert.assertEquals(val, agg.get()); Assert.assertEquals(val, agg.get()); Assert.assertEquals(val, agg.get()); aggregate(selector1, selector2, agg); val += Math.log(42.12d) * 2d; Assert.assertEquals(val, agg.get()); Assert.assertEquals(val, agg.get()); Assert.assertEquals(val, agg.get()); aggregate(selector1, selector2, agg); val += Math.log(9d) * 3d; Assert.assertEquals(val, agg.get()); Assert.assertEquals(val, agg.get()); Assert.assertEquals(val, agg.get()); }
@Test public void testAggregate() { final double[] values = {0.15d, 0.27d}; final TestDoubleColumnSelectorImpl selector = new TestDoubleColumnSelectorImpl(values); DoubleSumAggregator agg = new DoubleSumAggregator(selector); double expectedFirst = new Double(values[0]).doubleValue(); double expectedSecond = new Double(values[1]).doubleValue() + expectedFirst; Assert.assertEquals(0.0d, agg.get()); Assert.assertEquals(0.0d, agg.get()); Assert.assertEquals(0.0d, agg.get()); aggregate(selector, agg); Assert.assertEquals(expectedFirst, agg.get()); Assert.assertEquals(expectedFirst, agg.get()); Assert.assertEquals(expectedFirst, agg.get()); aggregate(selector, agg); Assert.assertEquals(expectedSecond, agg.get()); Assert.assertEquals(expectedSecond, agg.get()); Assert.assertEquals(expectedSecond, agg.get()); }