@Test public void testTooManyPops() { // given ThreadContextImpl threadContext = mock(ThreadContextImpl.class); MessageSupplier messageSupplier = mock(MessageSupplier.class); TimerImpl timer = mock(TimerImpl.class); Ticker ticker = mock(Ticker.class); TraceEntryComponent traceEntryComponent = new TraceEntryComponent(threadContext, messageSupplier, timer, 0, ticker); // when traceEntryComponent.popEntry(traceEntryComponent.getRootEntry(), 0); traceEntryComponent.popEntry(traceEntryComponent.getRootEntry(), 0); // then ok }
@Test public void testPopNonExisting() { // given ThreadContextImpl threadContext = mock(ThreadContextImpl.class); MessageSupplier messageSupplier1 = mock(MessageSupplier.class); MessageSupplier messageSupplier2 = mock(MessageSupplier.class); TimerImpl timer1 = mock(TimerImpl.class); TimerImpl timer2 = mock(TimerImpl.class); Ticker ticker = mock(Ticker.class); TraceEntryComponent traceEntryComponent = new TraceEntryComponent(threadContext, messageSupplier1, timer1, 0, ticker); // when traceEntryComponent.pushEntry(0, messageSupplier2, null, 0, timer2); traceEntryComponent.popEntry(mock(TraceEntryImpl.class), 0); // then assertThat(traceEntryComponent.isCompleted()).isTrue(); }