Search in sources :

Example 6 with PresenterElement

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

the class Mvp4gConfigurationTest method testEventHandlerWrongInterface.

@Test(expected = InvalidClassException.class)
public void testEventHandlerWrongInterface() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleView02.class, "view");
    views.add(view);
    PresenterElement presenter = new PresenterElement();
    presenter.setName("testHandler");
    presenter.setView("view");
    presenter.setClassName(Object.class.getName());
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    configuration.validateEventHandlers();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) OneObject(com.mvp4g.rebind.test_tools.OneObject) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 7 with PresenterElement

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

the class Mvp4gConfigurationTest method testEventHandlerViewMissing.

@Test(expected = UnknownConfigurationElementException.class)
public void testEventHandlerViewMissing() throws InvalidMvp4gConfigurationException {
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    configuration.validateEventHandlers();
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 8 with PresenterElement

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

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

the class Mvp4gConfigurationTest method testViewValidationSucceeds.

@Test
public void testViewValidationSucceeds() throws UnknownConfigurationElementException, InvalidTypeException, InvalidClassException, NotFoundClassException {
    views.add(newView(SimpleView02.class, "testView"));
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "testPresenter");
    presenter.setView("testView");
    presenters.add(presenter);
    configuration.validateViews();
}
Also used : SimpleView02(com.mvp4g.rebind.test_tools.annotation.views.SimpleView02) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 10 with PresenterElement

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

the class Mvp4gConfigurationTest method testPresenterViewValidationFails.

@Test(expected = UnknownConfigurationElementException.class)
public void testPresenterViewValidationFails() throws UnknownConfigurationElementException, InvalidTypeException, InvalidClassException, NotFoundClassException {
    events.add(newEvent("badView"));
    services.add(newService("badView"));
    presenters.add(newPresenter(SimplePresenter01.class, "badView"));
    historyConverters.add(newHistoryConverter(SimpleHistoryConverter01.class, "badView"));
    PresenterElement presenter = newPresenter(SimplePresenter02.class, "testPresenter");
    presenter.setView("badView");
    presenters.add(presenter);
    configuration.validateViews();
}
Also used : SimpleHistoryConverter01(com.mvp4g.rebind.test_tools.annotation.history_converters.SimpleHistoryConverter01) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Aggregations

PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)34 Test (org.junit.Test)32 EventElement (com.mvp4g.rebind.config.element.EventElement)22 ViewElement (com.mvp4g.rebind.config.element.ViewElement)14 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)11 BaseEventBus (com.mvp4g.client.event.BaseEventBus)8 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)8 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)7 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)4 SimpleView02 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView02)4 EventBus (com.mvp4g.client.event.EventBus)3 InjectedElement (com.mvp4g.rebind.config.element.InjectedElement)3 SplitterElement (com.mvp4g.rebind.config.element.SplitterElement)3 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)3 Splitters (com.mvp4g.rebind.test_tools.Splitters)3 Presenters (com.mvp4g.rebind.test_tools.annotation.Presenters)3 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)3 PresenterInterface (com.mvp4g.client.presenter.PresenterInterface)2 EventAssociation (com.mvp4g.rebind.config.element.EventAssociation)2 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)2