use of org.molgenis.data.event.BootstrappingEvent in project molgenis by molgenis.
the class DynamicRepositoryDecoratorRegistryImplTest method testDecorate.
@Test
public void testDecorate() {
DynamicDecorator dynamicDecorator = mock(DynamicDecorator.class);
Repository decoratedRepository = mock(Repository.class);
when(decoratedRepository.getName()).thenReturn("decoratedRepositoryName");
when(decoratorConfiguration.getDecorators()).thenReturn(Arrays.asList(dynamicDecorator).stream());
when(dynamicDecorator.getId()).thenReturn("dynamicDecoratorId");
when(dynamicRepositoryDecoratorFactory.getId()).thenReturn("dynamicDecoratorId");
when(dynamicRepositoryDecoratorFactory.createDecoratedRepository(repository)).thenReturn(decoratedRepository);
Query query = new QueryImpl().eq(ENTITY_TYPE_ID, "entityTypeId");
when(dataService.findOne(DECORATOR_CONFIGURATION, query, DecoratorConfiguration.class)).thenReturn(decoratorConfiguration);
DynamicRepositoryDecoratorRegistryImpl dynamicRepositoryDecoratorRegistry = new DynamicRepositoryDecoratorRegistryImpl(dataService);
// fake the event to tell the registry that bootstrapping is done.
dynamicRepositoryDecoratorRegistry.onApplicationEvent(new BootstrappingEvent(FINISHED));
dynamicRepositoryDecoratorRegistry.addFactory(dynamicRepositoryDecoratorFactory);
assertEquals(dynamicRepositoryDecoratorRegistry.decorate(repository).getName(), "decoratedRepositoryName");
}
use of org.molgenis.data.event.BootstrappingEvent in project molgenis by molgenis.
the class DynamicRepositoryDecoratorRegistryImplTest method testDecorateNoDecorator.
@Test
public void testDecorateNoDecorator() {
when(repository.getEntityType()).thenReturn(entityType);
when(repository.getName()).thenReturn("repositoryName");
when(entityType.getId()).thenReturn("entityTypeId");
DynamicRepositoryDecoratorRegistryImpl dynamicRepositoryDecoratorRegistry = new DynamicRepositoryDecoratorRegistryImpl(dataService);
// fake the event to tell the registry that bootstrapping is done.
dynamicRepositoryDecoratorRegistry.onApplicationEvent(new BootstrappingEvent(FINISHED));
assertEquals(dynamicRepositoryDecoratorRegistry.decorate(repository).getName(), "repositoryName");
}
Aggregations