CoreAggregationFactory implements AggregationFactory { @Override public Aggregation build(String name, List<Expression> args, Map<String, Expression> keywords) { final AggregationDSL builder = builderMap.get(name); if (builder == null) { throw new MissingAggregation(name); } final AggregationArguments a = new AggregationArguments(args, keywords); final Aggregation aggregation; try { aggregation = builder.build(a); } catch (final Exception e) { throw new RuntimeException(name + ": " + e.getMessage(), e); } a.throwUnlessEmpty(name); return aggregation; } @java.beans.ConstructorProperties({ "builderMap" })  CoreAggregationFactory(final Map<String, AggregationDSL> builderMap); @Override Aggregation build(String name, List<Expression> args, Map<String, Expression> keywords);  }
@Test public void builderMissing() { expected.expect(MissingAggregation.class); expected.expectMessage("Missing aggregation missing"); factory.build("missing", ImmutableList.of(), ImmutableMap.of()); }
@Test public void builderThrowing() { expected.expect(RuntimeException.class); expected.expectMessage("throwing: exception"); factory.build("throwing", ImmutableList.of(), ImmutableMap.of()); }
@Test public void builderWorking() { assertEquals(aggregation, factory.build("working", ImmutableList.of(), ImmutableMap.of())); }