use of org.guvnor.ala.runtime.providers.Provider in project kie-wb-common by kiegroup.
the class RuntimeProvisioningServiceBackendImplTest method testGetProviders.
@Test
public void testGetProviders() {
List<Provider> values = mockList(Provider.class, ELEMENTS_COUNT);
ProviderList list = new ProviderList(values);
when(runtimeProvisioningService.getProviders(PAGE, PAGE_SIZE, SORT, SORT_ORDER)).thenReturn(list);
List<Provider> result = runtimeProvisioningServiceBackend.getProviders(PAGE, PAGE_SIZE, SORT, SORT_ORDER);
verify(runtimeProvisioningService, times(1)).getProviders(PAGE, PAGE_SIZE, SORT, SORT_ORDER);
assertEquals(values, result);
}
use of org.guvnor.ala.runtime.providers.Provider 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.Provider in project kie-wb-common by kiegroup.
the class WildflyProviderConfigExecutor method apply.
@Override
public Optional<WildflyProvider> apply(final WildflyProviderConfig wildflyProviderConfig) {
if (wildflyProviderConfig.getName() == null || wildflyProviderConfig.getName().isEmpty()) {
throw new ProvisioningException("No name was provided for the WildflyProviderConfig.getName() " + "configuration parameter. You might probably have to properly set " + "the pipeline input parameter: " + ProviderConfig.PROVIDER_NAME);
}
Provider provider = runtimeRegistry.getProvider(wildflyProviderConfig.getName());
WildflyProvider wildflyProvider;
if (provider != null) {
if (!(provider instanceof WildflyProvider)) {
throw new ProvisioningException("The provider: " + wildflyProviderConfig.getName() + " must be an instance of " + WildflyProviderConfig.class + " but is: " + provider.getClass());
} else {
wildflyProvider = (WildflyProvider) provider;
}
} else {
wildflyProvider = new WildflyProviderImpl(new WildflyProviderConfigImpl(wildflyProviderConfig.getName(), wildflyProviderConfig.getHost(), wildflyProviderConfig.getPort(), wildflyProviderConfig.getManagementPort(), wildflyProviderConfig.getUser(), wildflyProviderConfig.getPassword()));
runtimeRegistry.registerProvider(wildflyProvider);
}
return Optional.of(wildflyProvider);
}
use of org.guvnor.ala.runtime.providers.Provider in project kie-wb-common by kiegroup.
the class InMemoryRuntimeRegistryTest method testGetProvidersByType.
@Test
public void testGetProvidersByType() {
ProviderType providerType1 = mockProviderTypeSPI("ProviderType1");
ProviderType providerType2 = mockProviderTypeSPI("ProviderType2");
List<Provider> providers = mockProviderListSPI(providerType, "1", ELEMENTS_COUNT);
List<Provider> providersForType1 = mockProviderListSPI(providerType1, "2", ELEMENTS_COUNT);
List<Provider> providersForType2 = mockProviderListSPI(providerType2, ELEMENTS_COUNT);
List<Provider> allProviders = new ArrayList<>();
allProviders.addAll(providers);
allProviders.addAll(providersForType1);
allProviders.addAll(providersForType2);
allProviders.forEach(provider -> runtimeRegistry.registerProvider(provider));
List<Provider> result = runtimeRegistry.getProvidersByType(providerType);
assertEquals(providers.size(), result.size());
for (Provider provider : providers) {
assertTrue(result.contains(provider));
}
}
use of org.guvnor.ala.runtime.providers.Provider in project kie-wb-common by kiegroup.
the class InMemoryRuntimeRegistryTest method testGetProvider.
@Test
public void testGetProvider() {
Provider result = runtimeRegistry.getProvider(provider.getId());
assertNull(result);
runtimeRegistry.registerProvider(provider);
result = runtimeRegistry.getProvider(provider.getId());
assertEquals(provider, result);
}
Aggregations