GroupIterator extends CloseableIteratorIteration<BindingSet, QueryEvaluationException> { @Override public BindingSet next() throws QueryEvaluationException { if (!initialized) { synchronized (lock) { if (!initialized) { super.setIterator(createIterator()); initialized = true; } } } return super.next(); } GroupIterator(EvaluationStrategy strategy, Group group, BindingSet parentBindings);  GroupIterator(EvaluationStrategy strategy, Group group, BindingSet parentBindings,
			long iterationCacheSyncThreshold); @Override boolean hasNext(); @Override BindingSet next();  }
@Test public void testAvgEmptySet() throws QueryEvaluationException { Group group = new Group(EMPTY_ASSIGNMENT); group.addGroupElement(new GroupElem("avg", new Avg(new Var("a")))); GroupIterator gi = new GroupIterator(evaluator, group, EmptyBindingSet.getInstance()); assertThat(gi.next().getBinding("avg").getValue()) .describedAs("AVG on empty set should result in 0") .isEqualTo(vf.createLiteral("0", XSD.INTEGER)); }
@Test public void testGroupConcatEmptySet() throws QueryEvaluationException { Group group = new Group(EMPTY_ASSIGNMENT); group.addGroupElement(new GroupElem("groupconcat", new GroupConcat(new Var("a")))); GroupIterator gi = new GroupIterator(evaluator, group, EmptyBindingSet.getInstance()); assertThat(gi.next().getBinding("groupconcat").getValue()) .describedAs("GROUP_CONCAT on empty set should result in empty string") .isEqualTo(vf.createLiteral("")); }
@Test public void testAvgNotZero() throws QueryEvaluationException { Group group = new Group(NONEMPTY_ASSIGNMENT); group.addGroupElement(new GroupElem("avg", new Avg(new Var("a")))); GroupIterator gi = new GroupIterator(evaluator, group, EmptyBindingSet.getInstance()); assertThat(gi.next().getBinding("avg").getValue()).isEqualTo(vf.createLiteral("5", XSD.DECIMAL)); }
@Test public void testCountNotZero() throws QueryEvaluationException { Group group = new Group(NONEMPTY_ASSIGNMENT); group.addGroupElement(new GroupElem("count", new Count(new Var("a")))); GroupIterator gi = new GroupIterator(evaluator, group, EmptyBindingSet.getInstance()); assertThat(gi.next().getBinding("count").getValue()).isEqualTo(vf.createLiteral("9", XSD.INTEGER)); }
@Test public void testSumNotZero() throws QueryEvaluationException { Group group = new Group(NONEMPTY_ASSIGNMENT); group.addGroupElement(new GroupElem("sum", new Sum(new Var("a")))); GroupIterator gi = new GroupIterator(evaluator, group, EmptyBindingSet.getInstance()); assertThat(gi.next().getBinding("sum").getValue()).isEqualTo(vf.createLiteral("45", XSD.INTEGER)); }