Search in sources :

Example 11 with EventHandlerElement

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

the class Mvp4gConfigurationTest method testWrongEventHandlerClass.

@Test
public void testWrongEventHandlerClass() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event = newEvent("event");
    event.setHandlers(new String[] { "test" });
    events.add(event);
    EventHandlerElement handler = new EventHandlerElement();
    handler.setClassName(Object.class.getCanonicalName());
    handler.setName("test");
    eventHandlers.add(handler);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
    handler.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
    PresenterElement presenter = new PresenterElement();
    Class<?> c = SimpleEventHandler01.class;
    oracle.addClass(c);
    presenter.setClassName(c.getCanonicalName());
    presenter.setName("test");
    presenters.add(presenter);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
    presenter.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) SimpleEventHandler01(com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01) 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) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) OneObject(com.mvp4g.rebind.test_tools.OneObject) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 12 with EventHandlerElement

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

the class Mvp4gConfigurationTest method testActivateDeActivateUseless.

@Test
public void testActivateDeActivateUseless() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    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() == 0);
    List<String> deactivate = event1.getDeactivate();
    assertTrue(deactivate.size() == 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) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Aggregations

EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)12 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)11 Test (org.junit.Test)11 EventElement (com.mvp4g.rebind.config.element.EventElement)10 BaseEventBus (com.mvp4g.client.event.BaseEventBus)7 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)7 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)6 ViewElement (com.mvp4g.rebind.config.element.ViewElement)4 EventAssociation (com.mvp4g.rebind.config.element.EventAssociation)2 SplitterElement (com.mvp4g.rebind.config.element.SplitterElement)2 SingleSplitter (com.mvp4g.client.SingleSplitter)1 EventBus (com.mvp4g.client.event.EventBus)1 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)1 InjectedElement (com.mvp4g.rebind.config.element.InjectedElement)1 ServiceElement (com.mvp4g.rebind.config.element.ServiceElement)1 InvalidClassException (com.mvp4g.rebind.exception.InvalidClassException)1 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)1 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)1 OneObject (com.mvp4g.rebind.test_tools.OneObject)1 Splitters (com.mvp4g.rebind.test_tools.Splitters)1