protected boolean handleEvent(AbstractEvent event) throws IOException {
        final Class<?> eventType = event.getClass();

        try {
            // ------------------------------------------------------------
            // Runtime events
            // ------------------------------------------------------------

            // This event is also checked at the (single) input gate to release the respective
            // channel, at which it was received.
            if (eventType == EndOfPartitionEvent.class) {
                return true;
            } else if (eventType == EndOfSuperstepEvent.class) {
                return incrementEndOfSuperstepEventAndCheck();
            }

            // ------------------------------------------------------------
            // Task events (user)
            // ------------------------------------------------------------
            else if (event instanceof TaskEvent) {
                taskEventHandler.publish((TaskEvent) event);

                return false;
            } else {
                throw new IllegalStateException(
                        "Received unexpected event of type " + eventType + " at reader.");
            }
        } catch (Throwable t) {
            throw new IOException(
                    "Error while handling event of type " + eventType + ": " + t.getMessage(), t);
        }
    }
@Test
    void testEndOfPartitionEvent() throws Exception {
        final AbstractReader reader = new MockReader(createInputGate(1));

        assertThat(reader.handleEvent(EndOfPartitionEvent.INSTANCE)).isTrue();
    }