Skip to content

Commit

Permalink
Test activity names saved in db
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelCourtney committed Sep 25, 2024
1 parent a844340 commit dec21b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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", 4).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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ public record Plan(
int revision,
List<ActivityDirective> 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")
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ query GetPlan($id: Int!) {
plan_id
startOffset: start_offset
type
name
}
constraint_specification {
constraint_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit dec21b5

Please sign in to comment.