@Test void testAddStateWhenOperationHasState() { Operation mockedOperation = createMockedOperation(PROCESS_ID, ProcessType.DEPLOY, Operation.State.RUNNING); Operation operation = operationsHelper.addState(mockedOperation); Assertions.assertEquals(Operation.State.RUNNING, operation.getState()); }
public Operation addState(Operation operation) { if (operation.getState() != null) { return operation; } Operation.State state = computeState(operation); if (operation.hasAcquiredLock() && (state.equals(Operation.State.ABORTED) || state.equals(Operation.State.FINISHED))) { operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .build(); operationService.update(operation, operation); } return ImmutableOperation.copyOf(operation) .withState(state); }
OperationsHelper { public Operation addState(Operation operation) { if (operation.getState() != null) { return operation; } Operation.State state = computeState(operation); if (operation.hasAcquiredLock() && (state.equals(Operation.State.ABORTED) || state.equals(Operation.State.FINISHED))) { operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .build(); operationService.update(operation, operation); } return ImmutableOperation.copyOf(operation) .withState(state); } }
OperationsHelper { public Operation addState(Operation operation) { if (operation.getState() != null) { return operation; } Operation.State state = computeState(operation); if (operation.hasAcquiredLock() && (state.equals(Operation.State.ABORTED) || state.equals(Operation.State.FINISHED))) { operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .build(); operationService.update(operation, operation); } return ImmutableOperation.copyOf(operation) .withState(state); } @Inject  OperationsHelper(OperationService operationService, ProcessTypeToOperationMetadataMapper metadataMapper,
                            ProcessHelper processHelper); }
OperationsHelper { public Operation addState(Operation operation) { if (operation.getState() != null) { return operation; } Operation.State state = computeState(operation); if (operation.hasAcquiredLock() && (state.equals(Operation.State.ABORTED) || state.equals(Operation.State.FINISHED))) { operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .build(); operationService.update(operation, operation); } return ImmutableOperation.copyOf(operation) .withState(state); } @Inject  OperationsHelper(OperationService operationService, ProcessTypeToOperationMetadataMapper metadataMapper,
                            ProcessHelper processHelper); String getProcessDefinitionKey(Operation operation); Operation addErrorType(Operation operation); Operation addState(Operation operation); Operation.State computeState(Operation operation); Operation.State computeProcessState(String processId); List<Operation> findOperations(List<Operation> operations, List<Operation.State> statusList); }
OperationsHelper { public Operation addState(Operation operation) { if (operation.getState() != null) { return operation; } Operation.State state = computeState(operation); if (operation.hasAcquiredLock() && (state.equals(Operation.State.ABORTED) || state.equals(Operation.State.FINISHED))) { operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .build(); operationService.update(operation, operation); } return ImmutableOperation.copyOf(operation) .withState(state); } @Inject  OperationsHelper(OperationService operationService, ProcessTypeToOperationMetadataMapper metadataMapper,
                            ProcessHelper processHelper); String getProcessDefinitionKey(Operation operation); Operation addErrorType(Operation operation); Operation addState(Operation operation); Operation.State computeState(Operation operation); Operation.State computeProcessState(String processId); List<Operation> findOperations(List<Operation> operations, List<Operation.State> statusList);  }