@Override
    public Optional<AllocatedSlot> removeSlot(AllocationID allocationId) {
        final AllocatedSlot removedSlot = removeSlotInternal(allocationId);

        if (removedSlot != null) {
            final ResourceID owner = removedSlot.getTaskManagerId();

            slotsPerTaskExecutor.computeIfPresent(
                    owner,
                    (resourceID, allocationIds) -> {
                        allocationIds.remove(allocationId);

                        if (allocationIds.isEmpty()) {
                            return null;
                        }

                        return allocationIds;
                    });

            return Optional.of(removedSlot);
        } else {
            return Optional.empty();
        }
    }
@Test
    void testRemoveSlot() {
        final DefaultAllocatedSlotPool slotPool = new DefaultAllocatedSlotPool();

        final Collection<AllocatedSlot> slots = createAllocatedSlots();

        slotPool.addSlots(slots, 0);

        final Iterator<AllocatedSlot> iterator = slots.iterator();
        final AllocatedSlot removedSlot = iterator.next();
        iterator.remove();

        slotPool.removeSlot(removedSlot.getAllocationId());

        assertSlotPoolContainsSlots(slotPool, slots);
    }