@Test
public void testToSql() {

    // Prepare
    final StringBuilder sb = new StringBuilder("BASE");
    final GroupByExtension groupBy = new GroupByExtension(new SearchBaseExtension(String.class, String.class));
    final Attribute att = new Attribute("TEST_TABLE", "TEST_COLUMN");
    final Pair<Func, Attribute> pair1 = new Pair<SearchCriteria.Func, Attribute>(SearchCriteria.Func.FIRST, att);
    final Pair<Func, Attribute> pair2 = new Pair<SearchCriteria.Func, Attribute>(SearchCriteria.Func.MAX, att);
    groupBy._groupBys = new ArrayList<Pair<Func, Attribute>>();
    groupBy._groupBys.add(pair1);
    groupBy._groupBys.add(pair2);
    groupBy.having(SearchCriteria.Func.COUNT, att, Op.GT, "SOME_VALUE");
    // Execute
    groupBy.toSql(sb);
    // Assert
    assertTrue("It didn't create the expected SQL query.", sb.toString().equals(EXPECTED_QUERY));
}