Search in sources :

Example 6 with EventBusElement

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

the class Mvp4gConfigurationTest method testSetterAndGetter.

@Test
public void testSetterAndGetter() {
    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(null, null, false);
    configuration.setEventBus(eventBus);
    assertSame(eventBus, configuration.getEventBus());
    assertSame(oracle, configuration.getOracle());
}
Also used : StartElement(com.mvp4g.rebind.config.element.StartElement) HistoryElement(com.mvp4g.rebind.config.element.HistoryElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) Test(org.junit.Test)

Example 7 with EventBusElement

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

the class Mvp4gConfigurationTest method testActivateDeActivateOk.

@Test
public void testActivateDeActivateOk() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event = newEvent("event");
    event.setHandlers(new String[] { "activate1", "deactivate1", "activate2", "deactivate2" });
    events.add(event);
    EventElement event1 = newEvent("event1");
    event1.setActivate(new String[] { "activate1", "activate2" });
    event1.setDeactivate(new String[] { "deactivate1", "deactivate2" });
    events.add(event1);
    PresenterElement activate1 = newPresenter(SimplePresenter01.class, "activate1");
    EventHandlerElement activate2 = newEventHandler(SimpleEventHandler01.class, "activate2");
    PresenterElement deactivate1 = newPresenter(SimplePresenter02.class, "deactivate1");
    EventHandlerElement deactivate2 = newEventHandler(SimpleEventHandler02.class, "deactivate2");
    eventHandlers.add(activate1);
    eventHandlers.add(activate2);
    eventHandlers.add(deactivate1);
    eventHandlers.add(deactivate2);
    configuration.validateEventHandlers();
    List<String> activate = event1.getActivate();
    assertTrue(activate.size() == 2);
    assertEquals(activate.get(0), activate1.getName());
    assertEquals(activate.get(1), activate2.getName());
    List<String> deactivate = event1.getDeactivate();
    assertTrue(deactivate.size() == 2);
    assertEquals(deactivate.get(0), deactivate1.getName());
    assertEquals(deactivate.get(1), deactivate2.getName());
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) 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) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 8 with EventBusElement

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

the class Mvp4gConfigurationTest method testChildModuleLoadersIncompatibleType.

@Test
public void testChildModuleLoadersIncompatibleType() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    oracle.addClass(Loaders.Loader1.class);
    oracle.addClass(Modules.ModuleWithLoader.class);
    ChildModuleElement withLoader = new ChildModuleElement();
    withLoader.setName("withLoader");
    withLoader.setClassName(Modules.ModuleWithLoader.class.getCanonicalName());
    childModules.add(withLoader);
    try {
        configuration.findChildModuleHistoryNameAndLoader();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
    }
}
Also used : Modules(com.mvp4g.rebind.test_tools.Modules) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) Loaders(com.mvp4g.rebind.test_tools.Loaders) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 9 with EventBusElement

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

the class Mvp4gConfigurationTest method testRootModuleWithHistoryName.

@Test
public void testRootModuleWithHistoryName() {
    configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
    EventBusElement eventBus = new EventBusElement(EventBusOk.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    assertTrue(configuration.isRootModule());
    try {
        configuration.loadParentModule();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals("Module " + Modules.ModuleWithParent01.class.getCanonicalName() + " can't have an history name since it's a root module.", e.getMessage());
    }
}
Also used : InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Modules(com.mvp4g.rebind.test_tools.Modules) EventBusOk(com.mvp4g.rebind.test_tools.annotation.events.EventBusOk) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) Test(org.junit.Test)

Example 10 with EventBusElement

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

the class Mvp4gConfigurationTest method testEventFiltersOk.

@Test
public void testEventFiltersOk() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    configuration.validateEventFilters();
    eventFilters.add(newEventFilter(EventFilters.EventFilter1.class, "filter"));
    configuration.validateEventFilters();
}
Also used : EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) EventBusWithLookup(com.mvp4g.client.event.EventBusWithLookup) BaseEventBus(com.mvp4g.client.event.BaseEventBus) Test(org.junit.Test)

Aggregations

EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)21 Test (org.junit.Test)20 BaseEventBus (com.mvp4g.client.event.BaseEventBus)19 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)11 EventElement (com.mvp4g.rebind.config.element.EventElement)11 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)8 EventBus (com.mvp4g.client.event.EventBus)7 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)7 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)5 ViewElement (com.mvp4g.rebind.config.element.ViewElement)3 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)3 Modules (com.mvp4g.rebind.test_tools.Modules)3 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)2 EventFilterElement (com.mvp4g.rebind.config.element.EventFilterElement)2 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)2 HistoryElement (com.mvp4g.rebind.config.element.HistoryElement)2 StartElement (com.mvp4g.rebind.config.element.StartElement)2 InvalidClassException (com.mvp4g.rebind.exception.InvalidClassException)2 Loaders (com.mvp4g.rebind.test_tools.Loaders)2 OneObject (com.mvp4g.rebind.test_tools.OneObject)2