MetricsHandler extends PipelinedHandler { MetricRegistry getMetricsRegistry(MongoRequest request, METRICS_GATHERING_LEVEL metricsLevel) { switch (metricsLevel) { case ROOT: return metrics.registry(); case DATABASE: return metrics.registry(request.getDBName()); case COLLECTION: return metrics.registry(request.getDBName(), request.getCollectionName()); default: return null; } } MetricsHandler();  MetricsHandler(PipelinedHandler next); @Override void handleRequest(HttpServerExchange exchange);  }
@Test public void testMetricsRegistryForRequestToRoot() { var requestContext = createRequest(URI_METRICS_ROOT); handler.getMetricsRegistry(requestContext, ROOT); verify(handler.metrics, times(1)).registry(); }
@Test public void testMetricsRegistryForRequestToDatabase() { var requestContext = createRequest(URI_METRICS_DATABASE); handler.getMetricsRegistry(requestContext, DATABASE); verify(handler.metrics, times(1)).registry(eq(requestContext.getDBName())); }
@Test public void testMetricsRegistryForRequestToCollection() { var requestContext = createRequest(URI_METRICS_COLLECTION); handler.getMetricsRegistry(requestContext, COLLECTION); verify(handler.metrics, times(1)).registry(eq(requestContext.getDBName()), eq(requestContext.getCollectionName())); }