RpcServerMetricsCollector { public void requestCompleted(Timer.Context context, Object reply) { if (context != null) { context.stop(); } totalNumberOfCompletedRequests.mark(); } RpcServerMetricsCollector(String identifier, Metrics metrics); Timer.Context requestReceived(Object destination); void requestCompleted(Timer.Context context, Object reply); void requestCompletedExceptionally(Timer.Context context, Object destination, Throwable error);  }
@Test void requestCompleted() { sut.requestCompleted(metrics.getTimer("foo").time(), "reply1"); assertThat(metrics.getMeter("rpcServer.requests.total").getCount(), Matchers.is(0L)); assertThat(metrics.getTimer("rpcServer.requests.req1").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.completed.total").getCount(), Matchers.is(1L)); assertThat(metrics.getMeter("rpcServer.error.total").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.error.req1").getCount(), Matchers.is(0L)); }
@Test void requestCompletedWithNullRequestAndReplyPossible() { sut.requestCompleted(null, null); assertThat(metrics.getMeter("rpcServer.requests.total").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.completed.total").getCount(), Matchers.is(1L)); assertThat(metrics.getMeter("rpcServer.error.total").getCount(), Matchers.is(0L)); }