From 100a8d86165f5f125e93110cb26cf1c0c6f03b96 Mon Sep 17 00:00:00 2001 From: JoelCourtney Date: Thu, 5 Sep 2024 16:18:46 -0700 Subject: [PATCH] Implement GoalInvocationId.fromJSON --- .../nasa/jpl/aerie/e2e/types/GoalInvocationId.java | 11 ++++++++++- .../gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/GoalInvocationId.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/GoalInvocationId.java index 07acdc4cf6..9694940c7a 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/GoalInvocationId.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/GoalInvocationId.java @@ -1,3 +1,12 @@ package gov.nasa.jpl.aerie.e2e.types; -public record GoalInvocationId(int goalId, int invocationId) { } +import javax.json.JsonObject; + +public record GoalInvocationId(int goalId, int invocationId) { + public static GoalInvocationId fromJSON(JsonObject json) { + return new GoalInvocationId( + json.getInt("goal_id"), + json.getInt("goal_invocation_id") + ); + } +} diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java index 71a81e6ea6..385dc3327e 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java @@ -700,7 +700,7 @@ public GoalInvocationId createSchedulingSpecProcedure( final var resp = makeRequest(GQL.CREATE_SCHEDULING_SPEC_GOAL, variables) .getJsonObject("insert_scheduling_specification_goals_one"); - return new GoalInvocationId(resp.getInt("goal_id"), resp.getInt("goal_invocation_id")); + return GoalInvocationId.fromJSON(resp); } public GoalInvocationId createSchedulingSpecGoal( @@ -738,7 +738,7 @@ public GoalInvocationId createSchedulingSpecGoal( final var resp = makeRequest(GQL.CREATE_SCHEDULING_SPEC_GOAL, variables) .getJsonObject("insert_scheduling_specification_goals_one"); - return new GoalInvocationId(resp.getInt("goal_id"), resp.getInt("goal_invocation_id")); + return GoalInvocationId.fromJSON(resp); } public int updateGoalDefinition(int goalId, String definition) throws IOException {