@Test
    public void testGrouping() throws IOException {
        try (SerializationTester t = new SerializationTester("testGrouping")) {
            t.assertMatch(new Grouping());

            GroupingLevel level1 = new GroupingLevel();
            level1.setMaxGroups(100)
                  .setExpression(createDummyExpression())
                  .getGroupPrototype()
                      .addAggregationResult(
                              new SumAggregationResult()
                                      .setExpression(createDummyExpression()));
            GroupingLevel level2 = new GroupingLevel();
            level2.setMaxGroups(10)
                    .setExpression(createDummyExpression())
                    .getGroupPrototype()
                        .addAggregationResult(
                                new SumAggregationResult()
                                        .setExpression(createDummyExpression()))
                        .addAggregationResult(
                                new SumAggregationResult()
                                        .setExpression(createDummyExpression()));
            t.assertMatch(new Grouping()
                    .addLevel(level1)
                    .addLevel(level2));

            GroupingLevel level3 = new GroupingLevel();
            level3.setExpression(new AttributeNode("folder"))
                    .getGroupPrototype()
                    .addAggregationResult(
                            new XorAggregationResult()
                                    .setExpression(new MD5BitFunctionNode(new AttributeNode("docid"), 64)))
                    .addAggregationResult(
                            new SumAggregationResult()
                                    .setExpression(new MinFunctionNode()
                                            .addArg(new AttributeNode("attribute1"))
                                            .addArg(new AttributeNode("attribute2"))))
                    .addAggregationResult(
                            new XorAggregationResult()
                                    .setExpression(
                                            new XorBitFunctionNode(new CatFunctionNode()
                                                    .addArg(new GetDocIdNamespaceSpecificFunctionNode(new StringResultNode("")))
                                                    .addArg(new DocumentFieldNode("folder"))
                                                    .addArg(new DocumentFieldNode("flags")), 64)));
            t.assertMatch(new Grouping()
                    .addLevel(level3));
        }
    }
Tests serialization compatibility across Java and C++. The comparison is performed by comparing serialized Java
object graphs with the content of specific binary files. C++ unit tests serializes
identical data structures into these files.
Note: This test relies heavily on proper implementation of {@link Object#equals(Object)}!
searchlib/src/test/java/com/yahoo/searchlib/aggregation/GroupingSerializationTest.java