use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testForwardParentModule.
@Test
public void testForwardParentModule() throws InvalidMvp4gConfigurationException {
String parentModule = oracle.addClass(Modules.Module01.class).getQualifiedSourceName();
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { parentModule });
event.setEventObjectClass(new String[] { String.class.getCanonicalName() });
events.add(event);
Map<String, ChildModuleElement> childModuleMap = configuration.getModuleParentEventBusClassMap();
JClassType parentEventBus = oracle.addClass(EventBusOk.class);
configuration.setParentEventBus(parentEventBus);
String currentModule = oracle.addClass(Modules.ModuleWithParent01.class).getQualifiedSourceName();
ChildModuleElement module = new ChildModuleElement();
module.setParentEventBus(parentEventBus);
module.setParentModuleClass(parentModule);
module.setClassName(currentModule);
childModuleMap.put(currentModule, module);
setEventBus();
configuration.setModule(oracle.findType(Modules.ModuleWithParent01.class.getCanonicalName()));
List<ChildModuleElement> siblings = configuration.getSiblings();
assertEquals(0, siblings.size());
assertFalse(event.hasForwardToParent());
configuration.validateChildModules();
assertTrue(event.hasForwardToParent());
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHandlerWrongInterface.
@Test(expected = InvalidClassException.class)
public void testEventHandlerWrongInterface() throws InvalidMvp4gConfigurationException {
ViewElement view = newView(SimpleView02.class, "view");
views.add(view);
PresenterElement presenter = new PresenterElement();
presenter.setName("testHandler");
presenter.setView("view");
presenter.setClassName(Object.class.getName());
presenters.add(presenter);
EventElement event = newEvent("testEvent");
event.setHandlers(new String[] { "testHandler" });
events.add(event);
setEventBus();
configuration.validateEventHandlers();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventWithParent.
@Test
public void testEventWithParent() throws InvalidMvp4gConfigurationException {
EventElement e = newEvent("event");
e.setForwardToParent("true");
events.add(e);
try {
configuration.validateEvents();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals("Event event: Root module has no parent so you can't forward event to parent.", ex.getMessage());
}
configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
setParentEventBus(Modules.ModuleWithParent01.class, EventBusOk.class);
configuration.loadParentModule();
configuration.validateEvents();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHandlerViewMissing.
@Test(expected = UnknownConfigurationElementException.class)
public void testEventHandlerViewMissing() throws InvalidMvp4gConfigurationException {
PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
presenter.setView("view");
presenters.add(presenter);
EventElement event = newEvent("testEvent");
event.setHandlers(new String[] { "testHandler" });
events.add(event);
setEventBus();
configuration.validateEventHandlers();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGenerateNotMultiple.
@Test
public void testGenerateNotMultiple() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event1 = newEvent("event1");
event1.setHandlers(new String[] { "generate2" });
event1.setGenerate(new String[] { "generate1", "generate2" });
events.add(event1);
ViewElement view = newView(SimpleView02.class, "view");
view.setClassName(SimpleView02.class.getCanonicalName());
views.add(view);
PresenterElement generate1 = newPresenter(SimplePresenter01.class, "generate1");
generate1.setView("view");
EventHandlerElement generate2 = newEventHandler(SimpleEventHandler01.class, "generate2");
presenters.add(generate1);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Event event1: you can generate only multiple handlers. Did you forget to set the attribute multiple to true for generate1?"));
}
presenters.clear();
eventHandlers.clear();
eventHandlers.add(generate2);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Event event1: you can generate only multiple handlers. Did you forget to set the attribute multiple to true for generate2?"));
}
}
Aggregations