Skip to content

Commit

Permalink
Merge pull request #1246 from NASA-AMMOS/fix/fix-canceling-sim-test
Browse files Browse the repository at this point in the history
Add the correct number of activities in e2eTest
  • Loading branch information
Mythicaeda authored Nov 21, 2023
2 parents 9fa3cd4 + ee85e79 commit d682fdb
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,15 @@ void beforeEach() throws IOException, InterruptedException {
fooPlan = hasura.createPlan(
fooId,
"Foo Plan - Simulation Tests",
"8760:00:00",
"1760:00:00",
planStartTimestamp);

// Add a Grow Banana every minute
for(int i = 0; i < 24*60; ++i) {
final int hours = i / 60;
final int minutes = i % 60;
final var startOffset = (hours<10 ? "0"+hours : hours) + ":"+ (minutes<10 ? "0"+minutes : minutes)+":00";
// Add a ControllableDurationActivity every hour
for(int i = 0; i < 1760; ++i) {
final var startOffset = (i<10 ? "0"+i : i) + ":00:00";
final var growArgs = Json.createObjectBuilder()
.add("duration", Json.createObjectBuilder()
.add("amountInMicroseconds", 60000000)) // 1 min
.add("amountInMicroseconds", 60000000*60L)) // 1 hour
.build();
hasura.insertActivity(fooPlan, "ControllableDurationActivity", startOffset, growArgs);
}
Expand Down Expand Up @@ -316,13 +314,10 @@ void cancelingSimReturnsPartialResults() throws IOException {

assertNotEquals(planEndTimestamp, reasonData.getString("utcTimeDoy"));

final var elapsedHours = reasonData.getString("elapsedTime").split(":")[0];
final int startedActivities = Integer.parseInt(elapsedHours) + 1; // Hours + 1 (Accounts for 0 index)

final var elapsedDurationComponents = reasonData.getString("elapsedTime").split("\\.")[0].split(":");
final int startedActivities = Integer.parseInt(elapsedDurationComponents[0]) * 60 // Hours
+ Integer.parseInt(elapsedDurationComponents[1]) // Minutes
+ 1; // Account for 0 index

// There should be as many activities that began simulation as time elapsed
// There should be as many activities that began simulation as hours into time elapsed
assertEquals(startedActivities, results.activities().size());
}
}
Expand Down

0 comments on commit d682fdb

Please sign in to comment.