use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method createProcessEntity.
private ProcessEntity createProcessEntity(Integer priority, ZonedDateTime initTime) {
ProcessEntity processEntity = new ProcessEntity();
processEntity.setProcessId(PipeliteIdCreator.processId());
processEntity.setPriority(priority);
processEntity.setCreateTime(initTime);
return processEntity;
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method lifecycle.
@Test
public void lifecycle() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
int priority = 1;
ProcessEntity processEntity = processService.createExecution(pipelineName, processId, priority);
assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getPriority()).isEqualTo(priority);
assertThat(processEntity.getExecutionCount()).isEqualTo(0);
assertThat(processEntity.getStartTime()).isNull();
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.PENDING);
processService.startExecution(processEntity);
assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getPriority()).isEqualTo(priority);
assertThat(processEntity.getExecutionCount()).isEqualTo(0);
assertThat(processEntity.getStartTime()).isNotNull();
assertThat(processEntity.getEndTime()).isNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
assertThat(processService.getSavedProcess(pipelineName, processId).get()).isEqualTo(processEntity);
Process process = new ProcessBuilder(processId).execute("STAGE").withSyncTestExecutor().build();
process.setProcessEntity(processEntity);
processService.endExecution(process, ProcessState.COMPLETED);
assertThat(processEntity.getPipelineName()).isEqualTo(pipelineName);
assertThat(processEntity.getProcessId()).isEqualTo(processId);
assertThat(processEntity.getPriority()).isEqualTo(priority);
assertThat(processEntity.getExecutionCount()).isEqualTo(1);
assertThat(processEntity.getStartTime()).isNotNull();
assertThat(processEntity.getEndTime()).isNotNull();
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
assertThat(processService.getSavedProcess(pipelineName, processId).get()).isEqualTo(processEntity);
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method getProcesses.
@Test
public void getProcesses() {
String pipelineName = PipeliteIdCreator.pipelineName();
List<ProcessEntity> processes = Arrays.asList(saveProcess(pipelineName, ProcessState.ACTIVE, 1), saveProcess(pipelineName, ProcessState.ACTIVE, 1), saveProcess(pipelineName, ProcessState.COMPLETED, 1), saveProcess(pipelineName, ProcessState.COMPLETED, 1), saveProcess(pipelineName, ProcessState.FAILED, 1), saveProcess(pipelineName, ProcessState.FAILED, 1), saveProcess(pipelineName, ProcessState.PENDING, 1), saveProcess(pipelineName, ProcessState.PENDING, 1));
// Test without state.
assertProcessStateCount(processService.getProcesses(pipelineName, null, /* state*/
MAX_PROCESS_COUNT), 2, 2, 2, 2);
for (ProcessState state : EnumSet.of(ProcessState.ACTIVE, ProcessState.COMPLETED, ProcessState.FAILED, ProcessState.CANCELLED)) {
assertProcessStateCount(processService.getProcesses(pipelineName, state, MAX_PROCESS_COUNT), state == ProcessState.COMPLETED ? 2 : 0, state == ProcessState.ACTIVE ? 2 : 0, state == ProcessState.FAILED ? 2 : 0, state == ProcessState.PENDING ? 2 : 0);
}
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method saveProcess.
private ProcessEntity saveProcess(String pipelineName, ProcessState state, int priority) {
ProcessEntity processEntity = ProcessEntity.createExecution(pipelineName, PipeliteIdCreator.processId(), priority);
processEntity.setProcessState(state);
processEntity.setExecutionCount(0);
return processService.saveProcess(processEntity);
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessServiceTest method isRetryProcessWithNotFailedProcess.
@Test
public void isRetryProcessWithNotFailedProcess() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
int priority = 1;
ProcessEntity processEntity = processService.createExecution(pipelineName, processId, priority);
processEntity.endExecution(ProcessState.COMPLETED);
processService.saveProcess(processEntity);
assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.COMPLETED);
assertThrows(PipeliteProcessRetryException.class, () -> processService.isRetryProcess(pipelineName, processId));
}
Aggregations