Search in sources :

Example 1 with EventBusElement

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

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

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

the class Mvp4gConfigurationTest method testEventFiltersWrongClass.

@Test
public void testEventFiltersWrongClass() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventFilterElement filter = new EventFilterElement();
    filter.setClassName(Object.class.getName());
    eventFilters.add(filter);
    try {
        configuration.validateEventFilters();
        fail();
    } catch (InvalidClassException e) {
        assertTrue(e.getMessage().contains("This class must extend " + EventFilter.class.getCanonicalName()));
    }
}
Also used : InvalidClassException(com.mvp4g.rebind.exception.InvalidClassException) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) EventBusWithLookup(com.mvp4g.client.event.EventBusWithLookup) BaseEventBus(com.mvp4g.client.event.BaseEventBus) OneObject(com.mvp4g.rebind.test_tools.OneObject) EventFilterElement(com.mvp4g.rebind.config.element.EventFilterElement) Test(org.junit.Test)

Example 4 with EventBusElement

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

Example 5 with EventBusElement

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

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