diff --git a/examples/banananation/src/main/java/gov/nasa/jpl/aerie/banananation/activities/GrowBananaActivity.java b/examples/banananation/src/main/java/gov/nasa/jpl/aerie/banananation/activities/GrowBananaActivity.java index 57489ccabb..5e6e2c8311 100644 --- a/examples/banananation/src/main/java/gov/nasa/jpl/aerie/banananation/activities/GrowBananaActivity.java +++ b/examples/banananation/src/main/java/gov/nasa/jpl/aerie/banananation/activities/GrowBananaActivity.java @@ -40,7 +40,7 @@ public boolean validateGrowingDuration() { @EffectModel @ControllableDuration(parameterName = "growingDuration") public void run(final Mission mission) { - final var rate = this.quantity() / (double) this.growingDuration().in(Duration.SECONDS); + final var rate = this.quantity() / (double) this.growingDuration().ratioOver(Duration.SECOND); mission.fruit.rate.add(rate); delay(this.growingDuration()); mission.fruit.rate.add(-rate); diff --git a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/EditablePlanTest.java b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/EditablePlanTest.java index dbd7e4f991..d15ab6b1da 100644 --- a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/EditablePlanTest.java +++ b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/EditablePlanTest.java @@ -198,4 +198,35 @@ public void simResultMarkedNotStaleAfterRollback_SimulateThenCommit() { assertFalse(simResults.isStale()); } + + @Test + void simulationInputDirectivesDontChange() { + plan.create( + "BiteBanana", + new DirectiveStart.Absolute(Duration.MINUTE), + Map.of("biteSize", SerializedValue.of(1)) + ); + + final var expectedDirectives = plan.directives(); + final var simResults = plan.simulate(); + + plan.create( + "GrowBanana", + new DirectiveStart.Absolute(Duration.HOUR), + Map.of( + "growingDuration", SerializedValue.of(10000), + "quantity", SerializedValue.of(1) + ) + ); + + assertIterableEquals(expectedDirectives, simResults.inputDirectives()); + assertNotEquals(plan.directives(), simResults.inputDirectives()); + + plan.commit(); + + assertIterableEquals(expectedDirectives, simResults.inputDirectives()); + assertNotEquals(plan.directives(), simResults.inputDirectives()); + + assertIterableEquals(plan.directives(), plan.simulate().inputDirectives()); + } }