-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00ed6d3
commit f924f8d
Showing
5 changed files
with
29 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ public class InjectHelperTest { | |
void injectsToRunTest() { | ||
// -- PREPARE -- | ||
Exercise exercise = new Exercise(); | ||
exercise.setName("Exercice name"); | ||
exercise.setName("Exercise name"); | ||
exercise.setStart(Instant.now()); | ||
exercise.setFrom("[email protected]"); | ||
exercise.setReplyTos(List.of("[email protected]")); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ class InjectCrudTest { | |
void createInjectSuccess() { | ||
// -- PREPARE -- | ||
Exercise exercise = new Exercise(); | ||
exercise.setName("Exercice name"); | ||
exercise.setName("Exercise name"); | ||
exercise.setFrom("[email protected]"); | ||
exercise.setReplyTos(List.of("[email protected]")); | ||
Exercise exerciseCreated = this.exerciseRepository.save(exercise); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,7 @@ | |
import io.openbas.database.repository.*; | ||
import io.openbas.rest.exercise.form.ExpectationUpdateInput; | ||
import io.openbas.utils.fixtures.InjectExpectationFixture; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.*; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
|
@@ -57,6 +54,11 @@ void beforeAll() { | |
getInjectExpectation(injectCreated, teamCreated, exerciseCreated); | ||
} | ||
|
||
@AfterAll | ||
void afterAll() { | ||
this.exerciseRepository.deleteById(EXERCISE_ID); | ||
} | ||
|
||
@DisplayName("Retrieve inject expectations") | ||
@Test | ||
void retrieveInjectExpectations() { | ||
|
@@ -86,7 +88,7 @@ void updateInjectExpectation() { | |
|
||
protected Exercise getExercise() { | ||
Exercise exercise = new Exercise(); | ||
exercise.setName("Exercice name"); | ||
exercise.setName("Exercise name"); | ||
exercise.setStatus(SCHEDULED); | ||
exercise.setFrom("[email protected]"); | ||
exercise.setReplyTos(List.of("[email protected]")); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ public class InjectTestStatusServiceTest { | |
@BeforeAll | ||
void beforeAll() { | ||
Exercise exercise = new Exercise(); | ||
exercise.setName("Exercice name"); | ||
exercise.setName("Exercise name"); | ||
exercise.setFrom("[email protected]"); | ||
exercise.setReplyTos(List.of("[email protected]")); | ||
EXERCISE = this.exerciseRepository.save(exercise); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,10 @@ | |
import java.util.NoSuchElementException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; | ||
|
||
@SpringBootTest | ||
@TestInstance(PER_CLASS) | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class VariableServiceTest { | ||
|
||
|
@@ -23,24 +25,32 @@ public class VariableServiceTest { | |
@Autowired | ||
private ExerciseRepository exerciseRepository; | ||
|
||
static String EXERCISE_ID; | ||
static Exercise EXERCISE; | ||
static String VARIABLE_ID; | ||
|
||
@BeforeAll | ||
void beforeAll() { | ||
Exercise exercise = new Exercise(); | ||
exercise.setName("Exercise name"); | ||
exercise.setFrom("[email protected]"); | ||
exercise.setReplyTos(List.of("[email protected]")); | ||
EXERCISE = this.exerciseRepository.save(exercise); | ||
} | ||
|
||
@AfterAll | ||
void afterAll() { | ||
this.exerciseRepository.deleteById(EXERCISE.getId()); | ||
} | ||
|
||
@DisplayName("Create variable") | ||
@Test | ||
@Order(1) | ||
void createVariableTest() { | ||
// -- PREPARE -- | ||
Exercise exercise = new Exercise(); | ||
exercise.setName("Exercice name"); | ||
exercise.setFrom("[email protected]"); | ||
exercise.setReplyTos(List.of("[email protected]")); | ||
Exercise exerciseCreated = this.exerciseRepository.save(exercise); | ||
EXERCISE_ID = exerciseCreated.getId(); | ||
Variable variable = new Variable(); | ||
String variableKey = "key"; | ||
variable.setKey(variableKey); | ||
variable.setExercise(exerciseCreated); | ||
variable.setExercise(EXERCISE); | ||
|
||
// -- EXECUTE -- | ||
Variable variableCreated = this.variableService.createVariable(variable); | ||
|
@@ -60,7 +70,7 @@ void retrieveVariableTest() { | |
Variable variable = this.variableService.variable(VARIABLE_ID); | ||
assertNotNull(variable); | ||
|
||
List<Variable> variables = this.variableService.variablesFromExercise(EXERCISE_ID); | ||
List<Variable> variables = this.variableService.variablesFromExercise(EXERCISE.getId()); | ||
assertNotNull(variable); | ||
assertEquals(VARIABLE_ID, variables.get(0).getId()); | ||
} | ||
|