@Test
    void testProgrammaticBuilding() {
        String expected =
                "all(group(myfield) max(10000) each(" +
                        "output(min(foo), max(bar)) " +
                        "all(group(foo) max(10000) output(count()))" +
                        "))";
        Query query = new Query();
        GroupingRequest grouping = GroupingRequest.newInstance(query);
        AllOperation root = new AllOperation();
        root.setGroupBy(new AttributeValue("myfield"));
        root.setMax(10000);
        EachOperation each = new EachOperation();
        each.addOutput(new MinAggregator(new AttributeValue("foo")));
        each.addOutput(new MaxAggregator(new AttributeValue("bar")));
        AllOperation all = new AllOperation();
        all.setGroupBy(new AttributeValue("foo"));
        all.setMax(10000);
        all.addOutput(new CountAggregator());
        each.addChild(all);
        root.addChild(each);
        grouping.setRootOperation(root);

        assertEquals(expected, query.getSelect().getGrouping().get(0).toString());
    }
Tests Query.Select

@author henrhoi
@author bratseth
container-search/src/test/java/com/yahoo/select/SelectTestCase.java