Grouping extends CompositeOperator<Grouping> { public Grouping withResultProjection(EvaluationExpression resultProjection) { this.setResultProjection(resultProjection); return this; }  @Override ElementarySopremoModule asElementaryOperators(EvaluationContext context); @Override boolean equals(final Object obj); EvaluationExpression getResultProjection(); @Override int hashCode(); @Property(preferred = true) @Name(preposition = "into") void setResultProjection(EvaluationExpression resultProjection); Grouping withResultProjection(EvaluationExpression resultProjection); @Property(preferred = true, input = true) @Name(preposition = "by") void setGroupingKey(final int inputIndex, final EvaluationExpression keyExpression); void setGroupingKey(final JsonStream input, final EvaluationExpression keyExpression); Grouping withGroupingKey(int inputIndex, EvaluationExpression groupingKey); Grouping withGroupingKey(EvaluationExpression groupingKey); EvaluationExpression getGroupingKey(final int index); EvaluationExpression getGroupingKey(final JsonStream input); EvaluationExpression getDefaultGroupingKey(); void setDefaultGroupingKey(EvaluationExpression defaultGroupingKey); @Override String toString();  }
@Test public void shouldPerformSimpleGroupBy() { final SopremoTestPlan sopremoPlan = new SopremoTestPlan(1, 1); sopremoPlan.getEvaluationContext().getFunctionRegistry().put(CoreFunctions.class); final Grouping aggregation = new Grouping().withResultProjection(CoreFunctions.COUNT.asExpression()); aggregation.setInputs(sopremoPlan.getInputOperator(0)); sopremoPlan.getOutputOperator(0).setInputs(aggregation); sopremoPlan.getInput(0). addObject("id", 1, "dept", 1, "income", 12000). addObject("id", 2, "dept", 1, "income", 13000). addObject("id", 3, "dept", 2, "income", 15000). addObject("id", 4, "dept", 1, "income", 10000). addObject("id", 5, "dept", 3, "income", 8000). addObject("id", 6, "dept", 2, "income", 5000). addObject("id", 7, "dept", 1, "income", 24000); sopremoPlan.getExpectedOutput(0). addValue(7); sopremoPlan.run(); }