@Override
    protected final CompletableFuture<MetricCollectionResponseBody> handleRequest(
            @Nonnull HandlerRequest<EmptyRequestBody> request, @Nonnull RestfulGateway gateway)
            throws RestHandlerException {
        metricFetcher.update();

        final MetricStore.ComponentMetricStore componentMetricStore =
                getComponentMetricStore(request, metricFetcher.getMetricStore());

        if (componentMetricStore == null || componentMetricStore.metrics == null) {
            return CompletableFuture.completedFuture(
                    new MetricCollectionResponseBody(Collections.emptyList()));
        }

        final Set<String> requestedMetrics =
                new HashSet<>(request.getQueryParameter(MetricsFilterParameter.class));

        if (requestedMetrics.isEmpty()) {
            return CompletableFuture.completedFuture(
                    new MetricCollectionResponseBody(getAvailableMetrics(componentMetricStore)));
        } else {
            final List<Metric> metrics =
                    getRequestedMetrics(componentMetricStore, requestedMetrics);
            return CompletableFuture.completedFuture(new MetricCollectionResponseBody(metrics));
        }
    }
@Test
    void testListMetrics() throws Exception {
        final CompletableFuture<MetricCollectionResponseBody> completableFuture =
                testMetricsHandler.handleRequest(
                        HandlerRequest.create(
                                EmptyRequestBody.getInstance(),
                                new TestMessageParameters(),
                                Collections.emptyList()),
                        mockDispatcherGateway);

        assertThat(completableFuture).isDone();

        final MetricCollectionResponseBody metricCollectionResponseBody = completableFuture.get();
        assertThat(metricCollectionResponseBody.getMetrics()).hasSize(1);

        final Metric metric = metricCollectionResponseBody.getMetrics().iterator().next();
        assertThat(metric.getId()).isEqualTo(TEST_METRIC_NAME);
        assertThat(metric.getValue()).isNull();
    }