Search in sources :

Example 1 with InvalidClassException

use of com.mvp4g.rebind.exception.InvalidClassException 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 2 with InvalidClassException

use of com.mvp4g.rebind.exception.InvalidClassException 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)

Aggregations

BaseEventBus (com.mvp4g.client.event.BaseEventBus)2 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)2 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)2 InvalidClassException (com.mvp4g.rebind.exception.InvalidClassException)2 OneObject (com.mvp4g.rebind.test_tools.OneObject)2 Test (org.junit.Test)2 EventElement (com.mvp4g.rebind.config.element.EventElement)1 EventFilterElement (com.mvp4g.rebind.config.element.EventFilterElement)1 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)1 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)1 SimpleEventHandler01 (com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01)1