Search in sources :

Example 1 with ChildModulesElement

use of com.mvp4g.rebind.config.element.ChildModulesElement in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testEventLoadConfigEventOk.

@Test
public void testEventLoadConfigEventOk() throws InvalidMvp4gConfigurationException {
    configuration.setHistory(null);
    EventElement e = newEvent("event");
    events.add(e);
    ChildModulesElement childModules = new ChildModulesElement();
    configuration.setLoadChildConfig(childModules);
    childModules.setBeforeEvent("event");
    childModules.setAfterEvent("event");
    childModules.setErrorEvent("event");
    configuration.validateEvents();
    e = newEvent("event2");
    e.setEventObjectClass(new String[] { Throwable.class.getCanonicalName() });
    events.add(e);
    childModules = new ChildModulesElement();
    configuration.setLoadChildConfig(childModules);
    childModules.setErrorEvent("event2");
    configuration.validateEvents();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) ChildModulesElement(com.mvp4g.rebind.config.element.ChildModulesElement) Test(org.junit.Test)

Example 2 with ChildModulesElement

use of com.mvp4g.rebind.config.element.ChildModulesElement in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testUnknownLoadConfigEvent.

@Test
public void testUnknownLoadConfigEvent() throws InvalidMvp4gConfigurationException {
    ChildModulesElement childModules = new ChildModulesElement();
    configuration.setHistory(null);
    configuration.setLoadChildConfig(childModules);
    childModules.setBeforeEvent("unknown");
    try {
        configuration.validateEvents();
        fail();
    } catch (UnknownConfigurationElementException e) {
    // nothing to test
    }
    childModules = new ChildModulesElement();
    configuration.setLoadChildConfig(childModules);
    childModules.setAfterEvent("unknown");
    try {
        configuration.validateEvents();
        fail();
    } catch (UnknownConfigurationElementException e) {
    // nothing to test
    }
    childModules = new ChildModulesElement();
    configuration.setLoadChildConfig(childModules);
    childModules.setErrorEvent("unknown");
    try {
        configuration.validateEvents();
        fail();
    } catch (UnknownConfigurationElementException e) {
    // nothing to test
    }
}
Also used : ChildModulesElement(com.mvp4g.rebind.config.element.ChildModulesElement) UnknownConfigurationElementException(com.mvp4g.rebind.exception.UnknownConfigurationElementException) Test(org.junit.Test)

Example 3 with ChildModulesElement

use of com.mvp4g.rebind.config.element.ChildModulesElement 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());
}
Also used : StartElement(com.mvp4g.rebind.config.element.StartElement) HistoryElement(com.mvp4g.rebind.config.element.HistoryElement) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) GinModuleElement(com.mvp4g.rebind.config.element.GinModuleElement) Mvp4gModule(com.mvp4g.client.Mvp4gModule) ChildModulesElement(com.mvp4g.rebind.config.element.ChildModulesElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) DebugElement(com.mvp4g.rebind.config.element.DebugElement) EventFiltersElement(com.mvp4g.rebind.config.element.EventFiltersElement) Test(org.junit.Test)

Example 4 with ChildModulesElement

use of com.mvp4g.rebind.config.element.ChildModulesElement 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)

Aggregations

ChildModulesElement (com.mvp4g.rebind.config.element.ChildModulesElement)4 Test (org.junit.Test)4 EventElement (com.mvp4g.rebind.config.element.EventElement)2 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)1 Mvp4gModule (com.mvp4g.client.Mvp4gModule)1 DebugElement (com.mvp4g.rebind.config.element.DebugElement)1 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)1 EventFiltersElement (com.mvp4g.rebind.config.element.EventFiltersElement)1 GinModuleElement (com.mvp4g.rebind.config.element.GinModuleElement)1 HistoryElement (com.mvp4g.rebind.config.element.HistoryElement)1 StartElement (com.mvp4g.rebind.config.element.StartElement)1 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)1 UnknownConfigurationElementException (com.mvp4g.rebind.exception.UnknownConfigurationElementException)1 OneObject (com.mvp4g.rebind.test_tools.OneObject)1