use of org.guvnor.ala.pipeline.execution.PipelineExecutorTrace in project kie-wb-common by kiegroup.
the class InMemoryPipelineExecutorRegistryTest method testGetExecutorTraces.
@Test
public void testGetExecutorTraces() {
List<PipelineExecutorTrace> traces = new ArrayList<>();
for (int i = 0; i < TRACES_COUNT; i++) {
PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class);
when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID + Integer.toString(i));
traces.add(trace);
}
traces.forEach(trace -> pipelineExecutorRegistry.register(trace));
Collection<PipelineExecutorTrace> result = pipelineExecutorRegistry.getExecutorTraces();
assertEquals(traces.size(), result.size());
for (PipelineExecutorTrace trace : traces) {
assertTrue(result.contains(trace));
}
}
use of org.guvnor.ala.pipeline.execution.PipelineExecutorTrace in project kie-wb-common by kiegroup.
the class VFSPipelineExecutorRegistryTest method testInit.
@Test
public void testInit() throws Exception {
traces = new ArrayList<>();
for (int i = 0; i < TRACES_COUNT; i++) {
PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class);
when(trace.getTaskId()).thenReturn(PIPELINE_EXECUTION_ID + Integer.toString(i));
traces.add(trace);
}
when(registryHelper.readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(TRACE_SUFFIX))).thenReturn(traces);
((VFSPipelineExecutorRegistry) pipelineExecutorRegistry).init();
verify(registryHelper, times(2)).ensureDirectory(PIPELINE_EXECUTOR_REGISTRY_PATH);
verify(registryHelper, times(2)).readEntries(registryRoot, VFSRegistryHelper.BySuffixFilter.newFilter(TRACE_SUFFIX));
for (Object trace : traces) {
PipelineExecutorTrace result = pipelineExecutorRegistry.getExecutorTrace(((PipelineExecutorTrace) trace).getTaskId());
assertNotNull(result);
assertEquals(trace, result);
}
}
use of org.guvnor.ala.pipeline.execution.PipelineExecutorTrace in project kie-wb-common by kiegroup.
the class PipelineExecutorTaskManagerImpl method delete.
@Override
public void delete(final String taskId) throws PipelineExecutorException {
final TaskEntry entry = getTaskEntry(taskId);
if (entry != null) {
throw new PipelineExecutorException("An active PipelineExecutorTask was found for taskId: " + taskId + " delete operation is only available for the following status set: " + deleteEnabledStatus);
}
final PipelineExecutorTrace trace = pipelineExecutorRegistry.getExecutorTrace(taskId);
if (trace == null) {
throw new PipelineExecutorException("No PipelineExecutorTask was found for taskId: " + taskId);
} else {
if (!deleteEnabledStatus.contains(trace.getTask().getPipelineStatus())) {
throw new PipelineExecutorException("A PipelineExecutorTask in status: " + trace.getTask().getPipelineStatus().name() + " can not" + " be deleted. Delete operation is available for the following status set: " + deleteEnabledStatus);
} else {
pipelineExecutorRegistry.deregister(taskId);
}
}
}
use of org.guvnor.ala.pipeline.execution.PipelineExecutorTrace in project kie-wb-common by kiegroup.
the class PipelineExecutorTaskManagerImplExecutionTest method testDeleteTask.
@Test
public void testDeleteTask() throws Exception {
PipelineExecutorTrace trace = mock(PipelineExecutorTrace.class);
PipelineExecutorTask task = mock(PipelineExecutorTask.class);
PipelineExecutorTask.Status status = PipelineExecutorTask.Status.STOPPED;
when(task.getPipelineStatus()).thenReturn(status);
when(trace.getTask()).thenReturn(task);
when(pipelineExecutorRegistry.getExecutorTrace(TASK_ID)).thenReturn(trace);
taskManager.delete(TASK_ID);
verify(pipelineExecutorRegistry, times(1)).deregister(TASK_ID);
}
use of org.guvnor.ala.pipeline.execution.PipelineExecutorTrace in project kie-wb-common by kiegroup.
the class InMemoryPipelineExecutorRegistryTest method testDeregister.
@Test
public void testDeregister() {
pipelineExecutorRegistry.register(trace);
PipelineExecutorTrace result = pipelineExecutorRegistry.getExecutorTrace(PIPELINE_EXECUTION_ID);
assertEquals(trace, result);
pipelineExecutorRegistry.deregister(trace.getTaskId());
result = pipelineExecutorRegistry.getExecutorTrace(PIPELINE_EXECUTION_ID);
assertNull(result);
}
Aggregations