Skip to content

Commit

Permalink
Add ast test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelCourtney committed Sep 1, 2023
1 parent 0ec7631 commit 2a35aa4
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static gov.nasa.jpl.aerie.constraints.time.Interval.at;
import static gov.nasa.jpl.aerie.constraints.time.Interval.interval;
import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.MICROSECONDS;
import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.MILLISECOND;
import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
Expand Down Expand Up @@ -1126,6 +1127,43 @@ public void testShiftWindowsEdgesBoundsAdjustment() {
assertIterableEquals(expected2, result2);
}

@Test
public void testRollingThreshold() {
final var simResults = new SimulationResults(
Instant.EPOCH, Interval.between(0, 20, SECONDS),
List.of(),
Map.of(),
Map.of()
);

final var spans = new Spans(
Interval.between(0, 1, SECONDS),
Interval.between(2, 3, SECONDS),
Interval.between(4, 5, SECONDS),

Interval.between(14, 15, SECONDS),
Interval.between(16, 17, SECONDS),
Interval.between(18, 19, SECONDS)
);

final var result1 = new RollingThreshold(
Supplier.of(spans),
Supplier.of(Duration.of(10, SECONDS)),
Supplier.of(Duration.of(2500, MILLISECOND)),
RollingThreshold.RollingThresholdAlgorithm.Hull
).evaluate(simResults);

final var expected = new ConstraintResult(
List.of(
new Violation(List.of(Interval.between(0, 5, SECONDS)), List.of()),
new Violation(List.of(Interval.between(14, 19, SECONDS)), List.of())
),
List.of()
);

assertEquals(expected, result1);
}

/**
* An expression that yields the same aliased object every time it is evaluated.
*/
Expand Down

0 comments on commit 2a35aa4

Please sign in to comment.