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();
}
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();
}
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();
}
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();
}
Aggregations