Search in sources :

Example 21 with RuntimeListItem

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

the class RuntimePresenterSetupsTest method testSetupRuntimeWithTrace.

/**
 * Tests the case when the item is a Runtime with pipeline execution trace.
 */
@Test
public void testSetupRuntimeWithTrace() {
    runtime = mockRuntime();
    preparePipelineExecutionTraceSetup();
    item = new RuntimeListItem(RUNTIME_NAME, trace);
    // set the trace on the runtime.
    runtime.setPipelineTrace(trace);
    item = new RuntimeListItem(RUNTIME_NAME, runtime);
    presenter.setup(item);
    verify(pipelinePresenter, times(2)).clearStages();
    verify(view, times(1)).setup(RUNTIME_NAME, CREATED_DATE, PIPELINE_NAME);
    verify(view, times(1)).setEndpoint(ENDPOINT);
    verifyPipelineWasSet(trace, displayableStages);
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) Test(org.junit.Test)

Example 22 with RuntimeListItem

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

the class RuntimePresenterSetupsTest method testOnPipelineStatusChange.

@Test
public void testOnPipelineStatusChange() {
    preparePipelineExecutionTraceSetup();
    RuntimeListItem item = new RuntimeListItem(RUNTIME_NAME, trace);
    // setup the presenter.
    presenter.setup(item);
    // the pipeline finishes
    presenter.onPipelineStatusChange(new PipelineStatusChangeEvent(trace.getKey(), PipelineStatus.FINISHED));
    verify(view, times(1)).setStatus(RuntimePresenterHelper.buildIconStyle(PipelineStatus.FINISHED));
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) PipelineStatusChangeEvent(org.guvnor.ala.ui.events.PipelineStatusChangeEvent) Test(org.junit.Test)

Example 23 with RuntimeListItem

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

the class RuntimeListItemBuilder method build.

public RuntimeListItem build() {
    RuntimeListItem result;
    PipelineExecutionTrace pipelineTrace;
    String runtimeName;
    if (item.getRuntimeName() != null) {
        runtimeName = item.getRuntimeName();
    } else {
        runtimeName = item.getRuntimeId();
    }
    if (item.getPipelineExecutionId() != null) {
        final Pipeline pipeline = new Pipeline(new PipelineKey(item.getPipelineId()));
        pipelineTrace = new PipelineExecutionTrace(new PipelineExecutionTraceKey(item.getPipelineExecutionId()));
        pipelineTrace.setPipelineStatus(transformToPipelineStatus(item.getPipelineStatus()));
        pipelineTrace.setPipelineError(new PipelineError(item.getPipelineError(), item.getPipelineErrorDetail()));
        item.getPipelineStageItems().getItems().forEach(stage -> {
            pipeline.addStage(new Stage(pipeline.getKey(), stage.getName()));
            pipelineTrace.setStageStatus(stage.getName(), transformToPipelineStatus(stage.getStatus()));
            pipelineTrace.setStageError(stage.getName(), new PipelineError(stage.getStageError(), stage.getStageErrorDetail()));
        });
        pipelineTrace.setPipeline(pipeline);
    } else {
        pipelineTrace = null;
    }
    if (item.getRuntimeId() != null) {
        final Runtime runtime = new Runtime(new RuntimeKey(new ProviderKey(new ProviderTypeKey(item.getProviderTypeName(), item.getProviderVersion()), item.getProviderId()), item.getRuntimeId()), item.getRuntimeStatus(), item.getRuntimeEndpoint(), item.getStartedAt());
        runtime.setPipelineTrace(pipelineTrace);
        result = new RuntimeListItem(runtimeName, runtime);
    } else {
        result = new RuntimeListItem(runtimeName, pipelineTrace);
    }
    return result;
}
Also used : Runtime(org.guvnor.ala.ui.model.Runtime) RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) PipelineKey(org.guvnor.ala.ui.model.PipelineKey) ProviderKey(org.guvnor.ala.ui.model.ProviderKey) PipelineExecutionTrace(org.guvnor.ala.ui.model.PipelineExecutionTrace) Stage(org.guvnor.ala.ui.model.Stage) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) PipelineExecutionTraceKey(org.guvnor.ala.ui.model.PipelineExecutionTraceKey) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) Pipeline(org.guvnor.ala.ui.model.Pipeline) PipelineError(org.guvnor.ala.ui.model.PipelineError)

Example 24 with RuntimeListItem

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

the class RuntimeListItemBuilderTest method testPipelineTraceBuild.

@Test
public void testPipelineTraceBuild() {
    preparePipelineTrace();
    RuntimeListItem result = RuntimeListItemBuilder.newInstance().withItem(queryResultItem).build();
    assertFalse(result.isRuntime());
    assertNotNull(result.getPipelineTrace());
    assertNull(result.getRuntime());
    assertPipelineTrace(result.getPipelineTrace());
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) Test(org.junit.Test)

Example 25 with RuntimeListItem

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

the class RuntimeListItemBuilderTest method testBuildRuntimeWithNoPipelineExecution.

@Test
public void testBuildRuntimeWithNoPipelineExecution() {
    prepareRuntime();
    RuntimeListItem result = RuntimeListItemBuilder.newInstance().withItem(queryResultItem).build();
    assertTrue(result.isRuntime());
    assertNotNull(result.getRuntime());
    assertNull(result.getPipelineTrace());
    assertRuntime(result.getRuntime());
}
Also used : RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) Test(org.junit.Test)

Aggregations

RuntimeListItem (org.guvnor.ala.ui.model.RuntimeListItem)29 Test (org.junit.Test)23 PipelineExecutionTraceKey (org.guvnor.ala.ui.model.PipelineExecutionTraceKey)7 RuntimeQuery (org.guvnor.ala.services.api.RuntimeQuery)5 RuntimeKey (org.guvnor.ala.ui.model.RuntimeKey)5 RuntimeQueryResultItem (org.guvnor.ala.services.api.RuntimeQueryResultItem)4 ProviderKey (org.guvnor.ala.ui.model.ProviderKey)4 Stage (org.guvnor.ala.ui.model.Stage)3 ArrayList (java.util.ArrayList)2 StagePresenter (org.guvnor.ala.ui.client.widget.pipeline.stage.StagePresenter)2 PipelineExecutionChangeEvent (org.guvnor.ala.ui.events.PipelineExecutionChangeEvent)2 StageStatusChangeEvent (org.guvnor.ala.ui.events.StageStatusChangeEvent)2 PipelineError (org.guvnor.ala.ui.model.PipelineError)2 PipelineExecutionTrace (org.guvnor.ala.ui.model.PipelineExecutionTrace)2 ProviderTypeKey (org.guvnor.ala.ui.model.ProviderTypeKey)2 Runtime (org.guvnor.ala.ui.model.Runtime)2 PipelineStatusChangeEvent (org.guvnor.ala.ui.events.PipelineStatusChangeEvent)1 Pipeline (org.guvnor.ala.ui.model.Pipeline)1 PipelineKey (org.guvnor.ala.ui.model.PipelineKey)1 Provider (org.guvnor.ala.ui.model.Provider)1