Search in sources :

Example 1 with DefaultProviderExtension

use of org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ExtensionLoaderTest method bootServiceExtensions_withSingleDefaultProvider.

@Test
@DisplayName("bootServiceExtensions - Should invoke default provider")
void bootServiceExtensions_withSingleDefaultProvider() {
    var dependentExtension = createDependentExtension(true);
    var defaultProvider = (DefaultProviderExtension) spy(createProviderExtension(true));
    when(defaultProvider.testObject()).thenCallRealMethod();
    var context = new DefaultServiceExtensionContext(new TypeManager(), mock(Monitor.class), null, List.of());
    var list = createInjectionContainers(createList(defaultProvider, dependentExtension));
    ExtensionLoader.bootServiceExtensions(list, context);
    verify(defaultProvider, times(1)).testObject();
}
Also used : ConsoleMonitor(org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor) MultiplexingMonitor(org.eclipse.dataspaceconnector.spi.monitor.MultiplexingMonitor) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) DefaultProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with DefaultProviderExtension

use of org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ExtensionLoaderTest method bootServiceExtensions_withOptionalDependency_defaultAndNonDefault.

@Test
@DisplayName("bootServiceExtensions - Should invoke non-default provider with optional dependency")
void bootServiceExtensions_withOptionalDependency_defaultAndNonDefault() {
    var dependentExtension = createDependentExtension(false);
    var defaultProvider = (DefaultProviderExtension) spy(createProviderExtension(true));
    when(defaultProvider.testObject()).thenCallRealMethod();
    var provider = (ProviderExtension) spy(createProviderExtension(false));
    when(provider.testObject()).thenCallRealMethod();
    var context = new DefaultServiceExtensionContext(new TypeManager(), mock(Monitor.class), null, List.of());
    var list = createInjectionContainers(createList(dependentExtension, defaultProvider, provider));
    ExtensionLoader.bootServiceExtensions(list, context);
    verify(defaultProvider, never()).testObject();
    verify(provider, times(1)).testObject();
    assertThat(context.getService(TestObject.class)).isNotNull();
}
Also used : ConsoleMonitor(org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor) MultiplexingMonitor(org.eclipse.dataspaceconnector.spi.monitor.MultiplexingMonitor) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) TestFunctions.createProviderExtension(org.eclipse.dataspaceconnector.boot.system.TestFunctions.createProviderExtension) DefaultProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension) ProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.ProviderExtension) DefaultProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with DefaultProviderExtension

use of org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ExtensionLoaderTest method bootServiceExtensions_withOptionalDependency_onlyDefault.

@Test
@DisplayName("bootServiceExtensions - Should invoke default provider for optional dependency")
void bootServiceExtensions_withOptionalDependency_onlyDefault() {
    var dependentExtension = createDependentExtension(false);
    var defaultProvider = (DefaultProviderExtension) spy(createProviderExtension(true));
    when(defaultProvider.testObject()).thenCallRealMethod();
    var context = new DefaultServiceExtensionContext(new TypeManager(), mock(Monitor.class), null, List.of());
    var list = createInjectionContainers(createList(dependentExtension, defaultProvider));
    ExtensionLoader.bootServiceExtensions(list, context);
    verify(defaultProvider, times(1)).testObject();
    assertThat(context.getService(TestObject.class)).isNotNull();
}
Also used : ConsoleMonitor(org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor) MultiplexingMonitor(org.eclipse.dataspaceconnector.spi.monitor.MultiplexingMonitor) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) DefaultProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with DefaultProviderExtension

use of org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ExtensionLoaderTest method bootServiceExtensions_withSingleDefaultProvider_andNonDefault.

@Test
@DisplayName("bootServiceExtensions - Should only invoke non-default provider")
void bootServiceExtensions_withSingleDefaultProvider_andNonDefault() {
    var dependentExtension = createDependentExtension(true);
    var defaultProvider = (DefaultProviderExtension) spy(createProviderExtension(true));
    var nonDefaultProvider = (ProviderExtension) spy(createProviderExtension(false));
    when(nonDefaultProvider.testObject()).thenCallRealMethod();
    var context = new DefaultServiceExtensionContext(new TypeManager(), mock(Monitor.class), null, List.of());
    var list = createInjectionContainers(createList(defaultProvider, dependentExtension, nonDefaultProvider));
    ExtensionLoader.bootServiceExtensions(list, context);
    verify(defaultProvider, never()).testObject();
    verify(nonDefaultProvider, times(1)).testObject();
}
Also used : ConsoleMonitor(org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor) MultiplexingMonitor(org.eclipse.dataspaceconnector.spi.monitor.MultiplexingMonitor) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) TestFunctions.createProviderExtension(org.eclipse.dataspaceconnector.boot.system.TestFunctions.createProviderExtension) DefaultProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension) ProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.ProviderExtension) DefaultProviderExtension(org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DefaultProviderExtension (org.eclipse.dataspaceconnector.boot.system.testextensions.DefaultProviderExtension)4 ConsoleMonitor (org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor)4 Monitor (org.eclipse.dataspaceconnector.spi.monitor.Monitor)4 MultiplexingMonitor (org.eclipse.dataspaceconnector.spi.monitor.MultiplexingMonitor)4 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)4 DisplayName (org.junit.jupiter.api.DisplayName)4 Test (org.junit.jupiter.api.Test)4 TestFunctions.createProviderExtension (org.eclipse.dataspaceconnector.boot.system.TestFunctions.createProviderExtension)2 ProviderExtension (org.eclipse.dataspaceconnector.boot.system.testextensions.ProviderExtension)2