Search in sources :

Example 21 with InvalidMvp4gConfigurationException

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());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) OneObject(com.mvp4g.rebind.test_tools.OneObject) Test(org.junit.Test)

Example 22 with InvalidMvp4gConfigurationException

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();
}
Also used : HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Modules(com.mvp4g.rebind.test_tools.Modules) Test(org.junit.Test)

Example 23 with InvalidMvp4gConfigurationException

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());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) ChildModulesElement(com.mvp4g.rebind.config.element.ChildModulesElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) OneObject(com.mvp4g.rebind.test_tools.OneObject) Test(org.junit.Test)

Example 24 with InvalidMvp4gConfigurationException

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);
}
Also used : GinModuleElement(com.mvp4g.rebind.config.element.GinModuleElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) OneGinModule(com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule) DefaultMvp4gGinModule(com.mvp4g.client.DefaultMvp4gGinModule) OneGinModule(com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule) DefaultMvp4gGinModule(com.mvp4g.client.DefaultMvp4gGinModule) GinModule(com.google.gwt.inject.client.GinModule) OneObject(com.mvp4g.rebind.test_tools.OneObject) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 25 with InvalidMvp4gConfigurationException

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());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Test(org.junit.Test)

Aggregations

InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)27 Test (org.junit.Test)26 EventElement (com.mvp4g.rebind.config.element.EventElement)18 OneObject (com.mvp4g.rebind.test_tools.OneObject)11 Modules (com.mvp4g.rebind.test_tools.Modules)9 ChildModuleElement (com.mvp4g.rebind.config.element.ChildModuleElement)5 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)3 GinModule (com.google.gwt.inject.client.GinModule)3 DefaultMvp4gGinModule (com.mvp4g.client.DefaultMvp4gGinModule)3 BaseEventBus (com.mvp4g.client.event.BaseEventBus)3 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)3 GinModuleElement (com.mvp4g.rebind.config.element.GinModuleElement)3 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)3 StartElement (com.mvp4g.rebind.config.element.StartElement)3 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)3 EventBusOk (com.mvp4g.rebind.test_tools.annotation.events.EventBusOk)3 OneGinModule (com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule)3 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)2 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)2 ViewElement (com.mvp4g.rebind.config.element.ViewElement)2