use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSameHistoryName.
@Test
public void testSameHistoryName() {
EventElement e = newEvent("start");
e.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
e.setHistory("history");
e.setName("name");
events.add(e);
e = newEvent("start2");
e.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
e.setHistory("history");
e.setName("name");
events.add(e);
try {
configuration.validateHistoryConverters();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals("Event start2: history name already used for another event: name.", ex.getMessage());
}
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testHistoryName.
@Test
public void testHistoryName() throws InvalidMvp4gConfigurationException {
historyConverters.add(new HistoryConverterElement());
configuration.setModule(oracle.addClass(Modules.ModuleWithParentNoName.class));
setParentEventBus(Modules.ModuleWithParentNoName.class, EventBusOk.class);
configuration.loadParentModule();
assertNull(configuration.getHistoryName());
try {
configuration.validateHistory();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Child module that defines history converter must have a"));
}
configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
setParentEventBus(Modules.ModuleWithParent01.class, EventBusOk.class);
configuration.loadParentModule();
assertEquals("moduleWithParent01", configuration.getHistoryName());
configuration.validateHistory();
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testWrongEventLoadConfigEvent.
@Test
public void testWrongEventLoadConfigEvent() throws InvalidMvp4gConfigurationException {
configuration.setHistory(null);
EventElement e = newEvent("event");
e.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
events.add(e);
ChildModulesElement childModules = new ChildModulesElement();
configuration.setLoadChildConfig(childModules);
childModules.setBeforeEvent("event");
try {
configuration.validateEvents();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals(String.format("%s: %s event %s can't have any object associated with it.", childModules.getTagName(), "Before", "event"), ex.getMessage());
}
childModules = new ChildModulesElement();
configuration.setLoadChildConfig(childModules);
childModules.setAfterEvent("event");
try {
configuration.validateEvents();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals(String.format("%s: %s event %s can't have any object associated with it.", childModules.getTagName(), "After", "event"), ex.getMessage());
}
childModules = new ChildModulesElement();
configuration.setLoadChildConfig(childModules);
childModules.setErrorEvent("event");
try {
configuration.validateEvents();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals("childModules: Error event event can only be associated with one and only one object with type java.lang.Throwable", ex.getMessage());
}
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGin02.
@Test
public void testGin02() throws InvalidMvp4gConfigurationException {
GinModuleElement gin = new GinModuleElement();
configuration.setGinModule(gin);
try {
configuration.validateGinModule();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals(e.getMessage(), "You need to define at least one GIN module. If you don't want to specify a GIN module, don't override the GIN modules option to use the default Mvp4g GIN module.");
}
gin = new GinModuleElement();
oracle.addClass(OneObject.class);
gin.setModules(new String[] { OneObject.class.getCanonicalName() });
configuration.setGinModule(gin);
try {
configuration.validateGinModule();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains(GinModule.class.getCanonicalName()));
}
String[] propertiesValues;
gin = new GinModuleElement();
oracle.addClass(DefaultMvp4gGinModule.class);
oracle.addClass(OneGinModule.class);
gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName(), OneGinModule.class.getCanonicalName() });
configuration.setGinModule(gin);
propertiesValues = configuration.validateGinModule();
assertNull(propertiesValues);
assertEquals(gin.getModules().size(), 2);
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testMissingChildModule.
@Test
public void testMissingChildModule() throws InvalidMvp4gConfigurationException {
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("Event testEvent: No instance of child has been found. Is this module a child module, a parent module or a silbling module? If it's supposed to be a child module, have you forgotten to add it to @ChildModules of your event bus interface?", e.getMessage());
}
}
Aggregations