use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService 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.strongback.rmi.service.LaunchStatisticsService 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.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollector method doLogTimeMeasurement.
@Override
protected void doLogTimeMeasurement(final String contextName, final MissionHealthCheckMatcher matcher, final boolean countdown, final StageTimeMeasurement measurement) {
try {
final LaunchStatisticsService service = RmiServiceProvider.service(registry);
final RmiStageTimeMeasurement rmiMeasurement = new RmiStageTimeMeasurement(measurement);
service.insertStageTimeMeasurement(contextName, matcher.getName(), countdown, rmiMeasurement);
} catch (final RemoteException e) {
LOGGER.error("Failed to log measurement.", e);
throw new StrongbackException(e.getMessage(), e);
}
}
use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorTest method testDoFetchAllShouldThrowStrongbackExceptionWhenCaughtException.
@Test
void testDoFetchAllShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
when(service.fetchMeasurementsFor(anyString(), anyString(), anyBoolean())).thenThrow(new RemoteException());
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.doFetchAll(CONTEXT, matcher, true));
// then + exception
final InOrder inOrder = inOrder(registry, service, matcher);
inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
inOrder.verify(service).fetchMeasurementsFor(eq(CONTEXT), eq(MATCHER), eq(true));
inOrder.verifyNoMoreInteractions();
}
use of com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorTest method testDoGetSnapshotShouldThrowStrongbackExceptionWhenCaughtException.
@Test
void testDoGetSnapshotShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
when(service.getSnapshot(anyString(), anyString(), anyBoolean())).thenThrow(new RemoteException());
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.doGetSnapshot(CONTEXT, matcher, true));
// then + exception
final InOrder inOrder = inOrder(registry, service, matcher);
inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
inOrder.verify(service).getSnapshot(eq(CONTEXT), eq(MATCHER), eq(true));
inOrder.verifyNoMoreInteractions();
}
Aggregations