Search in sources :

Example 6 with PipelineExecutorTrace

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));
    }
}
Also used : PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with PipelineExecutorTrace

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);
    }
}
Also used : PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) Test(org.junit.Test) InMemoryPipelineExecutorRegistryTest(org.guvnor.ala.registry.inmemory.InMemoryPipelineExecutorRegistryTest)

Example 8 with PipelineExecutorTrace

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);
        }
    }
}
Also used : PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) PipelineExecutorException(org.guvnor.ala.pipeline.execution.PipelineExecutorException)

Example 9 with PipelineExecutorTrace

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);
}
Also used : PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) PipelineExecutorTask(org.guvnor.ala.pipeline.execution.PipelineExecutorTask) Test(org.junit.Test)

Example 10 with PipelineExecutorTrace

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);
}
Also used : PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) Test(org.junit.Test)

Aggregations

PipelineExecutorTrace (org.guvnor.ala.pipeline.execution.PipelineExecutorTrace)12 Test (org.junit.Test)9 PipelineExecutorTask (org.guvnor.ala.pipeline.execution.PipelineExecutorTask)3 InMemoryPipelineExecutorRegistryTest (org.guvnor.ala.registry.inmemory.InMemoryPipelineExecutorRegistryTest)3 ArrayList (java.util.ArrayList)1 PipelineExecutorException (org.guvnor.ala.pipeline.execution.PipelineExecutorException)1 Runtime (org.guvnor.ala.runtime.Runtime)1 BusinessException (org.guvnor.ala.services.exceptions.BusinessException)1 ExpectedException (org.junit.rules.ExpectedException)1 StartsWith (org.mockito.internal.matchers.StartsWith)1