Search in sources :

Example 1 with EventBus

use of com.mvp4g.client.event.EventBus 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 2 with EventBus

use of com.mvp4g.client.event.EventBus in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testEventFiltersWrongEventBus.

@Test
public void testEventFiltersWrongEventBus() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventFilterElement filter = new EventFilterElement();
    oracle.addClass(EventFilters.EventFilter3.class);
    filter.setClassName(EventFilters.EventFilter3.class.getCanonicalName());
    eventFilters.add(filter);
    try {
        configuration.validateEventFilters();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
    }
}
Also used : EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventFilterElement(com.mvp4g.rebind.config.element.EventFilterElement) EventFilters(com.mvp4g.rebind.test_tools.annotation.EventFilters) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 3 with EventBus

use of com.mvp4g.client.event.EventBus in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testParentEventBus.

@Test
public void testParentEventBus() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusOk.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    configuration.loadParentModule();
    assertNull(configuration.getParentEventBus());
    assertTrue(configuration.isRootModule());
    configuration.setModule(oracle.addClass(Modules.Module01.class));
    setParentEventBus(Modules.Module01.class, EventBus.class);
    JClassType c = oracle.findType(EventBus.class.getCanonicalName());
    configuration.loadParentModule();
    assertEquals(c.getQualifiedSourceName(), configuration.getParentEventBus().getQualifiedSourceName());
    assertFalse(configuration.isRootModule());
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) 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) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) Test(org.junit.Test)

Example 4 with EventBus

use of com.mvp4g.client.event.EventBus 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 5 with EventBus

use of com.mvp4g.client.event.EventBus in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testEventHistoryConverterWrongEventBus.

@Test(expected = InvalidTypeException.class)
public void testEventHistoryConverterWrongEventBus() throws InvalidMvp4gConfigurationException {
    try {
        HistoryConverterElement hc = new HistoryConverterElement();
        hc.setName("testHistoryConverter");
        Class<?> c = HistoryConverters.HistoryConverterWithLookup.class;
        oracle.addClass(c);
        hc.setClassName(c.getCanonicalName());
        historyConverters.add(hc);
        EventElement event = newEvent("testEvent");
        event.setHistory("testHistoryConverter");
        events.add(event);
        EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
        configuration.setEventBus(eventBus);
        configuration.validateHistoryConverters();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
        throw e;
    }
}
Also used : HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) EventElement(com.mvp4g.rebind.config.element.EventElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Aggregations

BaseEventBus (com.mvp4g.client.event.BaseEventBus)7 EventBus (com.mvp4g.client.event.EventBus)7 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)7 Test (org.junit.Test)7 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)5 EventElement (com.mvp4g.rebind.config.element.EventElement)3 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)2 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)2 Loaders (com.mvp4g.rebind.test_tools.Loaders)2 Modules (com.mvp4g.rebind.test_tools.Modules)2 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)1 ClearHistory (com.mvp4g.client.history.ClearHistory)1 ChildModuleElement (com.mvp4g.rebind.config.element.ChildModuleElement)1 EventFilterElement (com.mvp4g.rebind.config.element.EventFilterElement)1 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)1 ViewElement (com.mvp4g.rebind.config.element.ViewElement)1 Splitters (com.mvp4g.rebind.test_tools.Splitters)1 EventFilters (com.mvp4g.rebind.test_tools.annotation.EventFilters)1 EventBusOk (com.mvp4g.rebind.test_tools.annotation.events.EventBusOk)1