Search in sources :

Example 6 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)

Example 7 with RuntimeQueryResultItem

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

the class RuntimeServiceImplTest method getRuntimeItemByRuntimeKeyExisting.

@Test
public void getRuntimeItemByRuntimeKeyExisting() {
    ProviderKey providerKey = mock(ProviderKey.class);
    RuntimeKey runtimeKey = new RuntimeKey(providerKey, RUNTIME_ID);
    List<RuntimeQueryResultItem> singleResult = mockRuntimeQueryResultItemList(1);
    when(runtimeProvisioningService.executeQuery(any(RuntimeQuery.class))).thenReturn(singleResult);
    RuntimeListItem expectedItem = buildExpectedResult(singleResult).iterator().next();
    RuntimeListItem result = service.getRuntimeItem(runtimeKey);
    assertEquals(expectedItem, 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) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) Test(org.junit.Test)

Example 8 with RuntimeQueryResultItem

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

Example 9 with RuntimeQueryResultItem

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

the class RuntimeServiceImplTest method getRuntimeItemByPipelineExecutionKeyNotExisting.

@Test
public void getRuntimeItemByPipelineExecutionKeyNotExisting() {
    PipelineExecutionTraceKey traceKey = new PipelineExecutionTraceKey(PIPELINE_EXECUTION_ID);
    List<RuntimeQueryResultItem> singleResult = new ArrayList<>();
    when(runtimeProvisioningService.executeQuery(any(RuntimeQuery.class))).thenReturn(singleResult);
    RuntimeListItem result = service.getRuntimeItem(traceKey);
    assertNull(result);
}
Also used : 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) PipelineExecutionTraceKey(org.guvnor.ala.ui.model.PipelineExecutionTraceKey) 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 Input (org.guvnor.ala.pipeline.Input)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 RuntimeQueryResultItemList (org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList)1 ServiceException (org.guvnor.ala.ui.exceptions.ServiceException)1