use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testParentBroadcast.
@Test
public void testParentBroadcast() throws InvalidMvp4gConfigurationException {
String parentModule = oracle.addClass(Modules.BroadcastModule2.class).getQualifiedSourceName();
EventElement event = newEvent("testEvent");
event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
event.setEventObjectClass(new String[] { String.class.getCanonicalName() });
events.add(event);
EventElement event2 = newEvent("testEvent2");
event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
events.add(event2);
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());
assertFalse(event2.hasForwardToParent());
configuration.validateChildModules();
assertTrue(event.hasForwardToParent());
assertTrue(event2.hasForwardToParent());
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHistoryConverterFails.
@Test(expected = UnknownConfigurationElementException.class)
public void testEventHistoryConverterFails() throws InvalidMvp4gConfigurationException {
events.add(newEvent("badHistoryConverter"));
services.add(newService("badHistoryConverter"));
presenters.add(newPresenter(SimplePresenter01.class, "badHistoryConverter"));
views.add(newView(SimpleView02.class, "badHistoryConverter"));
EventElement event = newEvent("testEvent");
event.setHistory("badView");
events.add(event);
setEventBus();
configuration.validateHistoryConverters();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testAutoDisplay.
@Test
public void testAutoDisplay() throws InvalidMvp4gConfigurationException {
ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
childModules.add(childModule1);
assertTrue(childModule1.isAutoDisplay());
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { "child1" });
event.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
events.add(event);
setEventBus();
configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
try {
configuration.validateChildModules();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals(e.getMessage(), String.format("%s: child module %s doesn't define any event to load its view.", Modules.ModuleWithParent01.class.getCanonicalName(), childModule1.getClassName()));
}
childModule1.setAutoDisplay("false");
configuration.validateChildModules();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testBroadcastHandlers.
@Test
public void testBroadcastHandlers() throws InvalidMvp4gConfigurationException {
oracle.addClass(TestBroadcast.class);
ViewElement view = newView(SimpleView01.class, "view");
views.add(view);
PresenterElement presenter = new PresenterElement();
presenter.setName("presenter");
Class<?> c = Presenters.BroadcastPresenter.class;
presenter.setClassName(c.getCanonicalName());
oracle.addClass(c);
presenter.setView("view");
presenters.add(presenter);
PresenterElement presenter2 = new PresenterElement();
presenter2.setName("presenter2");
c = Presenters.BroadcastPresenter2.class;
presenter2.setClassName(c.getCanonicalName());
oracle.addClass(c);
presenter2.setView("view");
presenters.add(presenter2);
PresenterElement presenter3 = new PresenterElement();
presenter3.setName("presenter3");
c = Presenters.BroadcastPresenter2.class;
presenter3.setClassName(c.getCanonicalName());
presenter3.setView("view");
presenters.add(presenter3);
EventElement event = newEvent("event");
event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
event.setHandlers(new String[0]);
events.add(event);
EventElement event2 = newEvent("event2");
event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
event2.setHandlers(new String[] { "presenter3" });
events.add(event2);
setEventBus();
configuration.validateEventHandlers();
List<String> handlers = event.getHandlers();
assertEquals(3, handlers.size());
assertEquals("presenter3", handlers.get(0));
assertEquals("presenter2", handlers.get(1));
assertEquals("presenter", handlers.get(2));
handlers = event2.getHandlers();
assertEquals(2, handlers.size());
assertEquals("presenter3", handlers.get(0));
assertEquals("presenter2", handlers.get(1));
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testTokenGenerationOk.
// ------------------------------------------------------------------------------
@Test
public void testTokenGenerationOk() throws InvalidMvp4gConfigurationException {
EventElement event = new EventElement();
event.setWithTokenGeneration("true");
event.setType("event1");
event.setHistory("history");
events.add(event);
event = new EventElement();
event.setWithTokenGeneration("true");
event.setType("event2");
event.setForwardToParent("true");
events.add(event);
HistoryConverterElement hc1 = newHistoryConverter(SimpleHistoryConverter01.class, "history");
historyConverters.add(hc1);
configuration.setModule(oracle.addClass(Modules.Module01.class));
setEventBus();
configuration.setParentEventBus(oracle.addClass(EventBusOk.class));
configuration.validateHistoryConverters();
}
Aggregations