public boolean removeItem(final RuntimeKey runtimeKey) { final Optional<RuntimePresenter> value = currentItems.stream() .filter(presenter -> presenter.getItem().isRuntime() && runtimeKey.equals(presenter.getItem().getRuntime().getKey())) .findFirst(); value.ifPresent(this::removeItem); return value.isPresent(); }
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); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RuntimeListItem that = (RuntimeListItem) o; if (itemLabel != null ? !itemLabel.equals(that.itemLabel) : that.itemLabel != null) { return false; } if (runtime != null ? !runtime.equals(that.runtime) : that.runtime != null) { return false; } return pipelineTrace != null ? pipelineTrace.equals(that.pipelineTrace) : that.pipelineTrace == null; }
private void assertRuntime(Runtime runtime) { assertEquals(RUNTIME_ID, runtime.getKey().getId()); assertEquals(PROVIDER_NAME, runtime.getKey().getProviderKey().getProviderTypeKey().getId()); assertEquals(PROVIDER_VERSION, runtime.getKey().getProviderKey().getProviderTypeKey().getVersion()); assertEquals(PROVIDER_NAME, runtime.getKey().getProviderKey().getProviderTypeKey().getId()); assertEquals(PROVIDER_ID, runtime.getKey().getProviderKey().getId()); assertEquals(RUNTIME_ENDPOINT, runtime.getEndpoint()); assertEquals(RUNTIME_STARTED_AT, runtime.getCreatedDate()); assertEquals(RUNTIME_STATUS, runtime.getStatus()); }
final Runtime runtime = new Runtime(new RuntimeKey(new ProviderKey(new ProviderTypeKey(item.getProviderTypeName(), item.getProviderVersion()), item.getProviderId()), item.getRuntimeEndpoint(), item.getStartedAt()); runtime.setPipelineTrace(pipelineTrace); result = new RuntimeListItem(runtimeName, runtime);
@Test public void testBuildRuntimeWithPipelineExecution() { prepareRuntime(); preparePipelineTrace(); RuntimeListItem result = RuntimeListItemBuilder.newInstance().withItem(queryResultItem).build(); assertTrue(result.isRuntime()); assertNotNull(result.getRuntime()); assertNotNull(result.getRuntime().getPipelineTrace()); assertNull(result.getPipelineTrace()); assertRuntime(result.getRuntime()); assertPipelineTrace(result.getRuntime().getPipelineTrace()); }
private void processRuntimeStatus(final Runtime runtime) { view.clearActionItems(); enableActions(true); view.addActionItem(startAction.getView()); view.addActionItem(stopAction.getView()); view.addActionItem(separator.getView()); view.addActionItem(deleteAction.getView()); startAction.setup(translationService.getTranslation(RuntimePresenter_RuntimeStartAction), this::startRuntime); stopAction.setup(translationService.getTranslation(RuntimePresenter_RuntimeStopAction), this::stopRuntime); deleteAction.setup(translationService.getTranslation(RuntimePresenter_RuntimeDeleteAction), this::deleteRuntime); RuntimeStatus runtimeStatus = buildRuntimeStatus(runtime.getStatus()); if (RUNNING == runtimeStatus) { startAction.setEnabled(false); } if (STOPPED == runtimeStatus || READY == runtimeStatus) { stopAction.setEnabled(false); } view.setStatus(buildIconStyle(runtimeStatus)); view.setStatusTitle(runtime.getStatus()); }
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; }
/** * 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); }
@Override public int hashCode() { int result = itemLabel != null ? itemLabel.hashCode() : 0; result = ~~result; result = 31 * result + (runtime != null ? runtime.hashCode() : 0); result = ~~result; result = 31 * result + (pipelineTrace != null ? pipelineTrace.hashCode() : 0); result = ~~result; return result; } }
private void assertRuntime(Runtime runtime) { assertEquals(RUNTIME_ID, runtime.getKey().getId()); assertEquals(PROVIDER_NAME, runtime.getKey().getProviderKey().getProviderTypeKey().getId()); assertEquals(PROVIDER_VERSION, runtime.getKey().getProviderKey().getProviderTypeKey().getVersion()); assertEquals(PROVIDER_NAME, runtime.getKey().getProviderKey().getProviderTypeKey().getId()); assertEquals(PROVIDER_ID, runtime.getKey().getProviderKey().getId()); assertEquals(RUNTIME_ENDPOINT, runtime.getEndpoint()); assertEquals(RUNTIME_STARTED_AT, runtime.getCreatedDate()); assertEquals(RUNTIME_STATUS, runtime.getStatus()); }
@Test public void testBuildRuntimeWithPipelineExecution() { prepareRuntime(); preparePipelineTrace(); RuntimeListItem result = RuntimeListItemBuilder.newInstance().withItem(queryResultItem).build(); assertTrue(result.isRuntime()); assertNotNull(result.getRuntime()); assertNotNull(result.getRuntime().getPipelineTrace()); assertNull(result.getPipelineTrace()); assertRuntime(result.getRuntime()); assertPipelineTrace(result.getRuntime().getPipelineTrace()); }
private void processRuntimeStatus(final Runtime runtime) { view.clearActionItems(); enableActions(true, startAction, stopAction, deleteAction); view.addActionItem(startAction.getView()); view.addActionItem(stopAction.getView()); view.addActionItem(separator.getView()); view.addActionItem(deleteAction.getView()); startAction.setup(translationService.getTranslation(RuntimePresenter_RuntimeStartAction), this::startRuntime); stopAction.setup(translationService.getTranslation(RuntimePresenter_RuntimeStopAction), this::stopRuntime); deleteAction.setup(translationService.getTranslation(RuntimePresenter_RuntimeDeleteAction), this::deleteRuntime); RuntimeStatus runtimeStatus = buildRuntimeStatus(runtime.getStatus()); if (RUNNING == runtimeStatus) { startAction.setEnabled(false); } if (STOPPED == runtimeStatus || READY == runtimeStatus) { stopAction.setEnabled(false); } view.setStatus(buildIconStyle(runtimeStatus)); view.setStatusTitle(runtime.getStatus()); }
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; }
/** * 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); }
@Override public int hashCode() { int result = itemLabel != null ? itemLabel.hashCode() : 0; result = ~~result; result = 31 * result + (runtime != null ? runtime.hashCode() : 0); result = ~~result; result = 31 * result + (pipelineTrace != null ? pipelineTrace.hashCode() : 0); result = ~~result; return result; } }
public boolean removeItem(final RuntimeKey runtimeKey) { final Optional<RuntimePresenter> value = currentItems.stream() .filter(presenter -> presenter.getItem().isRuntime() && runtimeKey.equals(presenter.getItem().getRuntime().getKey())) .findFirst(); value.ifPresent(this::removeItem); return value.isPresent(); }
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); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RuntimeListItem that = (RuntimeListItem) o; if (itemLabel != null ? !itemLabel.equals(that.itemLabel) : that.itemLabel != null) { return false; } if (runtime != null ? !runtime.equals(that.runtime) : that.runtime != null) { return false; } return pipelineTrace != null ? pipelineTrace.equals(that.pipelineTrace) : that.pipelineTrace == null; }
private boolean isFromCurrentRuntime(final RuntimeKey runtimeKey) { return item != null && item.isRuntime() && item.getRuntime().getKey().equals(runtimeKey); }