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());
}
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());
}
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);
}
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());
}
}
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());
}
Aggregations