From 64d6865b7897e47314296d149454e0e2fc3e14a1 Mon Sep 17 00:00:00 2001 From: Gael Leblan Date: Sun, 13 Oct 2024 00:39:15 +0200 Subject: [PATCH] [frontend/backend] Chaining injects conditionally --- .../scheduler/jobs/InjectsExecutionJob.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java b/openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java index c11321a2d3..4a54e4b578 100644 --- a/openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java +++ b/openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java @@ -55,11 +55,8 @@ public class InjectsExecutionJob implements Job { private final ExecutionExecutorService executionExecutorService; private final AtomicTestingService atomicTestingService; private final InjectDependenciesRepository injectDependenciesRepository; - private final ExerciseExpectationService exerciseExpectationService; private final InjectExpectationRepository injectExpectationRepository; - private static final String EXPECTATIONS = "expectations"; - private final List executionStatusesNotReady = List.of(ExecutionStatus.QUEUING, ExecutionStatus.DRAFT, ExecutionStatus.EXECUTING, ExecutionStatus.PENDING); @@ -238,6 +235,12 @@ private void executeInject(ExecutableInject executableInject) { } } + /** + * Get error messages if pre execution conditions are not met + * @param exerciseId the id of the exercise + * @param inject the inject to check + * @return an optional of list of error message + */ private Optional> getErrorMessagesPreExecution(String exerciseId, Inject inject) { List injectDependencies = injectDependenciesRepository.findParents(List.of(inject.getId())); if (!injectDependencies.isEmpty()) { @@ -272,6 +275,13 @@ private Optional> getErrorMessagesPreExecution(String exerciseId, I return Optional.empty(); } + /** + * Get a map containing the expectations and if they are met or not + * @param parents the parents injects + * @param exerciseId the id of the exercise + * @param injectDependencies the list of dependencies + * @return a map of expectations and their value + */ private @NotNull Map getStringBooleanMap(List parents, String exerciseId, List injectDependencies) { Map mapCondition = new HashMap<>();