Search in sources :

Example 6 with Provider

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);
}
Also used : ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) Provider(org.guvnor.ala.runtime.providers.Provider) Test(org.junit.Test)

Example 7 with Provider

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));
}
Also used : Provider(org.guvnor.ala.runtime.providers.Provider) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RuntimeRegistry(org.guvnor.ala.registry.RuntimeRegistry) PortablePreconditions.checkNotNull(org.kie.soup.commons.validation.PortablePreconditions.checkNotNull) ProviderType(org.guvnor.ala.runtime.providers.ProviderType) ProviderId(org.guvnor.ala.runtime.providers.ProviderId) Collectors(java.util.stream.Collectors) List(java.util.List) RuntimeId(org.guvnor.ala.runtime.RuntimeId) Map(java.util.Map) Optional(java.util.Optional) PageSortUtil(org.guvnor.ala.registry.inmemory.util.PageSortUtil) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Runtime(org.guvnor.ala.runtime.Runtime) Provider(org.guvnor.ala.runtime.providers.Provider)

Example 8 with 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);
}
Also used : WildflyProviderConfig(org.guvnor.ala.wildfly.config.WildflyProviderConfig) WildflyProviderImpl(org.guvnor.ala.wildfly.model.WildflyProviderImpl) ProvisioningException(org.guvnor.ala.exceptions.ProvisioningException) WildflyProviderConfigImpl(org.guvnor.ala.wildfly.config.impl.WildflyProviderConfigImpl) Provider(org.guvnor.ala.runtime.providers.Provider) WildflyProvider(org.guvnor.ala.wildfly.model.WildflyProvider) WildflyProvider(org.guvnor.ala.wildfly.model.WildflyProvider)

Example 9 with Provider

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));
    }
}
Also used : ArrayList(java.util.ArrayList) ProviderType(org.guvnor.ala.runtime.providers.ProviderType) Provider(org.guvnor.ala.runtime.providers.Provider) Test(org.junit.Test)

Example 10 with 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);
}
Also used : Provider(org.guvnor.ala.runtime.providers.Provider) Test(org.junit.Test)

Aggregations

Provider (org.guvnor.ala.runtime.providers.Provider)10 Test (org.junit.Test)6 ProviderType (org.guvnor.ala.runtime.providers.ProviderType)3 ProviderList (org.guvnor.ala.services.api.itemlist.ProviderList)3 ArrayList (java.util.ArrayList)2 DockerProviderConfig (org.guvnor.ala.docker.config.DockerProviderConfig)2 DockerProvider (org.guvnor.ala.docker.model.DockerProvider)2 ProvisioningException (org.guvnor.ala.exceptions.ProvisioningException)2 ProviderTypeList (org.guvnor.ala.services.api.itemlist.ProviderTypeList)2 RuntimeList (org.guvnor.ala.services.api.itemlist.RuntimeList)2 RuntimeQueryResultItemList (org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList)2 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)1 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)1