Search in sources :

Example 11 with EventBusElement

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

Example 12 with EventBusElement

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

the class Mvp4gConfigurationTest method testSameActivateDeactivate.

@Test
public void testSameActivateDeactivate() {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event1 = newEvent("event1");
    event1.setActivate(new String[] { "activate" });
    event1.setDeactivate(new String[] { "activate" });
    events.add(event1);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("an event can't activate and deactivate the same handler: activate."));
    }
}
Also used : 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) Test(org.junit.Test)

Example 13 with EventBusElement

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

the class Mvp4gConfigurationTest method testSetterGetter.

@Test
public void testSetterGetter() {
    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("", "", false);
    configuration.setEventBus(eventBus);
    assertSame(eventBus, configuration.getEventBus());
    JClassType module = oracle.findType(Mvp4gModule.class.getCanonicalName());
    configuration.setModule(module);
    assertSame(module, configuration.getModule());
    JClassType parentEventBus = oracle.addClass(EventBus.class);
    configuration.setParentEventBus(parentEventBus);
    assertSame(parentEventBus, configuration.getParentEventBus());
    String historyName = "historyName";
    configuration.setHistoryName("historyName");
    assertSame(historyName, configuration.getHistoryName());
    ChildModulesElement childConfig = new ChildModulesElement();
    configuration.setLoadChildConfig(childConfig);
    assertSame(childConfig, configuration.getLoadChildConfig());
    DebugElement debug = new DebugElement();
    configuration.setDebug(debug);
    assertSame(debug, configuration.getDebug());
    GinModuleElement gin = new GinModuleElement();
    configuration.setGinModule(gin);
    assertSame(gin, configuration.getGinModule());
    EventFiltersElement filters = new EventFiltersElement();
    configuration.setEventFilterConfiguration(filters);
    assertSame(filters, configuration.getEventFilterConfiguration());
}
Also used : StartElement(com.mvp4g.rebind.config.element.StartElement) HistoryElement(com.mvp4g.rebind.config.element.HistoryElement) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) GinModuleElement(com.mvp4g.rebind.config.element.GinModuleElement) Mvp4gModule(com.mvp4g.client.Mvp4gModule) ChildModulesElement(com.mvp4g.rebind.config.element.ChildModulesElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) DebugElement(com.mvp4g.rebind.config.element.DebugElement) EventFiltersElement(com.mvp4g.rebind.config.element.EventFiltersElement) Test(org.junit.Test)

Example 14 with EventBusElement

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

the class Mvp4gConfigurationTest method testGenerate.

@Test
public void testGenerate() 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(SimpleView01.class, "view");
    views.add(view);
    PresenterElement generate1 = newPresenter(SimplePresenter01.class, "generate1");
    generate1.setView("view");
    EventHandlerElement generate2 = newEventHandler(SimpleEventHandler01.class, "generate2");
    presenters.add(generate1);
    eventHandlers.add(generate2);
    generate1.setMultiple(Boolean.TRUE.toString());
    generate2.setMultiple(Boolean.TRUE.toString());
    configuration.validateEventHandlers();
    List<String> generate = event1.getGenerate();
    assertEquals(2, generate.size());
    assertEquals(generate.get(0), generate1.getName());
    assertEquals(generate.get(1), generate2.getName());
    List<String> handlers = event1.getHandlers();
    assertEquals(1, handlers.size());
    assertEquals(generate2.getName(), handlers.get(0));
}
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) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 15 with EventBusElement

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

the class Mvp4gConfigurationTest method testUnknownActivateDeactivate.

@Test
public void testUnknownActivateDeactivate() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event1 = newEvent("event1");
    event1.setActivate(new String[] { "activate" });
    events.add(event1);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (UnknownConfigurationElementException e) {
        assertTrue(e.getMessage().contains("Encountered a reference to unknown element 'activate'"));
    }
    events.clear();
    EventElement event2 = newEvent("event2");
    event2.setDeactivate(new String[] { "deactivate" });
    events.add(event2);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (UnknownConfigurationElementException e) {
        assertTrue(e.getMessage().contains("Encountered a reference to unknown element 'deactivate'"));
    }
}
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) UnknownConfigurationElementException(com.mvp4g.rebind.exception.UnknownConfigurationElementException) 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