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());
}
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;
}
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);
}
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;
}
Aggregations