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]Test launch/relaunch/pause of a simulation (#1488) #2025

Open
wants to merge 14 commits into
base: release/1.10.0
Choose a base branch
from

Conversation

johanah29
Copy link
Member

@johanah29 johanah29 changed the title Issue/1488 release [Backend]Test launch/relaunch/pause of a simulation (#1488) Dec 10, 2024
@johanah29 johanah29 self-assigned this Dec 10, 2024
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.60%. Comparing base (e90b943) to head (0188db8).

Additional details and impacted files
@@                 Coverage Diff                  @@
##             release/1.10.0    #2025      +/-   ##
====================================================
+ Coverage             34.06%   34.60%   +0.54%     
- Complexity             1305     1331      +26     
====================================================
  Files                   522      522              
  Lines                 15720    15720              
  Branches                976      976              
====================================================
+ Hits                   5355     5440      +85     
+ Misses                10102    10010      -92     
- Partials                263      270       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

List<ExecutableInject> injects = injectHelper.getInjectsToRun();
List<Pause> pauses = pauseRepository.findAllForExercise(PAUSED_EXERCISE.getId());
Exercise responseExercise =
exerciseRepository.findById(JsonPath.read(response, "$.exercise_id")).get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick : You should check isPresent before doing a get here :)


// --ASSERT--
Exercise responseExercise =
exerciseRepository.findById(JsonPath.read(response, "$.exercise_id")).get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exercise responseExercise =
exerciseRepository.findById(JsonPath.read(response, "$.exercise_id")).get();
assertEquals(
responseExercise.getCurrentPause().get().truncatedTo(MINUTES),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// --ASSERT--
Exercise responseExercise =
exerciseRepository.findById(JsonPath.read(response, "$.exercise_id")).get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exercise responseExercise =
exerciseRepository.findById(JsonPath.read(response, "$.exercise_id")).get();
assertEquals(
responseExercise.getEnd().get().truncatedTo(MINUTES), Instant.now().truncatedTo(MINUTES));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -44,4 +47,70 @@ public static Exercise createDefaultIncidentResponseExercise() {
exercise.setStart(Instant.now());
return exercise;
}

public static Exercise createDefaultAttackExercise() {
Exercise exercise = new Exercise();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts : I think Hedi suggested to have builders. Lombok provides a @builder annotation that creates one. Maybe we should look into this at some point ...

Copy link
Member

@Dimfacion Dimfacion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from a few nitpicks, this looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ Unit testing - simulation scope ] - launch/relaunch/pause of a simulation
2 participants