From 9f16c04c363d409fb29d4790aae4321a57fae531 Mon Sep 17 00:00:00 2001 From: Theresa Kamerman Date: Thu, 11 Jul 2024 18:00:56 -0700 Subject: [PATCH] Update Existing Tests - TimeTrackerDaemon: make counter "final" - CheckpointSimFacadeTest: Fix incorrect assertEquals - InMemoryCachedEngineTest: Use ResourceManager, reflect changes to `SimulationEngine` constructor SimulationDuplicationTest: Use ResourceManager - FooSimulationDuplicationTest: Remove empty consumer --- .../models/TimeTrackerDaemon.java | 2 +- .../FooSimulationDuplicationTest.java | 18 +++++-------- .../driver/SimulationDuplicationTest.java | 4 ++- .../CheckpointSimulationFacadeTest.java | 2 +- .../InMemoryCachedEngineStoreTest.java | 25 ++++++++----------- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/examples/foo-missionmodel/src/main/java/gov/nasa/jpl/aerie/foomissionmodel/models/TimeTrackerDaemon.java b/examples/foo-missionmodel/src/main/java/gov/nasa/jpl/aerie/foomissionmodel/models/TimeTrackerDaemon.java index 31567a013b..6c3fbb3365 100644 --- a/examples/foo-missionmodel/src/main/java/gov/nasa/jpl/aerie/foomissionmodel/models/TimeTrackerDaemon.java +++ b/examples/foo-missionmodel/src/main/java/gov/nasa/jpl/aerie/foomissionmodel/models/TimeTrackerDaemon.java @@ -8,7 +8,7 @@ * A daemon task that tracks the number of minutes since plan start */ public class TimeTrackerDaemon { - private Counter minutesElapsed; + private final Counter minutesElapsed; public int getMinutesElapsed() { return minutesElapsed.get(); diff --git a/examples/foo-missionmodel/src/test/java/gov/nasa/jpl/aerie/foomissionmodel/FooSimulationDuplicationTest.java b/examples/foo-missionmodel/src/test/java/gov/nasa/jpl/aerie/foomissionmodel/FooSimulationDuplicationTest.java index 65e92a7d33..f183d23824 100644 --- a/examples/foo-missionmodel/src/test/java/gov/nasa/jpl/aerie/foomissionmodel/FooSimulationDuplicationTest.java +++ b/examples/foo-missionmodel/src/test/java/gov/nasa/jpl/aerie/foomissionmodel/FooSimulationDuplicationTest.java @@ -100,8 +100,7 @@ void testCompareCheckpointOnEmptyPlan() { Duration.HOUR, Instant.EPOCH, Duration.HOUR, - () -> false, - $ -> {}); + () -> false); assertResultsEqual(expected, results); } @@ -129,8 +128,7 @@ void testFooNonEmptyPlan() { Duration.HOUR, Instant.EPOCH, Duration.HOUR, - () -> false, - $ -> {}); + () -> false); assertResultsEqual(expected, results); assertEquals(Duration.of(5, MINUTES), store.getCachedEngines(mockConfiguration()).getFirst().endsAt()); @@ -171,8 +169,7 @@ void testFooNonEmptyPlanMultipleResumes() { Duration.HOUR, Instant.EPOCH, Duration.HOUR, - () -> false, - $ -> {}); + () -> false); assertResultsEqual(expected, results); assertEquals(Duration.of(5, MINUTES), store.getCachedEngines(mockConfiguration()).getFirst().endsAt()); @@ -224,8 +221,7 @@ void testFooNonEmptyPlanMultipleCheckpointsMultipleResumes() { Duration.HOUR, Instant.EPOCH, Duration.HOUR, - () -> false, - $ -> {}); + () -> false); assertResultsEqual(expected, results); assertEquals(Duration.of(5, MINUTES), store.getCachedEngines(mockConfiguration()).getFirst().endsAt()); @@ -286,8 +282,7 @@ void testFooNonEmptyPlanMultipleCheckpointsMultipleResumesWithEdits() { Duration.HOUR, Instant.EPOCH, Duration.HOUR, - () -> false, - $ -> {}); + () -> false); final SimulationResults expected2 = SimulationDriver.simulate( missionModel, @@ -296,8 +291,7 @@ void testFooNonEmptyPlanMultipleCheckpointsMultipleResumesWithEdits() { Duration.HOUR, Instant.EPOCH, Duration.HOUR, - () -> false, - $ -> {}); + () -> false); assertResultsEqual(expected1, results); diff --git a/merlin-driver/src/test/java/gov/nasa/jpl/aerie/merlin/driver/SimulationDuplicationTest.java b/merlin-driver/src/test/java/gov/nasa/jpl/aerie/merlin/driver/SimulationDuplicationTest.java index ed29cdf857..24286636ab 100644 --- a/merlin-driver/src/test/java/gov/nasa/jpl/aerie/merlin/driver/SimulationDuplicationTest.java +++ b/merlin-driver/src/test/java/gov/nasa/jpl/aerie/merlin/driver/SimulationDuplicationTest.java @@ -1,5 +1,6 @@ package gov.nasa.jpl.aerie.merlin.driver; +import gov.nasa.jpl.aerie.merlin.driver.resources.InMemorySimulationResourceManager; import gov.nasa.jpl.aerie.merlin.protocol.types.Duration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -63,7 +64,8 @@ void testDuplicate() { Instant.EPOCH, Duration.HOUR, () -> false, - $ -> {}); + $ -> {}, + new InMemorySimulationResourceManager()); assertEquals(expected, results); final var newResults = simulateWithCheckpoints(store.getCachedEngines(mockConfiguration()).get(0), List.of(), store); assertEquals(expected, newResults); diff --git a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/CheckpointSimulationFacadeTest.java b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/CheckpointSimulationFacadeTest.java index 983b80b5e8..1753eba5d4 100644 --- a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/CheckpointSimulationFacadeTest.java +++ b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/CheckpointSimulationFacadeTest.java @@ -103,7 +103,7 @@ public void testStopsAtEndOfPlanningHorizon() final var actTypeA = activityTypes.get("ControllableDurationActivity"); plan.add(SchedulingActivityDirective.of(actTypeA, t0, HOUR.times(200), null, true)); final var results = newSimulationFacade.simulateNoResultsAllActivities(plan).computeResults(); - assertEquals(H.getEndAerie(), newSimulationFacade.totalSimulationTime()); + assertEquals(H.getEndAerie(), results.duration); assert(results.unfinishedActivities.size() == 1); } diff --git a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/InMemoryCachedEngineStoreTest.java b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/InMemoryCachedEngineStoreTest.java index b2b48a345f..9edf6e229a 100644 --- a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/InMemoryCachedEngineStoreTest.java +++ b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/InMemoryCachedEngineStoreTest.java @@ -5,10 +5,8 @@ import gov.nasa.jpl.aerie.merlin.driver.CachedSimulationEngine; import gov.nasa.jpl.aerie.merlin.driver.SimulationEngineConfiguration; import gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine; -import gov.nasa.jpl.aerie.merlin.driver.engine.SlabList; import gov.nasa.jpl.aerie.merlin.driver.MissionModelId; -import gov.nasa.jpl.aerie.merlin.driver.timeline.CausalEventSource; -import gov.nasa.jpl.aerie.merlin.driver.timeline.LiveCells; +import gov.nasa.jpl.aerie.merlin.driver.resources.InMemorySimulationResourceManager; import gov.nasa.jpl.aerie.merlin.protocol.types.Duration; import gov.nasa.jpl.aerie.scheduler.SimulationUtility; import org.junit.jupiter.api.AfterEach; @@ -44,11 +42,10 @@ public static CachedSimulationEngine getCachedEngine1(){ new ActivityDirectiveId(1), new ActivityDirective(Duration.HOUR, "ActivityType1", Map.of(), null, true), new ActivityDirectiveId(2), new ActivityDirective(Duration.HOUR, "ActivityType2", Map.of(), null, true) ), - new SimulationEngine(), - new LiveCells(new CausalEventSource()), - new SlabList<>(), + new SimulationEngine(SimulationUtility.getFooMissionModel().getInitialCells()), null, - SimulationUtility.getFooMissionModel() + SimulationUtility.getFooMissionModel(), + new InMemorySimulationResourceManager() ); } @@ -59,11 +56,10 @@ public static CachedSimulationEngine getCachedEngine2(){ new ActivityDirectiveId(3), new ActivityDirective(Duration.HOUR, "ActivityType3", Map.of(), null, true), new ActivityDirectiveId(4), new ActivityDirective(Duration.HOUR, "ActivityType4", Map.of(), null, true) ), - new SimulationEngine(), - new LiveCells(new CausalEventSource()), - new SlabList<>(), + new SimulationEngine(SimulationUtility.getFooMissionModel().getInitialCells()), null, - SimulationUtility.getFooMissionModel() + SimulationUtility.getFooMissionModel(), + new InMemorySimulationResourceManager() ); } @@ -74,11 +70,10 @@ public static CachedSimulationEngine getCachedEngine3(){ new ActivityDirectiveId(5), new ActivityDirective(Duration.HOUR, "ActivityType5", Map.of(), null, true), new ActivityDirectiveId(6), new ActivityDirective(Duration.HOUR, "ActivityType6", Map.of(), null, true) ), - new SimulationEngine(), - new LiveCells(new CausalEventSource()), - new SlabList<>(), + new SimulationEngine(SimulationUtility.getFooMissionModel().getInitialCells()), null, - SimulationUtility.getFooMissionModel() + SimulationUtility.getFooMissionModel(), + new InMemorySimulationResourceManager() ); }