Search in sources :

Example 6 with InvalidMvp4gConfigurationException

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

the class Mvp4gConfigurationTest method testAutoDisplay.

@Test
public void testAutoDisplay() throws InvalidMvp4gConfigurationException {
    ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
    childModules.add(childModule1);
    assertTrue(childModule1.isAutoDisplay());
    EventElement event = newEvent("testEvent");
    event.setForwardToModules(new String[] { "child1" });
    event.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
    events.add(event);
    setEventBus();
    configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
    try {
        configuration.validateChildModules();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals(e.getMessage(), String.format("%s: child module %s doesn't define any event to load its view.", Modules.ModuleWithParent01.class.getCanonicalName(), childModule1.getClassName()));
    }
    childModule1.setAutoDisplay("false");
    configuration.validateChildModules();
}
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) Test(org.junit.Test)

Example 7 with InvalidMvp4gConfigurationException

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

the class Mvp4gConfigurationTest method validateHistoryName.

@Test
public void validateHistoryName() throws InvalidMvp4gConfigurationException {
    EventElement element = newEvent("forward");
    try {
        configuration.validateHistoryName("!test", element);
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("history name can't start with '" + PlaceService.CRAWLABLE + "' or contain '" + PlaceService.MODULE_SEPARATOR + "'."));
    }
    try {
        configuration.validateHistoryName("/test", element);
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("history name can't start with '" + PlaceService.CRAWLABLE + "' or contain '" + PlaceService.MODULE_SEPARATOR + "'."));
    }
    try {
        configuration.validateHistoryName("te/st", element);
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("history name can't start with '" + PlaceService.CRAWLABLE + "' or contain '" + PlaceService.MODULE_SEPARATOR + "'."));
    }
    configuration.validateHistoryName("test", element);
    configuration.validateHistoryName("tes!t", element);
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Test(org.junit.Test)

Example 8 with InvalidMvp4gConfigurationException

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

the class Mvp4gConfigurationTest method testEventWithNoObjectForAutoDisplay.

@Test(expected = InvalidMvp4gConfigurationException.class)
public void testEventWithNoObjectForAutoDisplay() throws InvalidMvp4gConfigurationException {
    ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
    childModule1.setEventToDisplayView("testEvent");
    childModules.add(childModule1);
    EventElement event = newEvent("testEvent");
    event.setForwardToModules(new String[] { "child1" });
    events.add(event);
    setEventBus();
    try {
        configuration.validateChildModules();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Event testEvent: event must have one and only one an object associated with it as it loads a child view.", 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) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) Test(org.junit.Test)

Example 9 with InvalidMvp4gConfigurationException

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

the class Mvp4gConfigurationTest method testForwardEventRootModule.

@Test
public void testForwardEventRootModule() throws InvalidMvp4gConfigurationException {
    StartElement start = configuration.getStart();
    start.setForwardEventType("forward");
    try {
        configuration.validateEvents();
        fail();
    } catch (InvalidMvp4gConfigurationException ex) {
        assertEquals("You can't define a forward event for RootModule since no event from parent can be forwarded to it.", ex.getMessage());
    }
}
Also used : StartElement(com.mvp4g.rebind.config.element.StartElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Test(org.junit.Test)

Example 10 with InvalidMvp4gConfigurationException

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

the class Mvp4gConfigurationTest method testTokenGenerationNotOk.

@Test
public void testTokenGenerationNotOk() {
    EventElement event = new EventElement();
    event.setWithTokenGeneration("true");
    event.setType("event1");
    events.add(event);
    try {
        configuration.validateHistoryConverters();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Event event1: you can't generate a token for this event if it has no history converter.", e.getMessage());
    }
    configuration.setModule(oracle.addClass(Modules.Module01.class));
    try {
        configuration.validateHistoryConverters();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Event event1: you can't generate a token for this event if it has no history converter.", e.getMessage());
    }
    configuration.setParentEventBus(oracle.addClass(EventBusOk.class));
    try {
        configuration.validateHistoryConverters();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Event event1: you can't generate a token for this event if it has no history converter.", e.getMessage());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) EventBusOk(com.mvp4g.rebind.test_tools.annotation.events.EventBusOk) 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