diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java index 12602b1646..ef816b1951 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationService.java @@ -80,7 +80,7 @@ else if ((argument instanceof Discrete) || (argument instanceof Real)) { } else if(Array.isArray(argument)){ const arr: any[] = []; - argument.every((element) => { arr.push(makeAllDiscreteProfile(element))}); + argument.forEach((element) => { arr.push(makeAllDiscreteProfile(element))}); return Discrete.List(arr).__astNode; } else if (typeof argument === "object" ){ const obj: { [k: string]: any } = {}; diff --git a/scheduler-server/src/test/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTest.java b/scheduler-server/src/test/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTest.java index 28242ddf93..480bb3ce5c 100644 --- a/scheduler-server/src/test/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTest.java +++ b/scheduler-server/src/test/java/gov/nasa/jpl/aerie/scheduler/server/services/TypescriptCodeGenerationServiceTest.java @@ -39,7 +39,7 @@ else if ((argument instanceof Discrete) || (argument instanceof Real)) { } else if(Array.isArray(argument)){ const arr: any[] = []; - argument.every((element) => { arr.push(makeAllDiscreteProfile(element))}); + argument.forEach((element) => { arr.push(makeAllDiscreteProfile(element))}); return Discrete.List(arr).__astNode; } else if (typeof argument === "object" ){ const obj: { [k: string]: any } = {}; diff --git a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java index 7feed8713b..4f82be4c57 100644 --- a/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java +++ b/scheduler-worker/src/test/java/gov/nasa/jpl/aerie/scheduler/worker/services/SchedulingIntegrationTests.java @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.*; import gov.nasa.jpl.aerie.constraints.time.Interval; +import gov.nasa.jpl.aerie.foomissionmodel.mappers.FooValueMappers; import gov.nasa.jpl.aerie.merlin.driver.ActivityDirective; import gov.nasa.jpl.aerie.merlin.driver.ActivityDirectiveId; import gov.nasa.jpl.aerie.merlin.driver.MissionModelLoader; @@ -2657,4 +2658,34 @@ export default () => Goal.CoexistenceGoal({ assertEquals(1, peels.size()); assertEquals(peels.iterator().next().startOffset(), Duration.of(5, MINUTE).plus(Duration.of(2, activityDuration))); } + + @Test + void testListOfListParam() { + final var results = runScheduler(FOO, List.of(), List.of(new SchedulingGoal(new GoalId(0L), """ + export default function myGoal() { + return Goal.CardinalityGoal({ + activityTemplate: ActivityTemplates.foo({ + x: 1, + y:"test2", + z:3, + vecs: [[1, 2, 3], [4, 5, 6]] + }), + specification : {occurrence: 1} + }) + } + """, true)),List.of(), PLANNING_HORIZON); + assertEquals(1, results.scheduleResults.goalResults().size()); + final var goalResult = results.scheduleResults.goalResults().get(new GoalId(0L)); + + assertTrue(goalResult.satisfied()); + + final var activitiesByType = partitionByActivityType(results.updatedPlan()); + + final var foos = activitiesByType.get("foo"); + assertEquals(1, foos.size()); + final var insertedFoo = foos.iterator().next(); + final var vecs = insertedFoo.serializedActivity().getArguments().get("vecs").asList(); + assertTrue(vecs.isPresent()); + assertEquals(2, vecs.get().size()); + } }