Search in sources :

Example 1 with Runtime

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

the class ProviderStatusPresenterTest method testRemoveExistingRuntime.

@Test
public void testRemoveExistingRuntime() {
    RuntimeKey keyToRemove = mock(RuntimeKey.class);
    List<RuntimeListItem> items = mockItems(ITEMS_COUNT);
    // pick an arbitrary element as the existing runtime.
    int index = 1;
    RuntimeListItem item = items.get(index);
    Runtime runtime = mock(Runtime.class);
    when(runtime.getKey()).thenReturn(keyToRemove);
    when(item.isRuntime()).thenReturn(true);
    when(item.getRuntime()).thenReturn(runtime);
    presenter.setupItems(items);
    for (int i = 0; i < ITEMS_COUNT; i++) {
        when(runtimePresenters.get(i).getItem()).thenReturn(items.get(i));
    }
    assertTrue(presenter.removeItem(keyToRemove));
    verify(runtimePresenterInstance, times(1)).destroy(runtimePresenters.get(index));
    verify(view, times(1)).removeListItem(runtimePresenters.get(index).getView());
}
Also used : Runtime(org.guvnor.ala.ui.model.Runtime) RuntimeListItem(org.guvnor.ala.ui.model.RuntimeListItem) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) Test(org.junit.Test)

Example 2 with Runtime

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

the class RuntimePresenterTest method mockRuntime.

protected Runtime mockRuntime() {
    ProviderTypeKey providerTypeKey = mockProviderTypeKey("1");
    ProviderKey providerKey = mockProviderKey(providerTypeKey, "1");
    RuntimeKey runtimeKey = new RuntimeKey(providerKey, RUNTIME_ID);
    Runtime runtime = new Runtime(runtimeKey, RUNTIME_NAME, null, RUNTIME_STATUS, ENDPOINT, CREATED_DATE);
    return runtime;
}
Also used : Runtime(org.guvnor.ala.ui.model.Runtime) ProviderKey(org.guvnor.ala.ui.model.ProviderKey) ProvisioningManagementTestCommons.mockProviderKey(org.guvnor.ala.ui.ProvisioningManagementTestCommons.mockProviderKey) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) ProvisioningManagementTestCommons.mockProviderTypeKey(org.guvnor.ala.ui.ProvisioningManagementTestCommons.mockProviderTypeKey)

Example 3 with Runtime

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

the class RuntimePresenter method setupRuntime.

private void setupRuntime(RuntimeListItem item) {
    String itemLabel = item.getItemLabel();
    String pipelineName = SYSTEM_PIPELINE_NAME;
    String createdDate = item.getRuntime().getCreatedDate();
    String endpoint = "";
    Runtime runtime = item.getRuntime();
    PipelineExecutionTrace trace = runtime.getPipelineTrace();
    if (trace != null) {
        pipelineName = trace.getPipeline().getKey().getId();
        setupPipeline(trace);
    }
    view.setup(itemLabel, createdDate, pipelineName);
    if (runtime.getEndpoint() != null) {
        endpoint = runtime.getEndpoint();
    }
    view.setEndpoint(endpoint);
    processRuntimeStatus(runtime);
}
Also used : Runtime(org.guvnor.ala.ui.model.Runtime) PipelineExecutionTrace(org.guvnor.ala.ui.model.PipelineExecutionTrace)

Example 4 with Runtime

use of org.guvnor.ala.ui.model.Runtime 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)

Aggregations

Runtime (org.guvnor.ala.ui.model.Runtime)4 RuntimeKey (org.guvnor.ala.ui.model.RuntimeKey)3 PipelineExecutionTrace (org.guvnor.ala.ui.model.PipelineExecutionTrace)2 ProviderKey (org.guvnor.ala.ui.model.ProviderKey)2 ProviderTypeKey (org.guvnor.ala.ui.model.ProviderTypeKey)2 RuntimeListItem (org.guvnor.ala.ui.model.RuntimeListItem)2 ProvisioningManagementTestCommons.mockProviderKey (org.guvnor.ala.ui.ProvisioningManagementTestCommons.mockProviderKey)1 ProvisioningManagementTestCommons.mockProviderTypeKey (org.guvnor.ala.ui.ProvisioningManagementTestCommons.mockProviderTypeKey)1 Pipeline (org.guvnor.ala.ui.model.Pipeline)1 PipelineError (org.guvnor.ala.ui.model.PipelineError)1 PipelineExecutionTraceKey (org.guvnor.ala.ui.model.PipelineExecutionTraceKey)1 PipelineKey (org.guvnor.ala.ui.model.PipelineKey)1 Stage (org.guvnor.ala.ui.model.Stage)1 Test (org.junit.Test)1