use of com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot in project abort-mission by nagyesta.
the class H2BackedStageStatisticsCollectorIntegrationTest method testGetSnapshotShouldCountAndGroupMeasurementWhenCalled.
@ParameterizedTest
@MethodSource("measurementProvider")
void testGetSnapshotShouldCountAndGroupMeasurementWhenCalled(final List<StageTimeMeasurement> measurements) {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final H2BackedStageStatisticsCollector underTestCountdown = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, true);
final H2BackedStageStatisticsCollector underTestMission = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, false);
jdbi.withExtension(LaunchStatisticsRepository.class, dao -> {
measurements.forEach(m -> {
final boolean countdown = m.getTestCaseId().equals(CLASS_ONLY);
dao.insertStageTimeMeasurement(contextName, MATCHER_PREFIX, countdown, m);
});
return null;
});
// when
final StageStatisticsSnapshot actualCountdown = underTestCountdown.getSnapshot();
final StageStatisticsSnapshot actualMission = underTestMission.getSnapshot();
// then
verify(matcher, atLeastOnce()).getName();
assertSnapshotCountersMatch(measurements, actualCountdown, actualMission);
}
Aggregations