### Question:
Aggregate extends Operator { public void open() throws NoSuchElementException, DbException, TransactionAbortedException { child.open(); super.open(); while (child.hasNext()) { aggregator.mergeTupleIntoGroup(child.next()); } aggregateIter = aggregator.iterator(); aggregateIter.open(); } Aggregate(DbIterator child, int agIndex, int gbIndex, Aggregator.Op aggreOp); int groupFieldIndex(); String groupFieldName(); int aggregateFieldIndex(); String aggregateFieldName(); Aggregator.Op aggregateOp(); static String nameOfAggregatorOp(Aggregator.Op aggreOp); void open(); void rewind(); TupleDesc getTupleDesc(); void close(); @Override DbIterator[] getChildren(); @Override void setChildren(DbIterator[] children);  }### Answer:
@Test public void countStringAggregate() throws Exception { Aggregate op = new Aggregate(scan2, 1, 0, Aggregator.Op.COUNT); op.open(); count.open(); TestUtil.matchAllTuples(count, op); }
@Test public void sumStringGroupBy() throws Exception { Aggregate op = new Aggregate(scan3, 1, 0, Aggregator.Op.SUM); op.open(); sumstring.open(); TestUtil.matchAllTuples(sumstring, op); }
@Test public void sumAggregate() throws Exception { Aggregate op = new Aggregate(scan1, 1, 0, Aggregator.Op.SUM); op.open(); sum.open(); TestUtil.matchAllTuples(sum, op); }
@Test public void avgAggregate() throws Exception { Aggregate op = new Aggregate(scan1, 1, 0, Aggregator.Op.AVG); op.open(); avg.open(); TestUtil.matchAllTuples(avg, op); }
@Test public void maxAggregate() throws Exception { Aggregate op = new Aggregate(scan1, 1, 0, Aggregator.Op.MAX); op.open(); max.open(); TestUtil.matchAllTuples(max, op); }
@Test public void minAggregate() throws Exception { Aggregate op = new Aggregate(scan1, 1, 0, Aggregator.Op.MIN); op.open(); min.open(); TestUtil.matchAllTuples(min, op); }