Search in sources :

Example 16 with InvalidMvp4gConfigurationException

use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testSameActivateDeactivate.

@Test
public void testSameActivateDeactivate() {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event1 = newEvent("event1");
    event1.setActivate(new String[] { "activate" });
    event1.setDeactivate(new String[] { "activate" });
    events.add(event1);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("an event can't activate and deactivate the same handler: activate."));
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) EventBusWithLookup(com.mvp4g.client.event.EventBusWithLookup) BaseEventBus(com.mvp4g.client.event.BaseEventBus) Test(org.junit.Test)

Example 17 with InvalidMvp4gConfigurationException

use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testValidateSplitterStartPresenter.

@Test
public void testValidateSplitterStartPresenter() {
    setEventBus();
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "presenter");
    configuration.getStart().setPresenter("presenter");
    presenter.setAsync("true");
    presenters.add(presenter);
    EventElement event = new EventElement();
    event.setType("event");
    event.setHandlers(new String[] { "presenter" });
    events.add(event);
    try {
        configuration.validateSplitters();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Presenter presenter: start presenter can't be loaded asynchronously. Async attribute must not be set.", e.getMessage());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 18 with InvalidMvp4gConfigurationException

use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testHistoryNameNoConveter.

@Test
public void testHistoryNameNoConveter() {
    EventElement e = newEvent("start");
    e.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
    e.setName("name");
    events.add(e);
    try {
        configuration.validateHistoryConverters();
        fail();
    } catch (InvalidMvp4gConfigurationException ex) {
        assertEquals("Event start: you defined an history name for this event but this event has no history converter.", 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 19 with InvalidMvp4gConfigurationException

use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testFindChildModuleSameHistory.

@Test(expected = InvalidMvp4gConfigurationException.class)
public void testFindChildModuleSameHistory() throws InvalidMvp4gConfigurationException {
    setEventBus();
    ChildModuleElement childModule1 = newChildModule(Modules.ModuleWithParent01.class, "child1");
    childModules.add(childModule1);
    ChildModuleElement childModule2 = new ChildModuleElement();
    childModule2.setName("child2");
    childModule2.setClassName(Modules.ModuleWithParent01.class.getCanonicalName());
    childModules.add(childModule2);
    JClassType module = oracle.findType(Mvp4gModule.class.getCanonicalName());
    configuration.setModule(module);
    try {
        configuration.findChildModuleHistoryNameAndLoader();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        String.format("Module %s: You can't have two child modules with the same history name \"%s\".", module.getQualifiedSourceName(), "moduleWithParent");
        throw e;
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Mvp4gModule(com.mvp4g.client.Mvp4gModule) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) Test(org.junit.Test)

Example 20 with InvalidMvp4gConfigurationException

use of com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testChildModulesNoStart.

@Test(expected = InvalidMvp4gConfigurationException.class)
public void testChildModulesNoStart() throws InvalidMvp4gConfigurationException {
    ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
    childModule1.setEventToDisplayView("testEvent");
    childModules.add(childModule1);
    configuration.getOthersEventBusClassMap().put(Modules.ChildModule01.class.getCanonicalName(), oracle.addClass(EventBusWithNoStartPresenter.class));
    EventElement event = newEvent("testEvent");
    event.setForwardToModules(new String[] { "child1" });
    event.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
    events.add(event);
    try {
        configuration.validateChildModules();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Module com.mvp4g.rebind.test_tools.Modules.ChildModule01: You must define a start presenter since this module has a parent module that uses the auto-displayed feature for this module.", e.getMessage());
        throw e;
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Modules(com.mvp4g.rebind.test_tools.Modules) OneObject(com.mvp4g.rebind.test_tools.OneObject) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) EventBusWithNoStartPresenter(com.mvp4g.rebind.test_tools.annotation.Events.EventBusWithNoStartPresenter) 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