use of com.mvp4g.rebind.exception.InvalidTypeException 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.exception.InvalidTypeException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHistoryConverterWrongEventBus.
@Test(expected = InvalidTypeException.class)
public void testEventHistoryConverterWrongEventBus() throws InvalidMvp4gConfigurationException {
try {
HistoryConverterElement hc = new HistoryConverterElement();
hc.setName("testHistoryConverter");
Class<?> c = HistoryConverters.HistoryConverterWithLookup.class;
oracle.addClass(c);
hc.setClassName(c.getCanonicalName());
historyConverters.add(hc);
EventElement event = newEvent("testEvent");
event.setHistory("testHistoryConverter");
events.add(event);
EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
configuration.validateHistoryConverters();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("Event Bus"));
throw e;
}
}
use of com.mvp4g.rebind.exception.InvalidTypeException 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.InvalidTypeException 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.InvalidTypeException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHandlerValidationInvalidView.
@Test
public void testEventHandlerValidationInvalidView() throws InvalidMvp4gConfigurationException {
ViewElement view = newView(SimpleView02.class, "view");
view.setClassName(Integer.class.getName());
views.add(view);
PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
presenter.setView("view");
presenters.add(presenter);
EventElement event = newEvent("testEvent");
event.setHandlers(new String[] { "testHandler" });
events.add(event);
try {
setEventBus();
configuration.validateEventHandlers();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("View"));
}
presenter.setMultiple(Boolean.TRUE.toString());
try {
setEventBus();
configuration.validateEventHandlers();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("View"));
}
}
Aggregations