use of com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource in project abort-mission by nagyesta.
the class ReportingHelperTest method testTestExecutionFinishedShouldSaveProvidedData.
@Test
void testTestExecutionFinishedShouldSaveProvidedData() throws IOException {
// given
final ReportingHelper underTest = spy(new ReportingHelper());
final String dirname = System.getProperty("java.io.tmpdir") + "/abort-mission/";
doReturn(Optional.of(dirname)).when(underTest).reportingRoot();
final LaunchTelemetryDataSource dataSource = mock(LaunchTelemetryDataSource.class);
when(dataSource.fetchClassStatistics()).thenReturn(Collections.emptySortedMap());
final DefaultLaunchTelemetry telemetry = new DefaultLaunchTelemetry(dataSource);
doReturn(dataSource).when(underTest).launchTelemetryDataSource();
final ArgumentCaptor<File> fileCaptor = ArgumentCaptor.forClass(File.class);
doCallRealMethod().when(underTest).writeJson(any(DefaultLaunchTelemetry.class), fileCaptor.capture());
// when
underTest.report();
// then
verify(underTest).reportingRoot();
verify(underTest).launchTelemetryDataSource();
final File file = fileCaptor.getValue();
Files.readAllLines(file.toPath()).forEach(line -> Assertions.assertEquals(new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter()).create().toJson(telemetry), line));
Assertions.assertTrue(file.delete());
}
use of com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource in project abort-mission by nagyesta.
the class ReportingHelperTest method testWriteShouldCatchExceptionsWhenThrown.
@Test
void testWriteShouldCatchExceptionsWhenThrown() {
// given
final ReportingHelper underTest = new ReportingHelper();
final LaunchTelemetryDataSource dataSource = mock(LaunchTelemetryDataSource.class);
when(dataSource.fetchClassStatistics()).thenReturn(Collections.emptySortedMap());
final DefaultLaunchTelemetry telemetry = new DefaultLaunchTelemetry(dataSource);
// when
underTest.writeJson(telemetry, null);
// then no exception
}
use of com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource in project abort-mission by nagyesta.
the class H2StrongbackController method retract.
@Override
public void retract() {
final LaunchTelemetryDataSource telemetryDataSource = new H2BackedLaunchTelemetryDataSource(dataSource);
new ReportingHelper().report(telemetryDataSource);
serverManager.stopServer();
}
use of com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource in project abort-mission by nagyesta.
the class RmiStrongbackController method retract.
@Override
public void retract() {
final Registry registry = RmiServiceProvider.lookupRegistry(serverManager.getPort());
final LaunchTelemetryDataSource telemetryDataSource = new RmiBackedLaunchTelemetryDataSource(registry);
new ReportingHelper().report(telemetryDataSource);
serverManager.stopServer();
}
Aggregations