use of com.mvp4g.rebind.config.element.GinModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGin01.
@Test
public void testGin01() 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);
gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
configuration.setGinModule(gin);
propertiesValues = configuration.validateGinModule();
assertNull(propertiesValues);
assertEquals(gin.getModules().size(), 1);
}
use of com.mvp4g.rebind.config.element.GinModuleElement 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.config.element.GinModuleElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSetterGetter.
@Test
public void testSetterGetter() {
StartElement start = new StartElement();
configuration.setStart(start);
assertSame(start, configuration.getStart());
HistoryElement history = new HistoryElement();
configuration.setHistory(history);
assertSame(history, configuration.getHistory());
EventBusElement eventBus = new EventBusElement("", "", false);
configuration.setEventBus(eventBus);
assertSame(eventBus, configuration.getEventBus());
JClassType module = oracle.findType(Mvp4gModule.class.getCanonicalName());
configuration.setModule(module);
assertSame(module, configuration.getModule());
JClassType parentEventBus = oracle.addClass(EventBus.class);
configuration.setParentEventBus(parentEventBus);
assertSame(parentEventBus, configuration.getParentEventBus());
String historyName = "historyName";
configuration.setHistoryName("historyName");
assertSame(historyName, configuration.getHistoryName());
ChildModulesElement childConfig = new ChildModulesElement();
configuration.setLoadChildConfig(childConfig);
assertSame(childConfig, configuration.getLoadChildConfig());
DebugElement debug = new DebugElement();
configuration.setDebug(debug);
assertSame(debug, configuration.getDebug());
GinModuleElement gin = new GinModuleElement();
configuration.setGinModule(gin);
assertSame(gin, configuration.getGinModule());
EventFiltersElement filters = new EventFiltersElement();
configuration.setEventFilterConfiguration(filters);
assertSame(filters, configuration.getEventFilterConfiguration());
}
use of com.mvp4g.rebind.config.element.GinModuleElement 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);
}
Aggregations