### Question:
TaskEventDispatcher { public void unregisterPartition(ResultPartitionID partitionId) { checkNotNull(partitionId); synchronized (registeredHandlers) { LOG.debug("unregistering {}", partitionId); registeredHandlers.remove(partitionId); } }  void registerPartition(ResultPartitionID partitionId); void unregisterPartition(ResultPartitionID partitionId); void subscribeToEvent(
			ResultPartitionID partitionId,
			EventListener<TaskEvent> eventListener,
			Class<? extends TaskEvent> eventType); boolean publish(ResultPartitionID partitionId, TaskEvent event); void clearAll();  }### Answer:
@Test public void unregisterPartition() throws Exception { ResultPartitionID partitionId1 = new ResultPartitionID(); ResultPartitionID partitionId2 = new ResultPartitionID(); TaskEventDispatcher ted = new TaskEventDispatcher(); AllWorkersDoneEvent event = new AllWorkersDoneEvent(); assertFalse(ted.publish(partitionId1, event)); ted.registerPartition(partitionId1); ted.registerPartition(partitionId2); OneShotEventListener eventListener1a = new OneShotEventListener(event); ZeroShotEventListener eventListener1b = new ZeroShotEventListener(); OneShotEventListener eventListener2 = new OneShotEventListener(event); ted.subscribeToEvent(partitionId1, eventListener1a, AllWorkersDoneEvent.class); ted.subscribeToEvent(partitionId2, eventListener1b, AllWorkersDoneEvent.class); ted.subscribeToEvent(partitionId1, eventListener2, AllWorkersDoneEvent.class); ted.unregisterPartition(partitionId2); assertTrue(ted.publish(partitionId1, event)); assertTrue("listener should have fired for AllWorkersDoneEvent", eventListener1a.fired); assertTrue("listener should have fired for AllWorkersDoneEvent", eventListener2.fired); assertFalse(ted.publish(partitionId2, event)); }