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;
}
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);
}
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);
}
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));
}
Aggregations