Search in sources :

Example 11 with Provider

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

the class ProviderConverterImpl method toModel.

/**
 * @param provider A provider representation in the guvnor-ala core domain.
 * @return the converted version of the provider in the format managed by the UI related modules.
 */
@Override
public Provider toModel(org.guvnor.ala.runtime.providers.Provider provider) {
    Provider result = null;
    if (provider != null) {
        ProviderTypeKey providerTypeKey = new ProviderTypeKey(provider.getProviderType().getProviderTypeName(), provider.getProviderType().getVersion());
        ProviderKey providerKey = new ProviderKey(providerTypeKey, provider.getId());
        final BackendProviderHandler handler = handlerRegistry.ensureHandler(providerTypeKey);
        @SuppressWarnings("unchecked") final ProviderConfiguration providerConfiguration = (ProviderConfiguration) handler.getProviderConfigConverter().toModel(provider.getConfig());
        result = new Provider(providerKey, providerConfiguration);
    }
    return result;
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) BackendProviderHandler(org.guvnor.ala.ui.backend.service.handler.BackendProviderHandler) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) Provider(org.guvnor.ala.ui.model.Provider) ProviderConfiguration(org.guvnor.ala.ui.model.ProviderConfiguration)

Example 12 with Provider

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

the class ProviderServiceImplTest method setUp.

@Before
public void setUp() {
    providerTypeSpi = mockProviderTypeSPI("0");
    providersSpi = mockProviderListSPI(providerTypeSpi, PROVIDER_COUNT);
    when(runtimeProvisioningService.getProviders(anyInt(), anyInt(), anyString(), anyBoolean())).thenReturn(providersSpi);
    providerTypeKey = new ProviderTypeKey(providerTypeSpi.getProviderTypeName(), providerTypeSpi.getVersion());
    providerType = new ProviderType(providerTypeKey, null);
    when(providerConverterFactory.getProviderConverter()).thenReturn(providerConverter);
    when(providerConverterFactory.getProviderConfigConverter(providerTypeKey)).thenReturn(providerConfigConverter);
    providers = new ArrayList<>();
    providerKeys = new ArrayList<>();
    for (int i = 0; i < PROVIDER_COUNT; i++) {
        Provider provider = mock(Provider.class);
        ProviderTypeKey providerTypeKey = new ProviderTypeKey(providersSpi.get(i).getProviderType().getProviderTypeName(), providersSpi.get(i).getProviderType().getVersion());
        ProviderKey providerKey = new ProviderKey(providerTypeKey, providersSpi.get(i).getId());
        when(provider.getKey()).thenReturn(providerKey);
        providers.add(provider);
        providerKeys.add(providerKey);
        when(providerConverter.toModel(providersSpi.get(i))).thenReturn(provider);
    }
    service = new ProviderServiceImpl(runtimeProvisioningService, providerConverterFactory);
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) ProviderType(org.guvnor.ala.ui.model.ProviderType) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) Provider(org.guvnor.ala.ui.model.Provider) Before(org.junit.Before)

Example 13 with Provider

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

the class ProviderServiceImplTest method testGetProviderNotExisting.

@Test
public void testGetProviderNotExisting() {
    // create an arbitrary not existing key.
    ProviderTypeKey providerTypeKey = new ProviderTypeKey("not exist", "not exist");
    ProviderKey providerKey = new ProviderKey(providerTypeKey, "not exist");
    Provider provider = service.getProvider(providerKey);
    assertNull(provider);
}
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 14 with Provider

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

the class RuntimeServiceImplTest method testCreateRuntimeWhenProviderExistsButRuntimeNameExitsts.

@Test
public void testCreateRuntimeWhenProviderExistsButRuntimeNameExitsts() {
    Provider provider = mock(Provider.class);
    ProviderTypeKey providerTypeKey = new ProviderTypeKey(PROVIDER_NAME, PROVIDER_VERSION);
    ProviderKey providerKey = new ProviderKey(providerTypeKey, PROVIDER_ID);
    List<RuntimeQueryResultItem> items = mock(List.class);
    // the provider exists, so validation continues
    when(providerService.getProvider(providerKey)).thenReturn(provider);
    // but the runtime name already exists.
    when(runtimeProvisioningService.executeQuery(RuntimeQueryBuilder.newInstance().withRuntimeName(RUNTIME_ID).build())).thenReturn(items);
    when(items.isEmpty()).thenReturn(false);
    expectedException.expectMessage("A runtime with the given name already exists: " + RUNTIME_ID);
    service.createRuntime(providerKey, RUNTIME_ID, PIPELINE_KEY, mock(Map.class));
    verify(pipelineService, never()).runPipeline(anyString(), any(Input.class), eq(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) Map(java.util.Map) 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