Search in sources :

Example 6 with StageStatisticsSnapshot

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);
}
Also used : StageStatisticsSnapshot(com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

StageStatisticsSnapshot (com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 MissionHealthCheckMatcher (com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)2 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)1 Registry (java.rmi.registry.Registry)1