SqlppGroupingSetsParser { public List<List<GbyVariableExpressionPair>> parse(List<GroupingElement> inList, SourceLocation sourceLoc) throws CompilationException { this.sourceLoc = sourceLoc; List<GbyVariableExpressionPair> primitiveList = transformSimpleToPrimitive(inList); if (primitiveList != null) { return Collections.singletonList(primitiveList); } else { if (workList == null) { workList = new ArrayList<>(); } else { workList.clear(); } eliminateComplexGroupingSets(inList, workList, false); return crossProductGroupingSets(workList); } }  List<List<GbyVariableExpressionPair>> parse(List<GroupingElement> inList, SourceLocation sourceLoc);  }
@Test public void test() throws Exception { SqlppParserFactory parserFactory = new SqlppParserFactory(); String groupbyClause = "GROUP BY " + groupbyInput; String query = "SELECT COUNT(*) FROM test " + groupbyClause + ";"; IParser parser = parserFactory.createParser(query + query); List<Statement> statements; try { statements = parser.parse(); } catch (CompilationException e) { if (expectedErrorCode == null) { throw e; } else if (e.getMessage().contains(expectedErrorCode)) { return; } else { Assert.fail(String.format("Unable to find expected error code %s in error message: %s", expectedErrorCode, e.getMessage())); throw new IllegalStateException(); } } Assert.assertEquals(2, statements.size()); for (Statement statement : statements) { String groupingSets = extractGroupingSets(statement); Assert.assertEquals(expectedGroupingSets, groupingSets); } }