public void subscribeToEvent(
            ResultPartitionID partitionId,
            EventListener<TaskEvent> eventListener,
            Class<? extends TaskEvent> eventType) {
        checkNotNull(partitionId);
        checkNotNull(eventListener);
        checkNotNull(eventType);

        TaskEventHandler taskEventHandler;
        synchronized (registeredHandlers) {
            taskEventHandler = registeredHandlers.get(partitionId);
        }
        if (taskEventHandler == null) {
            throw new IllegalStateException(
                    "Partition " + partitionId + " not registered at task event dispatcher.");
        }
        taskEventHandler.subscribe(eventListener, eventType);
    }
@Test
    void subscribeToEventNotRegistered() {
        TaskEventDispatcher ted = new TaskEventDispatcher();
        assertThatThrownBy(
                        () ->
                                ted.subscribeToEvent(
                                        new ResultPartitionID(),
                                        new ZeroShotEventListener(),
                                        TaskEvent.class))
                .hasMessageContaining("not registered at task event dispatcher")
                .isInstanceOf(IllegalStateException.class);
    }