use of com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01 in project mvp4g by mvp4g.
the class BaseEventBusTest method testSetEventHandler.
@Test
public void testSetEventHandler() {
SimpleEventHandler01 eventHandler = new SimpleEventHandler01();
SimpleEventHandler01 eventHandler2 = BaseEventBus.setEventHandler(eventHandler, bus);
assertSame(eventHandler, eventHandler2);
assertSame(eventHandler.getEventBus(), bus);
}
use of com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01 in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testWrongEventHandlerClass.
@Test
public void testWrongEventHandlerClass() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event = newEvent("event");
event.setHandlers(new String[] { "test" });
events.add(event);
EventHandlerElement handler = new EventHandlerElement();
handler.setClassName(Object.class.getCanonicalName());
handler.setName("test");
eventHandlers.add(handler);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidClassException e) {
}
handler.setMultiple(Boolean.TRUE.toString());
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidClassException e) {
}
PresenterElement presenter = new PresenterElement();
Class<?> c = SimpleEventHandler01.class;
oracle.addClass(c);
presenter.setClassName(c.getCanonicalName());
presenter.setName("test");
presenters.add(presenter);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidClassException e) {
}
presenter.setMultiple(Boolean.TRUE.toString());
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidClassException e) {
}
}
use of com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01 in project mvp4g by mvp4g.
the class Mvp4gConfigurationFileReaderTest method testWriteSplitterWithLoader.
@Test
public void testWriteSplitterWithLoader() {
ViewElement view = new ViewElement();
view.setName("view");
view.setClassName(String.class.getCanonicalName());
configuration.getViews().add(view);
PresenterElement presenter = new PresenterElement();
presenter.setName("presenter");
presenter.setClassName(SimplePresenter01.class.getCanonicalName());
presenter.setView("view");
configuration.getPresenters().add(presenter);
PresenterElement presenterWithView = new PresenterElement();
presenterWithView.setName("presenterWithView");
presenterWithView.setClassName(SimplePresenter01.class.getCanonicalName());
presenterWithView.setView("view");
presenterWithView.setInverseView("true");
configuration.getPresenters().add(presenterWithView);
EventHandlerElement eventHandler = new EventHandlerElement();
eventHandler.setName("eventHandler");
eventHandler.setClassName(SimpleEventHandler01.class.getCanonicalName());
configuration.getEventHandlers().add(eventHandler);
EventElement e1 = new EventElement();
e1.setType("event1");
e1.setSplitters(new String[] { "splitter" });
e1.setEventObjectClass(new String[] { "int", "String" });
EventElement e2 = new EventElement();
e2.setType("event2");
e2.setSplitters(new String[] { "splitter" });
EventElement e3 = new EventElement();
e3.setType("event3");
e3.setSplitters(new String[] { "splitter" });
SplitterElement splitter = new SplitterElement();
splitter.getHandlers().add(presenter);
splitter.getHandlers().add(presenterWithView);
splitter.getHandlers().add(eventHandler);
splitter.setName("splitter");
splitter.setClassName("Splitter");
EventAssociation<String> ea1 = new EventAssociation<String>();
ea1.getActivated().add("eventHandler");
ea1.getDeactivated().add("presenter");
ea1.getBinds().add("presenter");
ea1.getHandlers().add("eventHandler");
splitter.getEvents().put(e1, ea1);
EventAssociation<String> ea2 = new EventAssociation<String>();
ea2.getActivated().add("eventHandler");
ea2.getDeactivated().add("presenter");
splitter.getEvents().put(e2, ea2);
EventAssociation<String> ea3 = new EventAssociation<String>();
ea3.getBinds().add("presenter");
splitter.getEvents().put(e3, ea3);
JClassType loaderType = ((TypeOracleStub) configuration.getOracle()).addClass(Loaders.Loader1.class);
LoaderElement loader = new LoaderElement();
loader.setName("loader");
loader.setClassName(loaderType.getQualifiedSourceName());
configuration.getLoaders().add(loader);
splitter.setLoader("loader");
Set<EventElement> events = configuration.getEvents();
events.add(e1);
events.add(e2);
events.add(e3);
configuration.getSplitters().add(splitter);
assertOutput(getExpectedSplitter(false), false);
assertOutput(getExpectedSplitterLoadingConf(), false);
assertOutput(getExpectedSplitterPassiveGenerateMultiple(), false);
assertOutput(getExpectedSplitterNotPassive(), false);
assertOutput(getExpectedSplitterWithLoader(), false);
writer.writeConf();
assertOutput(getExpectedSplitter(false), true);
assertOutput(getExpectedSplitterLoadingConf(), false);
assertOutput(getExpectedSplitterPassiveGenerateMultiple(), false);
assertOutput(getExpectedSplitterNotPassive(), true);
assertOutput(getExpectedSplitterWithLoader(), true);
}
Aggregations