@Test void testExecuteOperationActionInvalidAction() { assertThrows(IllegalArgumentException.class, () -> testedClass.executeOperationAction(mockHttpServletRequest(EXAMPLE_USER), SPACE_GUID, RUNNING_PROCESS, Action.START.getActionId())); }
@Override public ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId) { Operation operation = getOperation(operationId); List<String> availableOperations = getAvailableActions(operation); if (!availableOperations.contains(actionId)) { throw new IllegalArgumentException(MessageFormat.format(Messages.ACTION_0_CANNOT_BE_EXECUTED_OVER_OPERATION_1_IN_STATE_2, actionId, operationId, operation.getState())); } ProcessAction action = processActionRegistry.getAction(Action.fromString(actionId)); action.execute(getAuthenticatedUser(request), operationId); AuditLoggingProvider.getFacade() .logAboutToStart(MessageFormat.format("{0} over operation with id {1}", action, operation.getProcessId())); return ResponseEntity.accepted() .header("Location", getLocationHeader(operationId, spaceGuid)) .build(); }
OperationsApiServiceImpl implements OperationsApiService { @Override public ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId) { Operation operation = getOperation(operationId); List<String> availableOperations = getAvailableActions(operation); if (!availableOperations.contains(actionId)) { throw new IllegalArgumentException(MessageFormat.format(Messages.ACTION_0_CANNOT_BE_EXECUTED_OVER_OPERATION_1_IN_STATE_2, actionId, operationId, operation.getState())); } ProcessAction action = processActionRegistry.getAction(Action.fromString(actionId)); action.execute(getAuthenticatedUser(request), operationId); AuditLoggingProvider.getFacade() .logAboutToStart(MessageFormat.format("{0} over operation with id {1}", action, operation.getProcessId())); return ResponseEntity.accepted() .header("Location", getLocationHeader(operationId, spaceGuid)) .build(); } }
OperationsApiServiceImpl implements OperationsApiService { @Override public ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId) { Operation operation = getOperation(operationId); List<String> availableOperations = getAvailableActions(operation); if (!availableOperations.contains(actionId)) { throw new IllegalArgumentException(MessageFormat.format(Messages.ACTION_0_CANNOT_BE_EXECUTED_OVER_OPERATION_1_IN_STATE_2, actionId, operationId, operation.getState())); } ProcessAction action = processActionRegistry.getAction(Action.fromString(actionId)); action.execute(getAuthenticatedUser(request), operationId); AuditLoggingProvider.getFacade() .logAboutToStart(MessageFormat.format("{0} over operation with id {1}", action, operation.getProcessId())); return ResponseEntity.accepted() .header("Location", getLocationHeader(operationId, spaceGuid)) .build(); }  }
OperationsApiServiceImpl implements OperationsApiService { @Override public ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId) { Operation operation = getOperation(operationId); List<String> availableOperations = getAvailableActions(operation); if (!availableOperations.contains(actionId)) { throw new IllegalArgumentException(MessageFormat.format(Messages.ACTION_0_CANNOT_BE_EXECUTED_OVER_OPERATION_1_IN_STATE_2, actionId, operationId, operation.getState())); } ProcessAction action = processActionRegistry.getAction(Action.fromString(actionId)); action.execute(getAuthenticatedUser(request), operationId); AuditLoggingProvider.getFacade() .logAboutToStart(MessageFormat.format("{0} over operation with id {1}", action, operation.getProcessId())); return ResponseEntity.accepted() .header("Location", getLocationHeader(operationId, spaceGuid)) .build(); }  @Override ResponseEntity<List<Operation>> getOperations(String spaceGuid, String mtaId, List<String> stateStrings, Integer last); @Override ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId); @Override ResponseEntity<List<Log>> getOperationLogs(String spaceGuid, String operationId); @Override ResponseEntity<String> getOperationLogContent(String spaceGuid, String operationId, String logId); @Override ResponseEntity<Operation> startOperation(HttpServletRequest request, String spaceGuid, Operation operation); @Override ResponseEntity<Operation> getOperation(String spaceGuid, String operationId, String embed); @Override ResponseEntity<List<String>> getOperationActions(String spaceGuid, String operationId); }
OperationsApiServiceImpl implements OperationsApiService { @Override public ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId) { Operation operation = getOperation(operationId); List<String> availableOperations = getAvailableActions(operation); if (!availableOperations.contains(actionId)) { throw new IllegalArgumentException(MessageFormat.format(Messages.ACTION_0_CANNOT_BE_EXECUTED_OVER_OPERATION_1_IN_STATE_2, actionId, operationId, operation.getState())); } ProcessAction action = processActionRegistry.getAction(Action.fromString(actionId)); action.execute(getAuthenticatedUser(request), operationId); AuditLoggingProvider.getFacade() .logAboutToStart(MessageFormat.format("{0} over operation with id {1}", action, operation.getProcessId())); return ResponseEntity.accepted() .header("Location", getLocationHeader(operationId, spaceGuid)) .build(); }  @Override ResponseEntity<List<Operation>> getOperations(String spaceGuid, String mtaId, List<String> stateStrings, Integer last); @Override ResponseEntity<Void> executeOperationAction(HttpServletRequest request, String spaceGuid, String operationId, String actionId); @Override ResponseEntity<List<Log>> getOperationLogs(String spaceGuid, String operationId); @Override ResponseEntity<String> getOperationLogContent(String spaceGuid, String operationId, String logId); @Override ResponseEntity<Operation> startOperation(HttpServletRequest request, String spaceGuid, Operation operation); @Override ResponseEntity<Operation> getOperation(String spaceGuid, String operationId, String embed); @Override ResponseEntity<List<String>> getOperationActions(String spaceGuid, String operationId);  }