public void registerPartition(ResultPartitionID partitionId) {
        checkNotNull(partitionId);

        synchronized (registeredHandlers) {
            LOG.debug("registering {}", partitionId);
            if (registeredHandlers.put(partitionId, new TaskEventHandler()) != null) {
                throw new IllegalStateException(
                        "Partition "
                                + partitionId
                                + " already registered at task event dispatcher.");
            }
        }
    }
@Test
    void registerPartitionTwice() {
        ResultPartitionID partitionId = new ResultPartitionID();
        TaskEventDispatcher ted = new TaskEventDispatcher();
        ted.registerPartition(partitionId);

        assertThatThrownBy(() -> ted.registerPartition(partitionId))
                .hasMessageContaining("already registered at task event dispatcher")
                .isInstanceOf(IllegalStateException.class);
    }