use of org.guvnor.ala.runtime.providers.ProviderId in project kie-wb-common by kiegroup.
the class InMemoryRuntimeRegistry method getProvider.
@Override
public <T extends Provider> Optional<T> getProvider(final ProviderId providerId, final Class<T> clazz) {
checkNotNull("providerId", providerId);
checkNotNull("clazz", clazz);
final Provider value = providers.get(providerId.getId());
return Optional.ofNullable(value).filter(provider -> clazz.isInstance(provider)).map(provider -> clazz.cast(provider));
}
use of org.guvnor.ala.runtime.providers.ProviderId in project kie-wb-common by kiegroup.
the class InMemoryRuntimeRegistryTest method getProvider.
@Test
public void getProvider() {
MockProvider mockProvider = new MockProvider(PROVIDER_ID, providerType);
ProviderId providerId = mock(ProviderId.class);
when(providerId.getId()).thenReturn(PROVIDER_ID);
when(providerId.getProviderType()).thenReturn(providerType);
runtimeRegistry.registerProvider(mockProvider);
Optional<MockProvider> result = runtimeRegistry.getProvider(providerId, MockProvider.class);
assertTrue(result.isPresent());
assertEquals(mockProvider, result.get());
}
Aggregations