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);
}
Aggregations