Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] Update spring boot to v3.4.0 - abandoned #2075

Open
wants to merge 4 commits into
base: release/current
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[backend] Fix tests
  • Loading branch information
RomuDeuxfois committed Dec 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0b3fbb1d5145c95ee9d560ebf3d3265b25e4f983
40 changes: 24 additions & 16 deletions openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package io.openbas.injects;

import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT;
import static io.openbas.utils.fixtures.ExerciseFixture.getExercise;
import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;

import io.openbas.IntegrationTest;
import io.openbas.database.model.Exercise;
import io.openbas.database.model.Inject;
@@ -15,24 +21,14 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT;
import static io.openbas.utils.fixtures.ExerciseFixture.getExercise;
import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;

@TestInstance(PER_CLASS)
class InjectCrudTest extends IntegrationTest {

@Autowired
private InjectorContractRepository injectorContractRepository;
@Autowired
private InjectRepository injectRepository;
@Autowired private InjectorContractRepository injectorContractRepository;
@Autowired private InjectRepository injectRepository;

@Autowired
private ExerciseService exerciseService;
@Autowired
private ExerciseRepository exerciseRepository;
@Autowired private ExerciseService exerciseService;
@Autowired private ExerciseRepository exerciseRepository;

private static String EXERCISE_ID;
private static String INJECT_ID;
@@ -49,13 +45,25 @@ void afterAll() {
void createInjectSuccess() {
// -- PREPARE --
Exercise exercise = this.exerciseService.createExercise(getExercise());
assertNotNull(exercise.getId(), "Exercise ID should not be null after creation.");
EXERCISE_ID = exercise.getId();
InjectorContract contract = injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow();

InjectorContract contract =
injectorContractRepository
.findById(EMAIL_DEFAULT)
.orElseThrow(() -> new IllegalStateException("Injector contract not found."));
Inject inject = createDefaultInjectEmail(contract);
inject.setExercise(exercise);

// -- EXECUTE --
Inject injectCreated = this.injectRepository.save(inject);
assertNotNull(injectCreated.getId(), "Inject ID should not be null after saving.");
INJECT_ID = injectCreated.getId();
assertNotNull(injectCreated);

// -- VALIDATE --
assertNotNull(injectCreated.getExercise(), "Inject should reference a valid Exercise.");
assertNotNull(
injectRepository.findById(injectCreated.getId()),
"Inject should be persisted in the database.");
}
}
Original file line number Diff line number Diff line change
@@ -27,8 +27,7 @@ public static Inject createDefaultInjectEmail(InjectorContract injectorContract)
}

public static Inject createDefaultInjectChallenge(
InjectorContract injectorContract, ObjectMapper objectMapper, List<String> challengeIds
) {
InjectorContract injectorContract, ObjectMapper objectMapper, List<String> challengeIds) {
Inject inject = createInject(injectorContract, INJECT_CHALLENGE_NAME);

ChallengeContent content = new ChallengeContent();
@@ -38,8 +37,7 @@ public static Inject createDefaultInjectChallenge(
}

public static Inject createInjectCommandPayload(
InjectorContract injectorContract, Map<String, String> payloadArguments
) {
InjectorContract injectorContract, Map<String, String> payloadArguments) {

Inject inject = createInject(injectorContract, "Inject title");
ObjectMapper objectMapper = new ObjectMapper();