From 4328d4b0520d1f85d709eaec8f47ab36fe92bfab Mon Sep 17 00:00:00 2001 From: JoelCourtney Date: Wed, 25 Sep 2024 09:46:14 -0700 Subject: [PATCH] Test activity names saved in db --- .../gov/nasa/jpl/aerie/e2e/SchedulingTests.java | 17 +++++++++++++++++ .../java/gov/nasa/jpl/aerie/e2e/types/Plan.java | 6 ++++-- .../java/gov/nasa/jpl/aerie/e2e/utils/GQL.java | 1 + .../procedures/SampleProcedure.java | 11 ++++++++--- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java index 7251b504b4..681a68e067 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java @@ -1156,5 +1156,22 @@ void executeEDSLAndProcedure() throws IOException { assertEquals(52, activities.size()); } + + /** + * Run a spec with one procedure and make sure the activity names are saved to the database + */ + @Test + void saveActivityName() throws IOException { + final var args = Json.createObjectBuilder().add("quantity", 2).build(); + hasura.updateSchedulingSpecGoalArguments(procedureId.invocationId(), args); + + final var resp = hasura.awaitScheduling(specId); + + final var plan = hasura.getPlan(planId); + final var activities = plan.activityDirectives(); + + assertEquals(2, activities.size()); + assertEquals("It's a bite banana activity", activities.getFirst().name()); + } } } diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/Plan.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/Plan.java index 02f19dbb7e..4fb0d3ee80 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/Plan.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/Plan.java @@ -12,14 +12,16 @@ public record Plan( int revision, List activityDirectives ) { - public record ActivityDirective(int id, int planId, String type, String startOffset, JsonObject arguments) { + public record ActivityDirective(int id, int planId, String type, String startOffset, JsonObject arguments, String name) { public static ActivityDirective fromJSON(JsonObject json){ return new ActivityDirective( json.getInt("id"), json.getInt("plan_id"), json.getString("type"), json.getString("startOffset"), - json.getJsonObject("arguments")); + json.getJsonObject("arguments"), + json.getString("name") + ); } } diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/GQL.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/GQL.java index 0aea2e3564..3de72613b4 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/GQL.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/GQL.java @@ -327,6 +327,7 @@ query GetPlan($id: Int!) { plan_id startOffset: start_offset type + name } constraint_specification { constraint_id diff --git a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SampleProcedure.java b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SampleProcedure.java index 2e75c80566..9a2f1cd290 100644 --- a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SampleProcedure.java +++ b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SampleProcedure.java @@ -3,6 +3,8 @@ import gov.nasa.ammos.aerie.procedural.scheduling.plan.EditablePlan; import gov.nasa.ammos.aerie.procedural.scheduling.Goal; import gov.nasa.ammos.aerie.procedural.scheduling.annotations.SchedulingProcedure; +import gov.nasa.ammos.aerie.procedural.scheduling.plan.NewDirective; +import gov.nasa.ammos.aerie.procedural.timeline.payloads.activities.AnyDirective; import gov.nasa.jpl.aerie.merlin.protocol.types.Duration; import gov.nasa.ammos.aerie.procedural.timeline.payloads.activities.DirectiveStart; import org.jetbrains.annotations.NotNull; @@ -19,9 +21,12 @@ public void run(@NotNull final EditablePlan plan) { var currentTime = firstTime; for (var i = 0; i < quantity; i++) { plan.create( - "BiteBanana", - new DirectiveStart.Absolute(currentTime), - Map.of() + new NewDirective( + new AnyDirective(Map.of()), + "It's a bite banana activity", + "BiteBanana", + new DirectiveStart.Absolute(currentTime) + ) ); currentTime = currentTime.plus(step); }