/** * {@inheritDoc} */ @Override protected void initHook(Map<String, Object> parameters) { hook = new ApacheClientExchangeHandlerHook(); }
@Test public void missingHttpContext() { hook.beforeBody(5L, 10L, handler, null, rsc); verifyZeroInteractions(rsc); } }
@Test public void successful() { Object result = mock(Object.class); hook.firstAfterBody(5L, 10L, handler, null, result, false, rsc); verifyZeroInteractions(rsc, result); } }
@Test public void successful() { ICoreService coreService = mock(ICoreService.class); Object result = mock(Object.class); hook.secondAfterBody(coreService, 5L, 10L, handler, null, result, false, rsc); verifyZeroInteractions(coreService, rsc, result); } }
@Test public void noSpanStore() { HttpContext context = mock(HttpContext.class); handler.localContext = context; hook.beforeBody(5L, 10L, handler, null, rsc); verify(context).getAttribute(SpanStoreAdapter.Constants.ID); verifyNoMoreInteractions(context); verifyZeroInteractions(rsc); }
@Test public void successful() { SpanStore spanStore = mock(SpanStore.class); HttpContext context = mock(HttpContext.class); when(context.getAttribute(SpanStoreAdapter.Constants.ID)).thenReturn(spanStore); handler.localContext = context; hook.beforeBody(5L, 10L, handler, null, rsc); verify(context).getAttribute(SpanStoreAdapter.Constants.ID); verify(spanStore).startSpan(); verifyNoMoreInteractions(spanStore, context); verifyZeroInteractions(rsc); }