Search in sources :

Example 1 with BootstrappingEvent

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");
}
Also used : QueryImpl(org.molgenis.data.support.QueryImpl) BootstrappingEvent(org.molgenis.data.event.BootstrappingEvent) Test(org.testng.annotations.Test)

Example 2 with BootstrappingEvent

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");
}
Also used : BootstrappingEvent(org.molgenis.data.event.BootstrappingEvent) Test(org.testng.annotations.Test)

Aggregations

BootstrappingEvent (org.molgenis.data.event.BootstrappingEvent)2 Test (org.testng.annotations.Test)2 QueryImpl (org.molgenis.data.support.QueryImpl)1