use of com.mvp4g.rebind.config.element.ChildModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventWithNoObjectForAutoDisplay.
@Test(expected = InvalidMvp4gConfigurationException.class)
public void testEventWithNoObjectForAutoDisplay() throws InvalidMvp4gConfigurationException {
ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
childModule1.setEventToDisplayView("testEvent");
childModules.add(childModule1);
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { "child1" });
events.add(event);
setEventBus();
try {
configuration.validateChildModules();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Event testEvent: event must have one and only one an object associated with it as it loads a child view.", e.getMessage());
throw e;
}
}
use of com.mvp4g.rebind.config.element.ChildModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method newChildModule.
private ChildModuleElement newChildModule(Class<? extends Mvp4gModule> c, String name) {
ChildModuleElement childModule = new ChildModuleElement();
childModule.setName(name);
oracle.addClass(c);
childModule.setClassName(c.getCanonicalName());
return childModule;
}
use of com.mvp4g.rebind.config.element.ChildModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testChildModuleLoadersIncompatibleType.
@Test
public void testChildModuleLoadersIncompatibleType() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
oracle.addClass(Loaders.Loader1.class);
oracle.addClass(Modules.ModuleWithLoader.class);
ChildModuleElement withLoader = new ChildModuleElement();
withLoader.setName("withLoader");
withLoader.setClassName(Modules.ModuleWithLoader.class.getCanonicalName());
childModules.add(withLoader);
try {
configuration.findChildModuleHistoryNameAndLoader();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
}
}
use of com.mvp4g.rebind.config.element.ChildModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testFindChildModuleHistory.
@Test
public void testFindChildModuleHistory() throws InvalidMvp4gConfigurationException {
setEventBus();
oracle.addClass(Modules.ModuleWithParent01.class);
oracle.addClass(Modules.ModuleWithParentNoName.class);
oracle.addClass(Modules.Module01.class);
ChildModuleElement childModule1 = new ChildModuleElement();
childModule1.setName("child1");
childModule1.setClassName(Modules.ModuleWithParent01.class.getCanonicalName());
childModules.add(childModule1);
ChildModuleElement childModule2 = new ChildModuleElement();
childModule2.setName("child2");
childModule2.setClassName(Modules.Module01.class.getCanonicalName());
childModules.add(childModule2);
ChildModuleElement childModule3 = new ChildModuleElement();
childModule3.setName("child3");
childModule3.setClassName(Modules.ModuleWithParentNoName.class.getCanonicalName());
childModules.add(childModule3);
configuration.findChildModuleHistoryNameAndLoader();
assertNull(childModule2.getHistoryName());
assertNull(childModule3.getHistoryName());
assertEquals("moduleWithParent01", childModule1.getHistoryName());
}
use of com.mvp4g.rebind.config.element.ChildModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testChildViewLoadEvent.
@Test
public void testChildViewLoadEvent() throws InvalidMvp4gConfigurationException {
ChildModuleElement childModule = newChildModule(Modules.ChildModule01.class, "child");
childModule.setEventToDisplayView("testEvent");
configuration.getOthersEventBusClassMap().put(Modules.ChildModule01.class.getCanonicalName(), oracle.addClass(EventBusOk.class));
childModules.add(childModule);
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { "child" });
event.setEventObjectClass(new String[] { String.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("Child Module %s: event %s can not load child module's start view. Can not convert %s to %s.", childModule.getClassName(), "testEvent", SimpleView.class.getCanonicalName(), String.class.getCanonicalName()));
}
event = newEvent("testEvent");
event.setForwardToModules(new String[] { "child" });
event.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
events.clear();
events.add(event);
configuration.validateChildModules();
}
Aggregations