use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testRootModuleWithHistoryName.
@Test
public void testRootModuleWithHistoryName() {
configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
EventBusElement eventBus = new EventBusElement(EventBusOk.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
assertTrue(configuration.isRootModule());
try {
configuration.loadParentModule();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Module " + Modules.ModuleWithParent01.class.getCanonicalName() + " can't have an history name since it's a root module.", e.getMessage());
}
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventBindsAnnotationRestriction.
@Test
public void testEventBindsAnnotationRestriction() throws InvalidMvp4gConfigurationException {
// checking situation when handlers has the same attributes as binds
EventElement event = newEvent("testEvent1");
event.setHandlers(new String[] { "handler1", "handler2" });
event.setBinds(new String[] { "hander3", "handler1" });
events.add(event);
setEventBus();
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Event testEvent1: the same handler handler1 is used in the bind and handlers attributes. If you need handler1 to handle this event, you should remove it from the bind attribute."));
} finally {
events.remove(event);
}
// checking situation when passive event has some binds
EventElement event2 = newEvent("testEvent2");
event2.setBinds(new String[] { "someHandler" });
event2.setPassive("true");
events.add(event2);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Passive event can't bind any elements. Remove bind attribute from the testEvent2 event in order to keep it passive."));
} finally {
events.remove(event2);
}
// checking that combination with broadcastTo and passive event don't lead to exception
PresenterElement presenter = newPresenter(SimplePresenter01.class, "testPresenter");
presenter.setMultiple("true");
presenter.setView("view");
presenters.add(presenter);
ViewElement view = newView(SimpleView01.class, "view");
views.add(view);
oracle.addClass(TestBroadcast.class);
EventElement event3 = newEvent("testEvent3");
event3.setPassive("true");
event3.setBroadcastTo(TestBroadcast.class.getCanonicalName());
event3.setGenerate(new String[] { "testPresenter" });
events.add(event3);
try {
assertTrue(event3.isPassive());
configuration.validateEventHandlers();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Passive event can't have any binds elements. Remove bind annotation from the testEvent3 event in order to keep it passive"));
fail();
} finally {
events.remove(event3);
presenters.remove(presenter);
}
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGinWithProperties.
@Test
public void testGinWithProperties() throws InvalidMvp4gConfigurationException {
String[] propertiesValues;
GinModuleElement gin = new GinModuleElement();
oracle.addClass(DefaultMvp4gGinModule.class);
gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
gin.setModuleProperties(new String[] { PropertyOracleStub.PROPERTY_OK });
configuration.setGinModule(gin);
propertiesValues = configuration.validateGinModule();
assertEquals(gin.getModules().size(), 2);
assertEquals(gin.getModules().get(0), DefaultMvp4gGinModule.class.getCanonicalName());
assertEquals(gin.getModules().get(1), DefaultMvp4gGinModule.class.getCanonicalName());
assertEquals(1, propertiesValues.length);
assertEquals(DefaultMvp4gGinModule.class.getCanonicalName(), propertiesValues[0]);
gin = new GinModuleElement();
oracle.addClass(OneGinModule.class);
gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
gin.setModuleProperties(new String[] { PropertyOracleStub.PROPERTY_OK, PropertyOracleStub.PROPERTY_OK2 });
configuration.setGinModule(gin);
propertiesValues = configuration.validateGinModule();
assertEquals(gin.getModules().size(), 3);
assertEquals(gin.getModules().get(0), DefaultMvp4gGinModule.class.getCanonicalName());
assertEquals(gin.getModules().get(1), DefaultMvp4gGinModule.class.getCanonicalName());
assertEquals(gin.getModules().get(2), OneGinModule.class.getCanonicalName());
assertEquals(2, propertiesValues.length);
assertEquals(DefaultMvp4gGinModule.class.getCanonicalName(), propertiesValues[0]);
assertEquals(OneGinModule.class.getCanonicalName(), propertiesValues[1]);
gin = new GinModuleElement();
gin.setModuleProperties(new String[] { "unknown" });
configuration.setGinModule(gin);
try {
configuration.validateGinModule();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("couldn't find a value for the GIN module property unknown"));
}
gin = new GinModuleElement();
oracle.addClass(String.class);
gin.setModuleProperties(new String[] { PropertyOracleStub.PROPERTY_NOT_GIN_MODULE });
configuration.setGinModule(gin);
try {
configuration.validateGinModule();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains(GinModule.class.getCanonicalName()));
}
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException 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();
}
use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testStartEventWithParameter.
@Test
public void testStartEventWithParameter() throws InvalidMvp4gConfigurationException {
EventElement e = newEvent("start");
e.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
events.add(e);
StartElement start = configuration.getStart();
start.setPresenter("startPresenter");
start.setEventType("start");
try {
configuration.validateStart();
fail();
} catch (InvalidMvp4gConfigurationException ex) {
assertEquals("Start: Start event start can't have any object associated with it.", ex.getMessage());
}
events.clear();
e = newEvent("start");
events.add(e);
configuration.validateStart();
}
Aggregations