use of com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats in project abort-mission by nagyesta.
the class ClassTelemetryConverter method processLaunchStats.
/**
* Processes statistical information of all test methods in the class based on partitioned data.
*
* @param matcherNames The names of matchers partitioned per method name.
* @param byMethods The time series information per method name.
* @return The parsed statistics of each method.
*/
public Map<String, StageLaunchStats> processLaunchStats(final Map<String, Set<String>> matcherNames, final Map<String, List<StageTimeMeasurement>> byMethods) {
Objects.requireNonNull(matcherNames, "MatcherNames cannot be null.");
Objects.requireNonNull(byMethods, "ByMethods cannot be null.");
final Map<String, StageLaunchStats> methodStats = new TreeMap<String, StageLaunchStats>();
byMethods.forEach((method, measurementList) -> {
if (StageTimeMeasurement.CLASS_ONLY.equals(method)) {
return;
}
final Set<String> names = matcherNames.getOrDefault(method, Collections.emptySet());
methodStats.put(method, new StageLaunchStats(AggregatedLaunchStats.filter(measurementList), names));
});
return Collections.unmodifiableMap(methodStats);
}
use of com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats 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.StageLaunchStats 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