Search in sources :

Example 1 with ClassTelemetryConverter

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

the class ClassTelemetryTest method testConstructorShouldCallConverterWhenCalledWithValidInput.

@Test
void testConstructorShouldCallConverterWhenCalledWithValidInput() {
    // given
    final ClassTelemetryConverter converter = mock(ClassTelemetryConverter.class);
    final Collection<StageTimeMeasurement> measurements = spy(new HashSet<>());
    final Map<String, Set<String>> matcherNames = spy(new HashMap<>());
    final Map<String, List<StageTimeMeasurement>> byMethods = spy(new HashMap<>());
    when(converter.partitionByMethods(same(measurements))).thenReturn(byMethods);
    final StageLaunchStats countdown = new StageLaunchStats(Collections.emptySortedSet(), Collections.emptySet());
    when(converter.processCountdownStats(same(matcherNames), same(byMethods))).thenReturn(countdown);
    final Map<String, StageLaunchStats> methodStats = spy(new HashMap<>());
    when(converter.processLaunchStats(same(matcherNames), same(byMethods))).thenReturn(methodStats);
    when(converter.summarizeDescendantStats(same(countdown), anyCollection())).thenReturn(null);
    // when
    final ClassTelemetry actual = new ClassTelemetry(converter, CLASS, measurements, matcherNames);
    // then
    Assertions.assertNotNull(actual);
    Assertions.assertNull(actual.getStats());
    Assertions.assertSame(countdown, actual.getCountdown());
    Assertions.assertSame(methodStats, actual.getLaunches());
    Assertions.assertSame(CLASS, actual.getClassName());
    final InOrder inOrder = inOrder(converter, methodStats);
    inOrder.verify(converter).partitionByMethods(same(measurements));
    inOrder.verify(converter).processCountdownStats(same(matcherNames), same(byMethods));
    inOrder.verify(converter).processLaunchStats(same(matcherNames), same(byMethods));
    // noinspection ResultOfMethodCallIgnored
    inOrder.verify(methodStats).values();
    inOrder.verify(converter).summarizeDescendantStats(same(countdown), anyCollection());
    inOrder.verifyNoMoreInteractions();
    verifyNoInteractions(byMethods, matcherNames, measurements);
}
Also used : ClassTelemetryConverter(com.github.nagyesta.abortmission.core.telemetry.converter.ClassTelemetryConverter) InOrder(org.mockito.InOrder) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)1 ClassTelemetryConverter (com.github.nagyesta.abortmission.core.telemetry.converter.ClassTelemetryConverter)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 InOrder (org.mockito.InOrder)1