Search in sources :

Example 1 with LaunchTelemetryConverter

use of com.github.nagyesta.abortmission.core.telemetry.converter.LaunchTelemetryConverter in project abort-mission by nagyesta.

the class DefaultLaunchTelemetryDataSourceTest method testFetchClassStatisticsShouldCallConverterWhenConstructedWithValidData.

@Test
void testFetchClassStatisticsShouldCallConverterWhenConstructedWithValidData() {
    // given
    final LaunchTelemetryConverter converter = mock(LaunchTelemetryConverter.class);
    final Map<String, AbortMissionCommandOps> nameSpaces = spy(new HashMap<>());
    final SortedMap<String, ClassTelemetry> classStats = spy(new TreeMap<>());
    when(converter.processClassStatistics(same(nameSpaces))).thenReturn(classStats);
    final DefaultLaunchTelemetryDataSource underTest = new DefaultLaunchTelemetryDataSource(converter, nameSpaces);
    // when
    final SortedMap<String, ClassTelemetry> actual = underTest.fetchClassStatistics();
    // then
    Assertions.assertNotNull(actual);
    Assertions.assertSame(classStats, actual);
    final InOrder inOrder = inOrder(converter, classStats);
    inOrder.verify(converter).processClassStatistics(same(nameSpaces));
    inOrder.verifyNoMoreInteractions();
    verifyNoInteractions(nameSpaces);
}
Also used : LaunchTelemetryConverter(com.github.nagyesta.abortmission.core.telemetry.converter.LaunchTelemetryConverter) InOrder(org.mockito.InOrder) AbortMissionCommandOps(com.github.nagyesta.abortmission.core.AbortMissionCommandOps) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with LaunchTelemetryConverter

use of com.github.nagyesta.abortmission.core.telemetry.converter.LaunchTelemetryConverter in project abort-mission by nagyesta.

the class DefaultLaunchTelemetryTest method testConstructorShouldCallFetchClassStatisticsWhenCalledWithValidData.

@Test
void testConstructorShouldCallFetchClassStatisticsWhenCalledWithValidData() {
    // given
    final LaunchTelemetryConverter converter = mock(LaunchTelemetryConverter.class);
    final Map<String, AbortMissionCommandOps> nameSpaces = spy(new HashMap<>());
    final SortedMap<String, ClassTelemetry> classStats = spy(new TreeMap<>());
    when(converter.processClassStatistics(same(nameSpaces))).thenReturn(classStats);
    final LaunchTelemetryDataSource dataSource = mock(LaunchTelemetryDataSource.class);
    when(dataSource.fetchClassStatistics()).thenReturn(classStats);
    // when
    final DefaultLaunchTelemetry actual = new DefaultLaunchTelemetry(dataSource);
    // then
    Assertions.assertNotNull(actual);
    Assertions.assertSame(classStats, actual.getClasses());
    Assertions.assertNotNull(actual.getStats());
    final InOrder inOrder = inOrder(dataSource, classStats);
    inOrder.verify(dataSource).fetchClassStatistics();
    // noinspection ResultOfMethodCallIgnored
    inOrder.verify(classStats, times(2)).values();
    inOrder.verifyNoMoreInteractions();
    verifyNoInteractions(nameSpaces);
}
Also used : LaunchTelemetryConverter(com.github.nagyesta.abortmission.core.telemetry.converter.LaunchTelemetryConverter) InOrder(org.mockito.InOrder) AbortMissionCommandOps(com.github.nagyesta.abortmission.core.AbortMissionCommandOps) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AbortMissionCommandOps (com.github.nagyesta.abortmission.core.AbortMissionCommandOps)2 LaunchTelemetryConverter (com.github.nagyesta.abortmission.core.telemetry.converter.LaunchTelemetryConverter)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 InOrder (org.mockito.InOrder)2