Search in sources :

Example 1 with RuntimeQueryResultItem

use of org.guvnor.ala.services.api.RuntimeQueryResultItem in project kie-wb-common by kiegroup.

the class RuntimeServiceImplTest method getRuntimeItemByPipelineExecutionKeyExisting.

@Test
public void getRuntimeItemByPipelineExecutionKeyExisting() {
    PipelineExecutionTraceKey traceKey = new PipelineExecutionTraceKey(PIPELINE_EXECUTION_ID);
    List<RuntimeQueryResultItem> singleResult = mockRuntimeQueryResultItemList(1);
    when(runtimeProvisioningService.executeQuery(any(RuntimeQuery.class))).thenReturn(singleResult);
    RuntimeListItem expectedItem = buildExpectedResult(singleResult).iterator().next();
    RuntimeListItem result = service.getRuntimeItem(traceKey);
    assertEquals(expectedItem, result);
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery) RuntimeQueryResultItem(org.guvnor.ala.services.api.RuntimeQueryResultItem) PipelineExecutionTraceKey(org.guvnor.ala.ui.model.PipelineExecutionTraceKey) Test(org.junit.Test)

Example 2 with RuntimeQueryResultItem

use of org.guvnor.ala.services.api.RuntimeQueryResultItem in project kie-wb-common by kiegroup.

the class RuntimeServiceImplTest method mockRuntimeQueryResultItem.

private RuntimeQueryResultItem mockRuntimeQueryResultItem(String suffix, int stageItemsCount) {
    RuntimeQueryResultItem item = new RuntimeQueryResultItem();
    item.setProviderId("RuntimeQueryResultItem.providerId." + suffix);
    item.setProviderTypeName("RuntimeQueryResultItem.providerTypeName." + suffix);
    item.setProviderVersion("RuntimeQueryResultItem.providerVersion." + suffix);
    item.setPipelineId("RuntimeQueryResultItem.pipelineId." + suffix);
    item.setPipelineExecutionId("RuntimeQueryResultItem.pipelineExecutionId." + suffix);
    item.setPipelineStatus("RUNNING");
    item.setPipelineError("RuntimeQueryResultItem.pipelineError." + suffix);
    item.setPipelineStageItems(mockPipelineStageItemList(stageItemsCount));
    item.setRuntimeId("RuntimeQueryResultItem.runtimeId." + suffix);
    item.setRuntimeName("RuntimeQueryResultItem.runtimeName." + suffix);
    item.setRuntimeStatus("RUNNING");
    item.setStartedAt("RuntimeQueryResultItem.startedAt." + suffix);
    item.setRuntimeEndpoint("RuntimeQueryResultItem.runtimeEndpoint." + suffix);
    return item;
}
Also used : RuntimeQueryResultItem(org.guvnor.ala.services.api.RuntimeQueryResultItem)

Example 3 with RuntimeQueryResultItem

use of org.guvnor.ala.services.api.RuntimeQueryResultItem 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 4 with RuntimeQueryResultItem

use of org.guvnor.ala.services.api.RuntimeQueryResultItem in project kie-wb-common by kiegroup.

the class RuntimeProvisioningServiceBackendImplTest method testExecuteQuery.

@Test
public void testExecuteQuery() {
    RuntimeQuery query = mock(RuntimeQuery.class);
    List<RuntimeQueryResultItem> values = mockList(RuntimeQueryResultItem.class, ELEMENTS_COUNT);
    RuntimeQueryResultItemList list = new RuntimeQueryResultItemList(values);
    when(runtimeProvisioningService.executeQuery(query)).thenReturn(list);
    List<RuntimeQueryResultItem> result = runtimeProvisioningServiceBackend.executeQuery(query);
    verify(runtimeProvisioningService, times(1)).executeQuery(query);
    assertEquals(values, result);
}
Also used : RuntimeQueryResultItemList(org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList) RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery) RuntimeQueryResultItem(org.guvnor.ala.services.api.RuntimeQueryResultItem) Test(org.junit.Test)

Example 5 with RuntimeQueryResultItem

use of org.guvnor.ala.services.api.RuntimeQueryResultItem in project kie-wb-common by kiegroup.

the class RuntimeServiceImplTest method getRuntimeItemByRuntimeKeyNotExisting.

@Test
public void getRuntimeItemByRuntimeKeyNotExisting() {
    ProviderKey providerKey = mock(ProviderKey.class);
    RuntimeKey runtimeKey = new RuntimeKey(providerKey, RUNTIME_ID);
    List<RuntimeQueryResultItem> singleResult = new ArrayList<>();
    when(runtimeProvisioningService.executeQuery(any(RuntimeQuery.class))).thenReturn(singleResult);
    RuntimeListItem result = service.getRuntimeItem(runtimeKey);
    assertNull(result);
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery) RuntimeQueryResultItem(org.guvnor.ala.services.api.RuntimeQueryResultItem) ArrayList(java.util.ArrayList) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) Test(org.junit.Test)

Aggregations

RuntimeQueryResultItem (org.guvnor.ala.services.api.RuntimeQueryResultItem)9 Test (org.junit.Test)7 RuntimeQuery (org.guvnor.ala.services.api.RuntimeQuery)5 ProviderKey (org.guvnor.ala.ui.model.ProviderKey)4 RuntimeListItem (org.guvnor.ala.ui.model.RuntimeListItem)4 Provider (org.guvnor.ala.ui.model.Provider)3 ArrayList (java.util.ArrayList)2 PipelineExecutionTraceKey (org.guvnor.ala.ui.model.PipelineExecutionTraceKey)2 ProviderTypeKey (org.guvnor.ala.ui.model.ProviderTypeKey)2 RuntimeKey (org.guvnor.ala.ui.model.RuntimeKey)2 Map (java.util.Map)1 Input (org.guvnor.ala.pipeline.Input)1 RuntimeQueryResultItemList (org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList)1 ServiceException (org.guvnor.ala.ui.exceptions.ServiceException)1