Search in sources :

Example 1 with LaunchTelemetryDataSource

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());
}
Also used : LaunchTelemetryDataSource(com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource) DefaultLaunchTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.DefaultLaunchTelemetry) GsonBuilder(com.google.gson.GsonBuilder) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 2 with LaunchTelemetryDataSource

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
}
Also used : LaunchTelemetryDataSource(com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource) DefaultLaunchTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.DefaultLaunchTelemetry) Test(org.junit.jupiter.api.Test)

Example 3 with LaunchTelemetryDataSource

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();
}
Also used : H2BackedLaunchTelemetryDataSource(com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource) LaunchTelemetryDataSource(com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource) H2BackedLaunchTelemetryDataSource(com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource) ReportingHelper(com.github.nagyesta.abortmission.core.telemetry.ReportingHelper)

Example 4 with LaunchTelemetryDataSource

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();
}
Also used : RmiBackedLaunchTelemetryDataSource(com.github.nagyesta.abortmission.strongback.rmi.telemetry.RmiBackedLaunchTelemetryDataSource) LaunchTelemetryDataSource(com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource) RmiBackedLaunchTelemetryDataSource(com.github.nagyesta.abortmission.strongback.rmi.telemetry.RmiBackedLaunchTelemetryDataSource) ReportingHelper(com.github.nagyesta.abortmission.core.telemetry.ReportingHelper) Registry(java.rmi.registry.Registry)

Aggregations

LaunchTelemetryDataSource (com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource)4 ReportingHelper (com.github.nagyesta.abortmission.core.telemetry.ReportingHelper)2 DefaultLaunchTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.DefaultLaunchTelemetry)2 Test (org.junit.jupiter.api.Test)2 H2BackedLaunchTelemetryDataSource (com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource)1 RmiBackedLaunchTelemetryDataSource (com.github.nagyesta.abortmission.strongback.rmi.telemetry.RmiBackedLaunchTelemetryDataSource)1 GsonBuilder (com.google.gson.GsonBuilder)1 File (java.io.File)1 Registry (java.rmi.registry.Registry)1