use of com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement in project abort-mission by nagyesta.
the class LaunchStatisticsServiceIntegrationTest method testInsertStageTimeMeasurementShouldInsertUniqueRecordsWhenCalledWithoutCollision.
@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testInsertStageTimeMeasurementShouldInsertUniqueRecordsWhenCalledWithoutCollision(final Map<String, List<StageTimeMeasurement>> input) throws RemoteException {
// given
final LaunchStatisticsService underTest = RmiServiceProvider.service(RmiServiceProvider.lookupRegistry(port));
// when
for (final Map.Entry<String, List<StageTimeMeasurement>> entry : input.entrySet()) {
final String key = entry.getKey();
final List<StageTimeMeasurement> measurementList = entry.getValue();
for (final StageTimeMeasurement measurement : measurementList) {
final boolean isCountdown = CLASS_ONLY.equals(measurement.getTestCaseId());
underTest.insertStageTimeMeasurement(contextName, key, isCountdown, new RmiStageTimeMeasurement(measurement));
}
}
// then
for (final Map.Entry<String, List<StageTimeMeasurement>> entry : input.entrySet()) {
final String matcherName = entry.getKey();
final List<StageTimeMeasurement> measurements = entry.getValue();
final TreeSet<UUID> actual = this.service.fetchAllMeasurementsForMatcher(matcherName).stream().map(RmiStageTimeMeasurement::getLaunchId).collect(Collectors.toCollection(TreeSet::new));
final TreeSet<UUID> expected = measurements.stream().map(StageTimeMeasurement::getLaunchId).collect(Collectors.toCollection(TreeSet::new));
Assertions.assertIterableEquals(expected, actual);
}
}
use of com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement in project abort-mission by nagyesta.
the class RmiBackedLaunchTelemetryDataSourceIntegrationTest method fetchAllMeasurements.
private List<StageTimeMeasurement> fetchAllMeasurements() throws RemoteException {
final List<StageTimeMeasurement> list = new ArrayList<>();
final LaunchStatisticsService serviceOuter = service;
for (final String s : service.fetchAllMatcherNames()) {
final List<RmiStageTimeMeasurement> rmiStageTimeMeasurements = serviceOuter.fetchAllMeasurementsForMatcher(s);
for (final RmiStageTimeMeasurement rmiStageTimeMeasurement : rmiStageTimeMeasurements) {
final StageTimeMeasurement toStageTimeMeasurement = rmiStageTimeMeasurement.toStageTimeMeasurement();
list.add(toStageTimeMeasurement);
}
}
return list;
}
use of com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement in project abort-mission by nagyesta.
the class LaunchStatisticsRepositoryIntegrationTest method testFetchMeasurementsForMatcherShouldReturnNoMeasurementsWhenCalledWithUnknownMatcher.
@ParameterizedTest
@NullAndEmptySource
@ValueSource(strings = { METHOD_PREFIX, CLASS_NAME, MATCHER_PREFIX })
void testFetchMeasurementsForMatcherShouldReturnNoMeasurementsWhenCalledWithUnknownMatcher(final String lookup) {
// given
final StageTimeMeasurement measurement = generateMeasurement(1);
jdbi.withExtension(LaunchStatisticsRepository.class, insertSingleMeasurementCallback(MATCHER_PREFIX + 1, measurement));
// when
final List<StageTimeMeasurement> actual = jdbi.withExtension(LaunchStatisticsRepository.class, dao -> dao.fetchMeasurementsFor(CONTEXT_NAME, lookup, false));
// then
Assertions.assertNotNull(actual);
Assertions.assertIterableEquals(Collections.emptyList(), actual);
}
use of com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement in project abort-mission by nagyesta.
the class H2BackedStageStatisticsCollectorIntegrationTest method testLogAndIncrementShouldSaveMeasurementWhenCalledWithValidInput.
@ParameterizedTest
@MethodSource("measurementProvider")
void testLogAndIncrementShouldSaveMeasurementWhenCalledWithValidInput(final List<StageTimeMeasurement> measurements) {
// given
final boolean countdown = false;
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final H2BackedStageStatisticsCollector underTest = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, countdown);
// when
measurements.forEach(underTest::logAndIncrement);
// then
verify(matcher, atLeast(measurements.size())).getName();
final List<StageTimeMeasurement> actual = jdbi.withExtension(LaunchStatisticsRepository.class, dao -> dao.fetchMeasurementsFor(contextName, MATCHER_PREFIX, countdown));
Collections.sort(actual);
Collections.sort(measurements);
Assertions.assertIterableEquals(measurements, actual);
}
use of com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement in project abort-mission by nagyesta.
the class AbstractInMemoryDataSourceIntegrationTest method insertAll.
protected void insertAll(final Map<String, List<StageTimeMeasurement>> input) throws RemoteException {
for (final Map.Entry<String, List<StageTimeMeasurement>> entry : input.entrySet()) {
final String matcherName = entry.getKey();
final List<StageTimeMeasurement> measurementList = entry.getValue();
for (final StageTimeMeasurement measurement : measurementList) {
final boolean isCountdown = CLASS_ONLY.equals(measurement.getTestCaseId());
service.insertStageTimeMeasurement(contextName, matcherName, isCountdown, new RmiStageTimeMeasurement(measurement));
}
}
}
Aggregations