AggregatorFactory { public Aggregator get(AggregationParameters parameters) { if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) { throw new IllegalArgumentException("Invalid aggregation parameters"); } final AggregationOperation operation = parameters.getOperations().get(0); String groupBy = parameters.getGroupBy().get(0); switch (operation.getOperator()) { case AVERAGE: return new Average(groupBy, operation.getColumnId()); case MIN: return new Min(groupBy, operation.getColumnId()); case MAX: return new Max(groupBy, operation.getColumnId()); case SUM: return new Sum(groupBy, operation.getColumnId()); default: throw new IllegalArgumentException("Operation '" + operation.getOperator() + "' not supported"); } }  Aggregator get(AggregationParameters parameters);  }
@Test(expected = IllegalArgumentException.class) public void shouldReturnEmptyAggregator() { AggregationParameters parameters = new AggregationParameters(); parameters.addGroupBy("0000"); Aggregator actual = factory.get(parameters); }