@Test void testDecorateNoFactory() { String entityTypeId = "entityTypeId"; SystemEntityType entityType = mock(SystemEntityType.class); when(entityType.getId()).thenReturn(entityTypeId); @SuppressWarnings("unchecked") Repository<Entity> repository = mock(Repository.class); when(repository.getEntityType()).thenReturn(entityType); assertEquals(repository, systemRepositoryDecoratorRegistryImpl.decorate(repository)); }
@SuppressWarnings("unchecked") @Override public synchronized Repository<Entity> decorate(Repository<Entity> repository) { Repository<Entity> decoratedRepository = repository; for (String factoryId : getFactoryIds(repository)) { SystemRepositoryDecoratorFactory factory = factories.get(factoryId); if (factory != null) { decoratedRepository = factory.createDecoratedRepository(decoratedRepository); } } return decoratedRepository; }
SystemRepositoryDecoratorRegistryImpl implements SystemRepositoryDecoratorRegistry { @SuppressWarnings("unchecked") @Override public synchronized Repository<Entity> decorate(Repository<Entity> repository) { Repository<Entity> decoratedRepository = repository; for (String factoryId : getFactoryIds(repository)) { SystemRepositoryDecoratorFactory factory = factories.get(factoryId); if (factory != null) { decoratedRepository = factory.createDecoratedRepository(decoratedRepository); } } return decoratedRepository; } }
SystemRepositoryDecoratorRegistryImpl implements SystemRepositoryDecoratorRegistry { @SuppressWarnings("unchecked") @Override public synchronized Repository<Entity> decorate(Repository<Entity> repository) { Repository<Entity> decoratedRepository = repository; for (String factoryId : getFactoryIds(repository)) { SystemRepositoryDecoratorFactory factory = factories.get(factoryId); if (factory != null) { decoratedRepository = factory.createDecoratedRepository(decoratedRepository); } } return decoratedRepository; }  }
SystemRepositoryDecoratorRegistryImpl implements SystemRepositoryDecoratorRegistry { @SuppressWarnings("unchecked") @Override public synchronized Repository<Entity> decorate(Repository<Entity> repository) { Repository<Entity> decoratedRepository = repository; for (String factoryId : getFactoryIds(repository)) { SystemRepositoryDecoratorFactory factory = factories.get(factoryId); if (factory != null) { decoratedRepository = factory.createDecoratedRepository(decoratedRepository); } } return decoratedRepository; }  @Override synchronized void addFactory(SystemRepositoryDecoratorFactory factory); @SuppressWarnings("unchecked") @Override synchronized Repository<Entity> decorate(Repository<Entity> repository); }
SystemRepositoryDecoratorRegistryImpl implements SystemRepositoryDecoratorRegistry { @SuppressWarnings("unchecked") @Override public synchronized Repository<Entity> decorate(Repository<Entity> repository) { Repository<Entity> decoratedRepository = repository; for (String factoryId : getFactoryIds(repository)) { SystemRepositoryDecoratorFactory factory = factories.get(factoryId); if (factory != null) { decoratedRepository = factory.createDecoratedRepository(decoratedRepository); } } return decoratedRepository; }  @Override synchronized void addFactory(SystemRepositoryDecoratorFactory factory); @SuppressWarnings("unchecked") @Override synchronized Repository<Entity> decorate(Repository<Entity> repository);  }