use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorIntegrationTest method testLogAndIncrementShouldSaveMeasurementWhenCalledWithValidInput.
@ParameterizedTest
@MethodSource("measurementProvider")
void testLogAndIncrementShouldSaveMeasurementWhenCalledWithValidInput(final List<StageTimeMeasurement> measurements) throws RemoteException {
// given
final Registry registry = RmiServiceProvider.lookupRegistry(port);
final boolean countdown = false;
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(contextName, matcher, registry, countdown);
// when
measurements.forEach(underTest::logAndIncrement);
// then
verify(matcher, atLeast(measurements.size())).getName();
final List<RmiStageTimeMeasurement> actual = service.fetchMeasurementsFor(contextName, MATCHER_PREFIX, countdown);
Collections.sort(actual);
final List<RmiStageTimeMeasurement> expected = measurements.stream().sorted().map(RmiStageTimeMeasurement::new).collect(Collectors.toList());
Assertions.assertIterableEquals(expected, actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorTest method testDoLogTimeMeasurementShouldThrowStrongbackExceptionWhenCaughtException.
@Test
void testDoLogTimeMeasurementShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
doThrow(new RemoteException()).when(service).insertStageTimeMeasurement(anyString(), anyString(), anyBoolean(), any(RmiStageTimeMeasurement.class));
final Registry registry = mock(Registry.class);
when(registry.lookup(eq(RmiServerConstants.SERVICE_NAME))).thenReturn(service);
final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(CONTEXT, matcher, registry, true);
// when
Assertions.assertThrows(StrongbackException.class, () -> underTest.doLogTimeMeasurement(CONTEXT, matcher, true, ABORTED));
// then + exception
final InOrder inOrder = inOrder(registry, service, matcher);
inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
inOrder.verify(service).insertStageTimeMeasurement(eq(CONTEXT), eq(MATCHER), eq(true), any(RmiStageTimeMeasurement.class));
inOrder.verifyNoMoreInteractions();
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher 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.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ExternalStageStatisticsCollectorTest method testGetSnapshotShouldCallDoGetSnapshotWhenCalled.
@Test
void testGetSnapshotShouldCallDoGetSnapshotWhenCalled() {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final ExternalStageStatisticsCollector underTest = spy(new NoOpExternalStageStatisticsCollector(CONTEXT, matcher, true));
// when
underTest.getSnapshot();
// then
verify(underTest).getSnapshot();
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ExternalStageStatisticsCollectorTest method testTimeSeriesStreamShouldCallDoFetchAllWhenCalled.
@Test
void testTimeSeriesStreamShouldCallDoFetchAllWhenCalled() {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final ExternalStageStatisticsCollector underTest = spy(new NoOpExternalStageStatisticsCollector(CONTEXT, matcher, true));
// when
underTest.timeSeriesStream();
// then
verify(underTest).doFetchAll(eq(CONTEXT), eq(matcher), eq(true));
}
Aggregations