Search in sources :

Example 1 with EventElement

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

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

the class Mvp4gConfigurationTest method testEventHandlerValidationInvalidEventBus.

@Test
public void testEventHandlerValidationInvalidEventBus() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleView02.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    presenter.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    events.clear();
    configuration.validateEventHandlers();
    assertTrue(presenters.size() == 0);
    EventHandlerElement eventHandler = newEventHandler(SimpleEventHandler01.class, "testHandler");
    eventHandlers.add(eventHandler);
    events.add(event);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    eventHandler.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    events.clear();
    configuration.validateEventHandlers();
    assertTrue(eventHandlers.size() == 0);
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 3 with EventElement

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

the class Mvp4gConfigurationTest method testEventHandlerWrongInjectedView.

@Test
public void testEventHandlerWrongInjectedView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleInjectedView.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(Presenters.MultiplePresenter.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertEquals("view view: Invalid Presenter. Can not convert com.mvp4g.rebind.test_tools.annotation.Presenters.MultiplePresenter to com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01", e.getMessage());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 4 with EventElement

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

the class Mvp4gConfigurationTest method testChildModulesRemove.

@Test
public void testChildModulesRemove() throws InvalidMvp4gConfigurationException {
    ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
    childModule1.setEventToDisplayView("testEvent");
    childModules.add(childModule1);
    configuration.getOthersEventBusClassMap().put(Modules.ChildModule01.class.getCanonicalName(), oracle.addClass(EventBusOk.class));
    ChildModuleElement childModule2 = newChildModule(Modules.ChildModule02.class, "child2");
    childModules.add(childModule2);
    EventElement event = newEvent("testEvent");
    event.setForwardToModules(new String[] { "child1" });
    event.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
    events.add(event);
    builder.expectWarn("Module Mvp4gModule: the child module child2 is not loaded by any of the event of this module. You should remove it if it is not used by another child module (ie used for sibling communication).", null);
    logger = builder.createLogger();
    configuration.setLogger(logger);
    setEventBus();
    assertEquals(2, childModules.size());
    assertTrue(childModules.contains(childModule1));
    assertTrue(childModules.contains(childModule2));
    configuration.validateChildModules();
    assertEquals(2, childModules.size());
    assertTrue(childModules.contains(childModule1));
    assertTrue(childModules.contains(childModule2));
    logger.assertCorrectLogEntries();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) Modules(com.mvp4g.rebind.test_tools.Modules) EventBusOk(com.mvp4g.rebind.test_tools.annotation.events.EventBusOk) OneObject(com.mvp4g.rebind.test_tools.OneObject) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) Test(org.junit.Test)

Example 5 with EventElement

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

the class Mvp4gConfigurationTest method testEventHandlerValidationSucceedsWithInjectedView.

@Test
public void testEventHandlerValidationSucceedsWithInjectedView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleInjectedView.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    configuration.validateEventHandlers();
    assertTrue(presenter.hasInverseView());
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Aggregations

EventElement (com.mvp4g.rebind.config.element.EventElement)56 Test (org.junit.Test)55 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)22 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)18 OneObject (com.mvp4g.rebind.test_tools.OneObject)15 ChildModuleElement (com.mvp4g.rebind.config.element.ChildModuleElement)12 ViewElement (com.mvp4g.rebind.config.element.ViewElement)12 Modules (com.mvp4g.rebind.test_tools.Modules)12 BaseEventBus (com.mvp4g.client.event.BaseEventBus)11 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)11 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)10 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)8 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)6 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)5 TestBroadcast (com.mvp4g.rebind.test_tools.annotation.TestBroadcast)5 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)4 TestBroadcast2 (com.mvp4g.rebind.test_tools.annotation.TestBroadcast2)4 EventBusOk (com.mvp4g.rebind.test_tools.annotation.events.EventBusOk)4 SimpleView02 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView02)4 EventBus (com.mvp4g.client.event.EventBus)3