DynamicEventizer implements Eventizer<T> { @Override public MessageSender<Event<T>> newBackend(T target) { return new EventToDynamicListener<>(target); } DynamicEventizer(Class<T> type); @Override Class<T> getType(); @Override T newFrontend(MessageSender<Event<T>> target); @Override MessageSender<Event<T>> newBackend(T target);  }
@Test public void event_objects_are_converted_back_into_method_calls() { DummyListener target = mock(DummyListener.class); MessageSender<Event<DummyListener>> backend = eventizer.newBackend(target); frontend.onSomething("param"); Event<DummyListener> event = queue.poll(); backend.send(event); verify(target).onSomething("param"); }
@Test public void event_objects_are_serializable() throws Exception { DummyListener target = mock(DummyListener.class); MessageSender<Event<DummyListener>> backend = eventizer.newBackend(target); frontend.onSomething("param"); Event<DummyListener> original = queue.poll(); Event<DummyListener> deserialized = deserialize(serialize(original)); backend.send(deserialized); verify(target).onSomething("param"); }