Search in sources :

Example 1 with PresenterElement

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

the class TestExceptions method testInvalidClassException.

@Test
public void testInvalidClassException() {
    PresenterElement p = new PresenterElement();
    p.setName("name");
    p.setClassName("com.test.Presenter");
    InvalidClassException e = new InvalidClassException(p, PresenterInterface.class.getName());
    assertEquals("presenter name: This class must extend " + PresenterInterface.class.getName(), e.getMessage());
}
Also used : PresenterInterface(com.mvp4g.client.presenter.PresenterInterface) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 2 with PresenterElement

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

the class TestExceptions method testUnknownConfigurationElementException.

@Test
public void testUnknownConfigurationElementException() {
    PresenterElement p = new PresenterElement();
    p.setName("name");
    p.setClassName("com.test.Presenter");
    UnknownConfigurationElementException e = new UnknownConfigurationElementException(p, "test");
    assertEquals("presenter name: Encountered a reference to unknown element 'test'", e.getMessage());
}
Also used : PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 3 with PresenterElement

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

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

the class Mvp4gConfigurationTest method testEventHandlerWrongInjectedView.

@Test
public void testEventHandlerWrongInjectedView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleInjectedView.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(Presenters.MultiplePresenter.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertEquals("view view: Invalid Presenter. Can not convert com.mvp4g.rebind.test_tools.annotation.Presenters.MultiplePresenter to com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01", e.getMessage());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) 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 5 with PresenterElement

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

the class Mvp4gConfigurationTest method testEventHandlerValidationSucceedsWithInjectedView.

@Test
public void testEventHandlerValidationSucceedsWithInjectedView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleInjectedView.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);
    setEventBus();
    configuration.validateEventHandlers();
    assertTrue(presenter.hasInverseView());
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) 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