Optional<TaskExecutorProcessSpecAndResource> getTaskExecutorProcessSpecAndResource(
            Priority priority) {
        final TaskExecutorProcessSpec taskExecutorProcessSpec =
                priorityToTaskExecutorProcessSpec.get(priority);

        if (taskExecutorProcessSpec == null) {
            return Optional.empty();
        }

        final PriorityAndResource priorityAndResource =
                taskExecutorProcessSpecToPriorityAndResource.get(taskExecutorProcessSpec);
        Preconditions.checkState(priorityAndResource != null);
        Preconditions.checkState(priority.equals(priorityAndResource.getPriority()));

        return Optional.of(
                new TaskExecutorProcessSpecAndResource(
                        taskExecutorProcessSpec, priorityAndResource.getResource()));
    }
@Test
    void testGetTaskExecutorProcessSpecAndResource() {
        final TaskExecutorProcessSpecContainerResourcePriorityAdapter adapter = getAdapter();

        final TaskExecutorProcessSpecContainerResourcePriorityAdapter.PriorityAndResource
                addedPriorityAndResource =
                        adapter.getPriorityAndResource(TASK_EXECUTOR_PROCESS_SPEC_1).get();
        final Priority unknownPriority = Priority.newInstance(987);

        final TaskExecutorProcessSpecContainerResourcePriorityAdapter
                        .TaskExecutorProcessSpecAndResource
                resultSpecAndResource =
                        adapter.getTaskExecutorProcessSpecAndResource(
                                        addedPriorityAndResource.getPriority())
                                .get();

        assertThat(resultSpecAndResource.getTaskExecutorProcessSpec())
                .isEqualTo(TASK_EXECUTOR_PROCESS_SPEC_1);
        assertThat(resultSpecAndResource.getResource())
                .isEqualTo(addedPriorityAndResource.getResource());
        assertThat(adapter.getTaskExecutorProcessSpecAndResource(unknownPriority)).isNotPresent();
    }