@Override
    protected CompletableFuture<ProfilingInfo> handleRequest(
            @Nonnull HandlerRequest<ProfilingRequestBody> request,
            @Nonnull ResourceManagerGateway gateway)
            throws RestHandlerException {
        ProfilingRequestBody profilingRequest = request.getRequestBody();
        int duration = profilingRequest.getDuration();
        if (duration <= 0 || duration > maxDurationInSeconds) {
            return FutureUtils.completedExceptionally(
                    new IllegalArgumentException(
                            String.format(
                                    "`duration` must be set between (0s, %ds].",
                                    maxDurationInSeconds)));
        }
        final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
        return gateway.requestProfiling(
                taskManagerId, duration, profilingRequest.getMode(), getTimeout());
    }
@Test
    void testGetTaskManagerProfiling() throws Exception {
        ProfilingInfo profilingInfo = ProfilingInfo.create(30, ProfilingInfo.ProfilingMode.ITIMER);
        resourceManagerGateway.setRequestProfilingFunction(
                EXPECTED_TASK_MANAGER_ID -> CompletableFuture.completedFuture(profilingInfo));
        ProfilingInfo profilingInfoResp =
                taskManagerProfilingHandler
                        .handleRequest(handlerRequest, resourceManagerGateway)
                        .get();
        assertThat(profilingInfoResp).isEqualTo(profilingInfo);
    }