Search in sources :

Example 1 with Provider

use of org.guvnor.ala.ui.model.Provider in project kie-wb-common by kiegroup.

the class ProvisioningScreensServiceImpl method getRuntimesInfo.

@Override
public RuntimesInfo getRuntimesInfo(final ProviderKey providerKey) {
    checkNotNull("providerKey", providerKey);
    final Provider provider = providerService.getProvider(providerKey);
    if (provider == null) {
        return null;
    }
    final Collection<RuntimeListItem> items = runtimeService.getRuntimeItems(providerKey);
    return new RuntimesInfo(provider, items);
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) RuntimesInfo(org.guvnor.ala.ui.model.RuntimesInfo) Provider(org.guvnor.ala.ui.model.Provider)

Example 2 with Provider

use of org.guvnor.ala.ui.model.Provider in project kie-wb-common by kiegroup.

the class ProviderServiceImplTest method testGetProviderExisting.

@Test
public void testGetProviderExisting() {
    // pick one of the existing providers.
    org.guvnor.ala.runtime.providers.Provider providerSpi = providersSpi.get(2);
    // create a key for finding it.
    ProviderTypeKey providerTypeKey = new ProviderTypeKey(providerSpi.getProviderType().getProviderTypeName(), providerSpi.getProviderType().getVersion());
    ProviderKey providerKey = new ProviderKey(providerTypeKey, providerSpi.getId());
    Provider provider = service.getProvider(providerKey);
    assertNotNull(provider);
    assertEquals(providers.get(2).getKey(), provider.getKey());
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) Provider(org.guvnor.ala.ui.model.Provider) Test(org.junit.Test)

Example 3 with Provider

use of org.guvnor.ala.ui.model.Provider in project kie-wb-common by kiegroup.

the class RuntimeServiceImplTest method testCreateRuntimeWhenUnExpectedError.

@Test
public void testCreateRuntimeWhenUnExpectedError() {
    Provider provider = mock(Provider.class);
    ProviderTypeKey providerTypeKey = new ProviderTypeKey(PROVIDER_NAME, PROVIDER_VERSION);
    ProviderKey providerKey = new ProviderKey(providerTypeKey, PROVIDER_ID);
    when(providerService.getProvider(providerKey)).thenReturn(provider);
    when(pipelineService.runPipeline(anyString(), any(Input.class), eq(true))).thenThrow(new RuntimeException(ERROR_MESSAGE));
    expectedException.expectMessage(ERROR_MESSAGE);
    service.createRuntime(providerKey, "irrelevant for the test", mock(PipelineKey.class), mock(Map.class));
}
Also used : Input(org.guvnor.ala.pipeline.Input) ProviderKey(org.guvnor.ala.ui.model.ProviderKey) PipelineKey(org.guvnor.ala.ui.model.PipelineKey) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) Map(java.util.Map) Provider(org.guvnor.ala.ui.model.Provider) Test(org.junit.Test)

Example 4 with Provider

use of org.guvnor.ala.ui.model.Provider in project kie-wb-common by kiegroup.

the class RuntimeServiceImplTest method testCreateRuntimeSuccessful.

@Test
public void testCreateRuntimeSuccessful() {
    Provider provider = mock(Provider.class);
    ProviderTypeKey providerTypeKey = new ProviderTypeKey(PROVIDER_NAME, PROVIDER_VERSION);
    ProviderKey providerKey = new ProviderKey(providerTypeKey, PROVIDER_ID);
    Map<String, String> params = PipelineInputBuilderTest.mockParams(PARAMS_COUNT);
    List<RuntimeQueryResultItem> items = mock(List.class);
    when(providerService.getProvider(providerKey)).thenReturn(provider);
    when(runtimeProvisioningService.executeQuery(RuntimeQueryBuilder.newInstance().withRuntimeName(RUNTIME_ID).build())).thenReturn(items);
    when(items.isEmpty()).thenReturn(true);
    Input expectedInput = PipelineInputBuilder.newInstance().withProvider(providerKey).withRuntimeName(RUNTIME_ID).withParams(params).build();
    service.createRuntime(providerKey, RUNTIME_ID, PIPELINE_KEY, params);
    verify(pipelineService, times(1)).runPipeline(PIPELINE, expectedInput, true);
}
Also used : Input(org.guvnor.ala.pipeline.Input) ProviderKey(org.guvnor.ala.ui.model.ProviderKey) RuntimeQueryResultItem(org.guvnor.ala.services.api.RuntimeQueryResultItem) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) Provider(org.guvnor.ala.ui.model.Provider) Test(org.junit.Test)

Example 5 with Provider

use of org.guvnor.ala.ui.model.Provider in project kie-wb-common by kiegroup.

the class ProviderConverterImplTest method testToModelWhenHandlerIsConfigured.

@Test
public void testToModelWhenHandlerIsConfigured() {
    when(handlerRegistry.ensureHandler(providerTypeKey)).thenReturn(providerHandler);
    when(providerHandler.getProviderConfigConverter()).thenReturn(providerConfigConverter);
    when(providerConfigConverter.toModel(providerConfig)).thenReturn(providerConfiguration);
    Provider result = converter.toModel(provider);
    assertNotNull(result);
    assertEquals(PROVIDER_ID, result.getKey().getId());
    assertEquals(PROVIDER_TYPE_NAME, result.getKey().getProviderTypeKey().getId());
    assertEquals(PROVIDER_VERSION, result.getKey().getProviderTypeKey().getVersion());
    assertEquals(result.getConfiguration(), providerConfiguration);
}
Also used : Provider(org.guvnor.ala.ui.model.Provider) Test(org.junit.Test)

Aggregations

Provider (org.guvnor.ala.ui.model.Provider)14 ProviderKey (org.guvnor.ala.ui.model.ProviderKey)9 Test (org.junit.Test)9 ProviderTypeKey (org.guvnor.ala.ui.model.ProviderTypeKey)8 ProviderConfiguration (org.guvnor.ala.ui.model.ProviderConfiguration)5 Input (org.guvnor.ala.pipeline.Input)3 RuntimeQueryResultItem (org.guvnor.ala.services.api.RuntimeQueryResultItem)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 PipelineKey (org.guvnor.ala.ui.model.PipelineKey)2 RuntimesInfo (org.guvnor.ala.ui.model.RuntimesInfo)2 ProvisioningManagementTestCommons.mockProviderTypeKey (org.guvnor.ala.ui.ProvisioningManagementTestCommons.mockProviderTypeKey)1 BackendProviderHandler (org.guvnor.ala.ui.backend.service.handler.BackendProviderHandler)1 AddNewRuntimeEvent (org.guvnor.ala.ui.client.events.AddNewRuntimeEvent)1 ServiceException (org.guvnor.ala.ui.exceptions.ServiceException)1 ProviderType (org.guvnor.ala.ui.model.ProviderType)1 RuntimeListItem (org.guvnor.ala.ui.model.RuntimeListItem)1 Before (org.junit.Before)1