CoreAggregationRegistry implements AggregationRegistry { @Override public <A extends Aggregation, I extends AggregationInstance> void register( final String id, final Class<A> type, final Class<I> instanceType, final AggregationDSL dsl ) { synchronized (lock) { if (definitionMap.containsKey(type)) { throw new IllegalArgumentException( "An aggregation with the same type (" + type.getCanonicalName() + ") is already registered"); } if (instanceMap.containsKey(instanceType)) { throw new IllegalArgumentException("An aggregation instance with the same type (" + instanceType.getCanonicalName() + ") is already registered"); } if (builderMap.containsKey(id)) { throw new IllegalArgumentException( "An aggregation with the same id (" + id + ") is already registered"); } definitionMap.put(type, id); instanceMap.put(instanceType, id); builderMap.put(id, dsl); } } @java.beans.ConstructorProperties({ "string" })  CoreAggregationRegistry(final Serializer<String> string); @Override void register(
        final String id, final Class<A> type, final Class<I> instanceType, final AggregationDSL dsl
    ); @Override void registerInstance(
        final String id, final Class<I> instanceType
    ); Module module(); @Override AggregationFactory newAggregationFactory();  }
@Test public void testRegisterQuery() { registry.register("foo", A.class, AI.class, dsl); assertEquals("foo", registry.definitionMap.get(A.class)); assertEquals("foo", registry.instanceMap.get(AI.class)); assertEquals(dsl, registry.builderMap.get("foo")); }
@Test(expected = IllegalArgumentException.class) public void testRegisterSameId() { registry.register("foo", A.class, AI.class, dsl); registry.register("foo", B.class, BI.class, dsl); }
@Test(expected = IllegalArgumentException.class) public void testRegisterSameAggregation() { registry.register("foo", A.class, AI.class, dsl); registry.register("bar", A.class, BI.class, dsl); }
@Test(expected = IllegalArgumentException.class) public void testRegisterSameInstance() { registry.register("foo", A.class, AI.class, dsl); registry.register("bar", B.class, AI.class, dsl); }