Search in sources :

Example 6 with EventElement

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

the class Mvp4gConfigurationTest method testForwardParentModule.

@Test
public void testForwardParentModule() throws InvalidMvp4gConfigurationException {
    String parentModule = oracle.addClass(Modules.Module01.class).getQualifiedSourceName();
    EventElement event = newEvent("testEvent");
    event.setForwardToModules(new String[] { parentModule });
    event.setEventObjectClass(new String[] { String.class.getCanonicalName() });
    events.add(event);
    Map<String, ChildModuleElement> childModuleMap = configuration.getModuleParentEventBusClassMap();
    JClassType parentEventBus = oracle.addClass(EventBusOk.class);
    configuration.setParentEventBus(parentEventBus);
    String currentModule = oracle.addClass(Modules.ModuleWithParent01.class).getQualifiedSourceName();
    ChildModuleElement module = new ChildModuleElement();
    module.setParentEventBus(parentEventBus);
    module.setParentModuleClass(parentModule);
    module.setClassName(currentModule);
    childModuleMap.put(currentModule, module);
    setEventBus();
    configuration.setModule(oracle.findType(Modules.ModuleWithParent01.class.getCanonicalName()));
    List<ChildModuleElement> siblings = configuration.getSiblings();
    assertEquals(0, siblings.size());
    assertFalse(event.hasForwardToParent());
    configuration.validateChildModules();
    assertTrue(event.hasForwardToParent());
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) EventElement(com.mvp4g.rebind.config.element.EventElement) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) Test(org.junit.Test)

Example 7 with EventElement

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

the class Mvp4gConfigurationTest method testEventHandlerWrongInterface.

@Test(expected = InvalidClassException.class)
public void testEventHandlerWrongInterface() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleView02.class, "view");
    views.add(view);
    PresenterElement presenter = new PresenterElement();
    presenter.setName("testHandler");
    presenter.setView("view");
    presenter.setClassName(Object.class.getName());
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    configuration.validateEventHandlers();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) OneObject(com.mvp4g.rebind.test_tools.OneObject) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 8 with EventElement

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

the class Mvp4gConfigurationTest method testEventWithParent.

@Test
public void testEventWithParent() throws InvalidMvp4gConfigurationException {
    EventElement e = newEvent("event");
    e.setForwardToParent("true");
    events.add(e);
    try {
        configuration.validateEvents();
        fail();
    } catch (InvalidMvp4gConfigurationException ex) {
        assertEquals("Event event: Root module has no parent so you can't forward event to parent.", ex.getMessage());
    }
    configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
    setParentEventBus(Modules.ModuleWithParent01.class, EventBusOk.class);
    configuration.loadParentModule();
    configuration.validateEvents();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Modules(com.mvp4g.rebind.test_tools.Modules) Test(org.junit.Test)

Example 9 with EventElement

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

the class Mvp4gConfigurationTest method testEventHandlerViewMissing.

@Test(expected = UnknownConfigurationElementException.class)
public void testEventHandlerViewMissing() throws InvalidMvp4gConfigurationException {
    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();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 10 with EventElement

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

the class Mvp4gConfigurationTest method testGenerateNotMultiple.

@Test
public void testGenerateNotMultiple() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event1 = newEvent("event1");
    event1.setHandlers(new String[] { "generate2" });
    event1.setGenerate(new String[] { "generate1", "generate2" });
    events.add(event1);
    ViewElement view = newView(SimpleView02.class, "view");
    view.setClassName(SimpleView02.class.getCanonicalName());
    views.add(view);
    PresenterElement generate1 = newPresenter(SimplePresenter01.class, "generate1");
    generate1.setView("view");
    EventHandlerElement generate2 = newEventHandler(SimpleEventHandler01.class, "generate2");
    presenters.add(generate1);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("Event event1: you can generate only multiple handlers. Did you forget to set the attribute multiple to true for generate1?"));
    }
    presenters.clear();
    eventHandlers.clear();
    eventHandlers.add(generate2);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("Event event1: you can generate only multiple handlers. Did you forget to set the attribute multiple to true for generate2?"));
    }
}
Also used : SimpleView02(com.mvp4g.rebind.test_tools.annotation.views.SimpleView02) 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) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) 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