use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEmptyHistoryNameForRoot.
@Test
public void testEmptyHistoryNameForRoot() {
EventElement e = newEvent("start");
e.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
e.setHistory("history");
e.setName("");
events.add(e);
try {
configuration.validateHistoryConverters();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals("Event start: An event of the Mvp4g Root module can't have an history name equal to empty string.", ex.getMessage());
}
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testForwardSiblingModule.
@Test
public void testForwardSiblingModule() throws InvalidMvp4gConfigurationException {
String siblingModule = oracle.addClass(Modules.Module01.class).getQualifiedSourceName();
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { siblingModule });
event.setEventObjectClass(new String[] { String.class.getCanonicalName() });
events.add(event);
String currentParentModule = oracle.addClass(Modules.ModuleWithParentNoName.class).getQualifiedSourceName();
Map<String, ChildModuleElement> childModuleMap = configuration.getModuleParentEventBusClassMap();
JClassType parentEventBus = oracle.addClass(EventBusOk.class);
ChildModuleElement sibling = new ChildModuleElement();
sibling.setParentEventBus(parentEventBus);
sibling.setParentModuleClass(currentParentModule);
sibling.setClassName(siblingModule);
configuration.setParentEventBus(parentEventBus);
String currentModule = oracle.addClass(Modules.ModuleWithParent01.class).getQualifiedSourceName();
childModuleMap.put("sibling", sibling);
ChildModuleElement module = new ChildModuleElement();
module.setParentEventBus(parentEventBus);
module.setParentModuleClass(currentParentModule);
module.setClassName(currentModule);
childModuleMap.put(currentModule, module);
setEventBus();
configuration.setModule(oracle.findType(Modules.ModuleWithParent01.class.getCanonicalName()));
List<ChildModuleElement> siblings = configuration.getSiblings();
assertEquals(1, siblings.size());
assertSame(sibling, siblings.get(0));
assertEquals(1, event.getForwardToModules().size());
assertEquals(0, event.getSiblingsToLoad().size());
configuration.validateChildModules();
assertEquals(0, event.getForwardToModules().size());
assertEquals(1, event.getSiblingsToLoad().size());
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testActivateDeActivateUseless.
@Test
public void testActivateDeActivateUseless() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event1 = newEvent("event1");
event1.setActivate(new String[] { "activate1", "activate2" });
event1.setDeactivate(new String[] { "deactivate1", "deactivate2" });
events.add(event1);
PresenterElement activate1 = newPresenter(SimplePresenter01.class, "activate1");
EventHandlerElement activate2 = newEventHandler(SimpleEventHandler01.class, "activate2");
PresenterElement deactivate1 = newPresenter(SimplePresenter02.class, "deactivate1");
EventHandlerElement deactivate2 = newEventHandler(SimpleEventHandler02.class, "deactivate2");
eventHandlers.add(activate1);
eventHandlers.add(activate2);
eventHandlers.add(deactivate1);
eventHandlers.add(deactivate2);
configuration.validateEventHandlers();
List<String> activate = event1.getActivate();
assertTrue(activate.size() == 0);
List<String> deactivate = event1.getDeactivate();
assertTrue(deactivate.size() == 0);
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHistoryConverterRemove.
@Test
public void testEventHistoryConverterRemove() throws InvalidMvp4gConfigurationException {
HistoryConverterElement hc1 = newHistoryConverter(SimpleHistoryConverter01.class, "hc1");
HistoryConverterElement hc2 = newHistoryConverter(SimpleHistoryConverter02.class, "hc2");
historyConverters.add(hc1);
historyConverters.add(hc2);
EventElement event = newEvent("testEvent");
event.setHistory("hc1");
events.add(event);
setEventBus();
assertEquals(2, historyConverters.size());
assertTrue(historyConverters.contains(hc1));
assertTrue(historyConverters.contains(hc2));
configuration.validateHistoryConverters();
assertEquals(1, historyConverters.size());
assertTrue(historyConverters.contains(hc1));
assertFalse(historyConverters.contains(hc2));
configuration.validateHistoryConverters();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSiblingBroadcast.
@Test
public void testSiblingBroadcast() throws InvalidMvp4gConfigurationException {
String siblingModule1 = oracle.addClass(Modules.BroadcastModule.class).getQualifiedSourceName();
String siblingModule2 = oracle.addClass(Modules.BroadcastModule2.class).getQualifiedSourceName();
String siblingModule3 = oracle.addClass(Modules.Module01.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());
event2.setForwardToModules(new String[] { siblingModule3 });
events.add(event2);
String currentParentModule = oracle.addClass(Modules.ModuleWithParentNoName.class).getQualifiedSourceName();
Map<String, ChildModuleElement> childModuleMap = configuration.getModuleParentEventBusClassMap();
JClassType parentEventBus = oracle.addClass(EventBusOk.class);
ChildModuleElement sibling1 = new ChildModuleElement();
sibling1.setParentEventBus(parentEventBus);
sibling1.setParentModuleClass(currentParentModule);
sibling1.setClassName(siblingModule1);
ChildModuleElement sibling2 = new ChildModuleElement();
sibling2.setParentEventBus(parentEventBus);
sibling2.setParentModuleClass(currentParentModule);
sibling2.setClassName(siblingModule2);
ChildModuleElement sibling3 = new ChildModuleElement();
sibling3.setParentEventBus(parentEventBus);
sibling3.setParentModuleClass(currentParentModule);
sibling3.setClassName(siblingModule3);
childModuleMap.put("sibling1", sibling1);
childModuleMap.put("sibling2", sibling2);
childModuleMap.put("sibling3", sibling3);
configuration.setParentEventBus(parentEventBus);
configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
String currentModule01 = Modules.ModuleWithParent01.class.getCanonicalName();
ChildModuleElement module01 = new ChildModuleElement();
module01.setParentEventBus(parentEventBus);
module01.setParentModuleClass(currentParentModule);
module01.setClassName(currentModule01);
childModuleMap.put(currentModule01, module01);
setEventBus();
List<ChildModuleElement> siblings = configuration.getSiblings();
assertEquals(3, siblings.size());
assertSame(sibling1, siblings.get(0));
assertSame(sibling3, siblings.get(1));
assertSame(sibling2, siblings.get(2));
assertEquals(0, event.getSiblingsToLoad().size());
assertEquals(1, event2.getForwardToModules().size());
configuration.validateChildModules();
List<String> siblingsToLoad = event.getSiblingsToLoad();
assertEquals(2, siblingsToLoad.size());
assertEquals(sibling1.getClassName(), siblingsToLoad.get(0));
assertEquals(sibling2.getClassName(), siblingsToLoad.get(1));
siblingsToLoad = event2.getSiblingsToLoad();
assertEquals(2, siblingsToLoad.size());
assertEquals(sibling3.getClassName(), siblingsToLoad.get(0));
assertEquals(sibling2.getClassName(), siblingsToLoad.get(1));
}
Aggregations