Skip to content

Commit

Permalink
Update Existing Tests
Browse files Browse the repository at this point in the history
- TimeTrackerDaemon: make counter "final"
- CheckpointSimFacadeTest: Fix incorrect assertEquals
- InMemoryCachedEngineTest: Use ResourceManager, reflect changes to `SimulationEngine` constructor
SimulationDuplicationTest: Use ResourceManager
- FooSimulationDuplicationTest: Remove empty consumer
  • Loading branch information
Mythicaeda committed Jul 23, 2024
1 parent 5528a2e commit 9f16c04
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* A daemon task that tracks the number of minutes since plan start
*/
public class TimeTrackerDaemon {
private Counter<Integer> minutesElapsed;
private final Counter<Integer> minutesElapsed;

public int getMinutesElapsed() {
return minutesElapsed.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ void testCompareCheckpointOnEmptyPlan() {
Duration.HOUR,
Instant.EPOCH,
Duration.HOUR,
() -> false,
$ -> {});
() -> false);
assertResultsEqual(expected, results);
}

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -286,8 +282,7 @@ void testFooNonEmptyPlanMultipleCheckpointsMultipleResumesWithEdits() {
Duration.HOUR,
Instant.EPOCH,
Duration.HOUR,
() -> false,
$ -> {});
() -> false);

final SimulationResults expected2 = SimulationDriver.simulate(
missionModel,
Expand All @@ -296,8 +291,7 @@ void testFooNonEmptyPlanMultipleCheckpointsMultipleResumesWithEdits() {
Duration.HOUR,
Instant.EPOCH,
Duration.HOUR,
() -> false,
$ -> {});
() -> false);

assertResultsEqual(expected1, results);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
);
}

Expand All @@ -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()
);
}

Expand All @@ -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()
);
}

Expand Down

0 comments on commit 9f16c04

Please sign in to comment.