public CompletableFuture<Map<ExecutionAttemptID, Collection<ThreadInfoSample>>>
            requestThreadInfoSamples(
                    Map<Long, ExecutionAttemptID> threads,
                    final ThreadInfoSamplesRequest requestParams) {
        checkNotNull(threads, "threads must not be null");
        checkNotNull(requestParams, "requestParams must not be null");

        CompletableFuture<Map<ExecutionAttemptID, Collection<ThreadInfoSample>>> resultFuture =
                new CompletableFuture<>();
        scheduledExecutor.execute(
                () ->
                        requestThreadInfoSamples(
                                threads,
                                requestParams.getNumSamples(),
                                requestParams.getDelayBetweenSamples(),
                                requestParams.getMaxStackTraceDepth(),
                                CollectionUtil.newHashMapWithExpectedSize(threads.size()),
                                resultFuture));
        return resultFuture;
    }
@Test
    void testThrowExceptionIfNumSamplesIsNegative() {
        Set<IdleTestTask> tasks = new HashSet<>();
        assertThatThrownBy(
                        () ->
                                executeWithTerminationGuarantee(
                                        () -> {
                                            tasks.add(new IdleTestTask());

                                            Map<Long, ExecutionAttemptID> threads =
                                                    collectExecutionAttempts(tasks);
                                            threadInfoSampleService.requestThreadInfoSamples(
                                                    threads,
                                                    new ThreadInfoSamplesRequest(
                                                            1,
                                                            -1,
                                                            DELAY_BETWEEN_SAMPLES,
                                                            MAX_STACK_TRACK_DEPTH));
                                        },
                                        tasks))
                .isInstanceOf(IllegalArgumentException.class)
                .hasMessage("numSamples must be positive");
    }