RpcServerHandler extends RpcHandler<RpcServerRequest, RpcServerResponse> { public void handleSend(RpcServerResponse response, Span span) { handleFinish(response, span); } RpcServerHandler(RpcTracing rpcTracing); static RpcServerHandler create(RpcTracing rpcTracing); Span handleReceive(RpcServerRequest request); void handleSend(RpcServerResponse response, Span span);  }
@Test public void handleSend_finishesSpanEvenIfUnwrappedNull() { brave.Span span = mock(brave.Span.class); when(span.context()).thenReturn(context); when(span.customizer()).thenReturn(span); handler.handleSend(response, span); verify(span).isNoop(); verify(span).context(); verify(span).customizer(); verify(span).finish(); verifyNoMoreInteractions(span); }
@Test public void handleSend_finishesSpanEvenIfUnwrappedNull_withError() { brave.Span span = mock(brave.Span.class); when(span.context()).thenReturn(context); when(span.customizer()).thenReturn(span); Exception error = new RuntimeException("peanuts"); when(response.error()).thenReturn(error); handler.handleSend(response, span); verify(span).isNoop(); verify(span).context(); verify(span).customizer(); verify(span).error(error); verify(span).finish(); verifyNoMoreInteractions(span); }
@Test public void handleSend_oneOfResponseError() { brave.Span span = mock(brave.Span.class); assertThatThrownBy(() -> handler.handleSend(null, span)) .isInstanceOf(NullPointerException.class) .hasMessage("response == null"); }