@Test public void testSum() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM); ExecutionContext context1 = new ExecutionContext(null, cache); assertThat(caf1.evaluate(context1)).isInstanceOf(Sum.class); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM, true); ExecutionContext context2 = new ExecutionContext(null, cache); assertThat(caf2.evaluate(context2)).isInstanceOf(SumDistinct.class); CompiledAggregateFunction caf3 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM); ExecutionContext context3 = new ExecutionContext(null, cache); context3.setIsPRQueryNode(true); assertThat(caf3.evaluate(context3)).isInstanceOf(Sum.class); CompiledAggregateFunction caf4 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM); QueryExecutionContext context4 = new QueryExecutionContext(null, cache); context4.setBucketList(bucketList); assertThat(caf4.evaluate(context4)).isInstanceOf(Sum.class); CompiledAggregateFunction caf5 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM, true); ExecutionContext context5 = new ExecutionContext(null, cache); context5.setIsPRQueryNode(true); assertThat(caf5.evaluate(context5)).isInstanceOf(SumDistinctPRQueryNode.class); CompiledAggregateFunction caf6 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.SUM, true); QueryExecutionContext context6 = new QueryExecutionContext(null, cache); context6.setBucketList(bucketList); assertThat(caf6.evaluate(context6)).isInstanceOf(DistinctAggregator.class); }
@Test public void testCount() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT); ExecutionContext context1 = new ExecutionContext(null, cache); assertThat(caf1.evaluate(context1)).isInstanceOf(Count.class); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT, true); ExecutionContext context2 = new ExecutionContext(null, cache); assertThat(caf2.evaluate(context2)).isInstanceOf(CountDistinct.class); CompiledAggregateFunction caf3 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT); ExecutionContext context3 = new ExecutionContext(null, cache); context3.setIsPRQueryNode(true); assertThat(caf3.evaluate(context3)).isInstanceOf(CountPRQueryNode.class); CompiledAggregateFunction caf4 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT); QueryExecutionContext context4 = new QueryExecutionContext(null, cache); context4.setBucketList(bucketList); assertThat(caf4.evaluate(context4)).isInstanceOf(Count.class); CompiledAggregateFunction caf5 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT, true); ExecutionContext context5 = new ExecutionContext(null, cache); context5.setIsPRQueryNode(true); assertThat(caf5.evaluate(context5)).isInstanceOf(CountDistinctPRQueryNode.class); CompiledAggregateFunction caf6 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.COUNT, true); QueryExecutionContext context6 = new QueryExecutionContext(null, cache); context6.setBucketList(bucketList); assertThat(caf6.evaluate(context6)).isInstanceOf(DistinctAggregator.class); }
@Test public void testAvg() throws Exception { CompiledAggregateFunction caf1 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG); ExecutionContext context1 = new ExecutionContext(null, cache); assertThat(caf1.evaluate(context1)).isInstanceOf(Avg.class); CompiledAggregateFunction caf2 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG, true); ExecutionContext context2 = new ExecutionContext(null, cache); assertThat(caf2.evaluate(context2)).isInstanceOf(AvgDistinct.class); CompiledAggregateFunction caf3 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG); ExecutionContext context3 = new ExecutionContext(null, cache); context3.setIsPRQueryNode(true); assertThat(caf3.evaluate(context3)).isInstanceOf(AvgPRQueryNode.class); CompiledAggregateFunction caf4 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG); QueryExecutionContext context4 = new QueryExecutionContext(null, cache); context4.setBucketList(this.bucketList); assertThat(caf4.evaluate(context4)).isInstanceOf(AvgBucketNode.class); CompiledAggregateFunction caf5 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG, true); ExecutionContext context5 = new ExecutionContext(null, cache); context5.setIsPRQueryNode(true); assertThat(caf5.evaluate(context5)).isInstanceOf(AvgDistinctPRQueryNode.class); CompiledAggregateFunction caf6 = new CompiledAggregateFunction(null, OQLLexerTokenTypes.AVG, true); QueryExecutionContext context6 = new QueryExecutionContext(null, cache); context6.setBucketList(this.bucketList); assertThat(caf6.evaluate(context6)).isInstanceOf(DistinctAggregator.class); }