use of com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry in project abort-mission by nagyesta.
the class RmiBackedLaunchTelemetryDataSourceIntegrationTest method testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled.
@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled(final Map<String, List<StageTimeMeasurement>> input) throws RemoteException {
// given
final Registry registry = RmiServiceProvider.lookupRegistry(port);
insertAll(input);
final RmiBackedLaunchTelemetryDataSource underTest = new RmiBackedLaunchTelemetryDataSource(registry);
// when
final SortedMap<String, ClassTelemetry> actual = underTest.fetchClassStatistics();
// then
final Map<String, StageLaunchStats> actualLaunchStatsMap = toLaunches(actual);
final Set<String> actualMethods = new TreeSet<>(actualLaunchStatsMap.keySet());
final List<StageTimeMeasurement> allMeasurements = fetchAllMeasurements();
final List<String> expectedMethods = mapToMethodNames(allMeasurements);
Assertions.assertIterableEquals(expectedMethods, actualMethods);
expectedMethods.forEach(method -> {
final StageLaunchStats actualLaunch = actualLaunchStatsMap.get(method);
final List<TestRunTelemetry> expectedMeasurements = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(method)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
Assertions.assertIterableEquals(expectedMeasurements, actualLaunch.getTimeMeasurements());
final Map<StageResult, Integer> actualResultCount = actualLaunch.getStats().getResultCount();
final Map<StageResult, Integer> expectedResultCount = countResults(expectedMeasurements);
Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
});
final StageLaunchStats actualCountdown = toCountdown(actual);
final List<TestRunTelemetry> expectedCountdowns = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(CLASS_ONLY)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
Assertions.assertIterableEquals(expectedCountdowns, actualCountdown.getTimeMeasurements());
final Map<StageResult, Integer> actualResultCount = actualCountdown.getStats().getResultCount();
final Map<StageResult, Integer> expectedResultCount = countResults(expectedCountdowns);
Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
}
use of com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry in project abort-mission by nagyesta.
the class H2BackedLaunchTelemetryDataSourceIntegrationTest method testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled.
@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled(final Map<String, List<StageTimeMeasurement>> input) {
// given
jdbi.withExtension(LaunchStatisticsRepository.class, insertAllCallback(input));
final H2BackedLaunchTelemetryDataSource underTest = new H2BackedLaunchTelemetryDataSource(dataSource);
// when
final SortedMap<String, ClassTelemetry> actual = underTest.fetchClassStatistics();
// then
final Map<String, StageLaunchStats> actualLaunchStatsMap = toLaunches(actual);
final Set<String> actualMethods = new TreeSet<>(actualLaunchStatsMap.keySet());
final List<StageTimeMeasurement> allMeasurements = fetchAllMeasurements();
final List<String> expectedMethods = mapToMethodNames(allMeasurements);
Assertions.assertIterableEquals(expectedMethods, actualMethods);
expectedMethods.forEach(method -> {
final StageLaunchStats actualLaunch = actualLaunchStatsMap.get(method);
final List<TestRunTelemetry> expectedMeasurements = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(method)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
Assertions.assertIterableEquals(expectedMeasurements, actualLaunch.getTimeMeasurements());
final Map<StageResult, Integer> actualResultCount = actualLaunch.getStats().getResultCount();
final Map<StageResult, Integer> expectedResultCount = countResults(expectedMeasurements);
Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
});
final StageLaunchStats actualCountdown = toCountdown(actual);
final List<TestRunTelemetry> expectedCountdowns = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(CLASS_ONLY)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
Assertions.assertIterableEquals(expectedCountdowns, actualCountdown.getTimeMeasurements());
final Map<StageResult, Integer> actualResultCount = actualCountdown.getStats().getResultCount();
final Map<StageResult, Integer> expectedResultCount = countResults(expectedCountdowns);
Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
}
Aggregations