Skip to content

Commit

Permalink
[frontend/backend] Chaining injects conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimfacion committed Oct 12, 2024
1 parent 973f6be commit 64d6865
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExecutionStatus> executionStatusesNotReady =
List.of(ExecutionStatus.QUEUING, ExecutionStatus.DRAFT, ExecutionStatus.EXECUTING, ExecutionStatus.PENDING);

Expand Down Expand Up @@ -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<List<String>> getErrorMessagesPreExecution(String exerciseId, Inject inject) {
List<InjectDependency> injectDependencies = injectDependenciesRepository.findParents(List.of(inject.getId()));

Check warning on line 245 in openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java

View check run for this annotation

Codecov / codecov/patch

openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java#L245

Added line #L245 was not covered by tests
if (!injectDependencies.isEmpty()) {
Expand Down Expand Up @@ -272,6 +275,13 @@ private Optional<List<String>> getErrorMessagesPreExecution(String exerciseId, I
return Optional.empty();

Check warning on line 275 in openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java

View check run for this annotation

Codecov / codecov/patch

openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java#L275

Added line #L275 was not covered by tests
}

/**
* 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<String, Boolean> getStringBooleanMap(List<Inject> parents, String exerciseId, List<InjectDependency> injectDependencies) {
Map<String, Boolean> mapCondition = new HashMap<>();

Check warning on line 286 in openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java

View check run for this annotation

Codecov / codecov/patch

openbas-api/src/main/java/io/openbas/scheduler/jobs/InjectsExecutionJob.java#L286

Added line #L286 was not covered by tests

Expand Down

0 comments on commit 64d6865

Please sign in to comment.