FinishSpan implements BiConsumer<Object, Throwable> { static FinishSpan create(TracingFilter filter, DubboRequest request, Result result, Span span) { if (request instanceof DubboClientRequest) { return new FinishClientSpan( span, result, filter.clientHandler, (DubboClientRequest) request); } return new FinishServerSpan(span, result, filter.serverHandler, (DubboServerRequest) request); } FinishSpan(Span span, Result result);   }
@Test public void create_null_result_value_and_error_DubboClientRequest() { Span span = tracing.tracer().nextSpan().kind(CLIENT).start(); FinishSpan.create(filter, clientRequest, mock(Result.class), span) .accept(null, null); testSpanHandler.takeRemoteSpan(CLIENT); }
@Test public void create_null_result_value_and_error_DubboServerRequest() { Span span = tracing.tracer().nextSpan().kind(SERVER).start(); FinishSpan.create(filter, serverRequest, mock(Result.class), span) .accept(null, null); testSpanHandler.takeRemoteSpan(SERVER); }
@Test public void create_result_value_but_null_error_DubboClientRequest() { Span span = tracing.tracer().nextSpan().kind(CLIENT).start(); FinishSpan.create(filter, clientRequest, mock(Result.class), span) .accept(new Object(), null); testSpanHandler.takeRemoteSpan(CLIENT); }
@Test public void create_result_value_but_null_error_DubboServerRequest() { Span span = tracing.tracer().nextSpan().kind(SERVER).start(); FinishSpan.create(filter, serverRequest, mock(Result.class), span) .accept(new Object(), null); testSpanHandler.takeRemoteSpan(SERVER); }
@Test public void create_error_but_null_result_value_DubboClientRequest() { Span span = tracing.tracer().nextSpan().kind(CLIENT).start(); Throwable error = new RuntimeException("melted"); FinishSpan.create(filter, clientRequest, mock(Result.class), span) .accept(null, error); testSpanHandler.takeRemoteSpanWithError(CLIENT, error); }
@Test public void create_error_but_null_result_value_DubboServerRequest() { Span span = tracing.tracer().nextSpan().kind(SERVER).start(); Throwable error = new RuntimeException("melted"); FinishSpan.create(filter, serverRequest, mock(Result.class), span) .accept(null, error); testSpanHandler.takeRemoteSpanWithError(SERVER, error); }