@Test void testAddFactory() { DynamicRepositoryDecoratorFactory factory1 = mock(DynamicRepositoryDecoratorFactory.class); when(factory1.getId()).thenReturn("test1"); DynamicRepositoryDecoratorFactory factory2 = mock(DynamicRepositoryDecoratorFactory.class); when(factory2.getId()).thenReturn("test2"); registry.addFactory(factory1); registry.addFactory(factory2); assertEquals(newHashSet("test1", "test2"), registry.getFactoryIds().collect(toSet())); }
@Override public synchronized void addFactory(DynamicRepositoryDecoratorFactory factory) { String factoryId = factory.getId(); if (factories.containsKey(factoryId)) { throw new IllegalArgumentException(format("Duplicate decorator id [%s]", factoryId)); } factories.put(factoryId, factory); }
DynamicRepositoryDecoratorRegistryImpl implements DynamicRepositoryDecoratorRegistry { @Override public synchronized void addFactory(DynamicRepositoryDecoratorFactory factory) { String factoryId = factory.getId(); if (factories.containsKey(factoryId)) { throw new IllegalArgumentException(format("Duplicate decorator id [%s]", factoryId)); } factories.put(factoryId, factory); } }
DynamicRepositoryDecoratorRegistryImpl implements DynamicRepositoryDecoratorRegistry { @Override public synchronized void addFactory(DynamicRepositoryDecoratorFactory factory) { String factoryId = factory.getId(); if (factories.containsKey(factoryId)) { throw new IllegalArgumentException(format("Duplicate decorator id [%s]", factoryId)); } factories.put(factoryId, factory); } DynamicRepositoryDecoratorRegistryImpl(DataService dataService, Gson gson); }
DynamicRepositoryDecoratorRegistryImpl implements DynamicRepositoryDecoratorRegistry { @Override public synchronized void addFactory(DynamicRepositoryDecoratorFactory factory) { String factoryId = factory.getId(); if (factories.containsKey(factoryId)) { throw new IllegalArgumentException(format("Duplicate decorator id [%s]", factoryId)); } factories.put(factoryId, factory); } DynamicRepositoryDecoratorRegistryImpl(DataService dataService, Gson gson); @Override synchronized void addFactory(DynamicRepositoryDecoratorFactory factory); @Override Stream<String> getFactoryIds(); @Override DynamicRepositoryDecoratorFactory getFactory(String id); @Override synchronized Repository<Entity> decorate(Repository<Entity> repository); @EventListener void onApplicationEvent(BootstrappingEvent bootstrappingEvent); }
DynamicRepositoryDecoratorRegistryImpl implements DynamicRepositoryDecoratorRegistry { @Override public synchronized void addFactory(DynamicRepositoryDecoratorFactory factory) { String factoryId = factory.getId(); if (factories.containsKey(factoryId)) { throw new IllegalArgumentException(format("Duplicate decorator id [%s]", factoryId)); } factories.put(factoryId, factory); } DynamicRepositoryDecoratorRegistryImpl(DataService dataService, Gson gson); @Override synchronized void addFactory(DynamicRepositoryDecoratorFactory factory); @Override Stream<String> getFactoryIds(); @Override DynamicRepositoryDecoratorFactory getFactory(String id); @Override synchronized Repository<Entity> decorate(Repository<Entity> repository); @EventListener void onApplicationEvent(BootstrappingEvent bootstrappingEvent);  }