Skip to content

Commit

Permalink
removed uncomplete fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
heditar committed Jan 7, 2025
1 parent c24c2a8 commit c7d0ec2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import io.openbas.database.model.Asset;
import io.openbas.database.model.Exercise;
import io.openbas.database.model.Inject;
import io.openbas.database.model.Tag;
import io.openbas.database.repository.*;
import io.openbas.rest.exercise.form.ExercisesGlobalScoresInput;
Expand Down Expand Up @@ -114,10 +115,15 @@ public void testUpdateExercise_WITH_apply_rule_true() {
Asset asset1 = AssetFixture.createDefaultAsset("asset1");
Asset asset2 = AssetFixture.createDefaultAsset("asset2");
Asset asset3 = AssetFixture.createDefaultAsset("asset3");
io.openbas.database.model.Tag tag1 = TagFixture.getTag("Tag1");
io.openbas.database.model.Tag tag2 = TagFixture.getTag("Tag2");
io.openbas.database.model.Tag tag3 = TagFixture.getTag("Tag3");
Exercise exercise = ExerciseFixture.getExerciseWithInjects();
Tag tag1 = TagFixture.getTag("Tag1");
Tag tag2 = TagFixture.getTag("Tag2");
Tag tag3 = TagFixture.getTag("Tag3");
Inject inject1 = new Inject();
inject1.setId("1");
Inject inject2 = new Inject();
inject1.setId("2");
Exercise exercise = ExerciseFixture.getExercise(null);
exercise.setInjects(List.of(inject1, inject2));
exercise.setTags(Set.of(tag1, tag2));
Set<Tag> currentTags = Set.of(tag2, tag3);
List<Asset> assetsToAdd = List.of(asset1, asset2);
Expand All @@ -143,7 +149,12 @@ public void testUpdateExercise_WITH_apply_rule_false() {
io.openbas.database.model.Tag tag1 = TagFixture.getTag("Tag1");
io.openbas.database.model.Tag tag2 = TagFixture.getTag("Tag2");
io.openbas.database.model.Tag tag3 = TagFixture.getTag("Tag3");
Exercise exercise = ExerciseFixture.getExerciseWithInjects();
Inject inject1 = new Inject();
inject1.setId("1");
Inject inject2 = new Inject();
inject1.setId("2");
Exercise exercise = ExerciseFixture.getExercise(null);
exercise.setInjects(List.of(inject1, inject2));
exercise.setTags(Set.of(tag1, tag2));
Set<Tag> currentTags = Set.of(tag2, tag3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ public void testUpdateScenario_WITH_applyRule_true() {
Tag tag1 = TagFixture.getTag("Tag1");
Tag tag2 = TagFixture.getTag("Tag2");
Tag tag3 = TagFixture.getTag("Tag3");
Scenario scenario = ScenarioFixture.getScenarioWithInjects();
Inject inject1 = new Inject();
inject1.setId("1");
Inject inject2 = new Inject();
inject1.setId("2");
Scenario scenario = ScenarioFixture.getScenario(null, Set.of(inject1, inject2));
scenario.setTags(Set.of(tag1, tag2));
Set<Tag> currentTags = Set.of(tag2, tag3);
List<Asset> assetsToAdd = List.of(asset1, asset2);
Expand Down Expand Up @@ -242,7 +246,11 @@ public void testUpdateScenario_WITH_applyRule_false() {
Tag tag1 = TagFixture.getTag("Tag1");
Tag tag2 = TagFixture.getTag("Tag2");
Tag tag3 = TagFixture.getTag("Tag3");
Scenario scenario = ScenarioFixture.getScenarioWithInjects();
Inject inject1 = new Inject();
inject1.setId("1");
Inject inject2 = new Inject();
inject1.setId("2");
Scenario scenario = ScenarioFixture.getScenario(null, Set.of(inject1, inject2));
scenario.setTags(Set.of(tag1, tag2));
Set<Tag> currentTags = Set.of(tag2, tag3);
List<Asset> assetsToAdd = List.of(asset1, asset2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package io.openbas.utils.fixtures;

import io.openbas.database.model.Asset;
import java.time.Instant;
import org.jetbrains.annotations.NotNull;

public class AssetFixture {
public static Asset createDefaultAsset(@NotNull final String id) {
Asset assetGroup = new Asset();
assetGroup.setId(id);
return assetGroup;
Asset asset = new Asset();
asset.setId(id);
asset.setCreatedAt(Instant.now());
asset.setUpdatedAt(Instant.now());
asset.setName("asset name");
asset.setDescription("asset description");
return asset;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import io.openbas.database.model.Exercise;
import io.openbas.database.model.ExerciseStatus;
import io.openbas.database.model.Inject;
import io.openbas.database.model.Team;
import java.time.Instant;
import java.util.List;
Expand All @@ -26,16 +25,6 @@ public static Exercise getExercise(List<Team> exerciseTeams) {
return exercise;
}

public static Exercise getExerciseWithInjects() {
Exercise exercise = getExercise(null);
Inject inject1 = new Inject();
inject1.setId("1");
Inject inject2 = new Inject();
inject1.setId("2");
exercise.setInjects(List.of(inject1, inject2));
return exercise;
}

public static Exercise createDefaultCrisisExercise() {
Exercise exercise = new Exercise();
exercise.setName("Crisis exercise");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,4 @@ public static Scenario createDefaultIncidentResponseScenario() {
scenario.setSeverity(critical);
return scenario;
}

public static Scenario getScenarioWithInjects() {
Inject inject1 = new Inject();
inject1.setId("1");
Inject inject2 = new Inject();
inject1.setId("2");
return getScenario(null, Set.of(inject1, inject2));
}
}

0 comments on commit c7d0ec2

Please sign in to comment.