use of com.mvp4g.rebind.config.element.ViewElement in project mvp4g by mvp4g.
the class PresenterAnnotationsLoaderTest method testViewWithName.
@Test
public void testViewWithName() throws Mvp4gAnnotationException {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
JClassType type = oracle.addClass(Presenters.PresenterWithViewName.class);
annotedClasses.add(type);
loader.load(annotedClasses, configuration);
ViewElement view = configuration.getViews().iterator().next();
assertEquals(view.getClassName(), Object.class.getName());
assertEquals(view.getName(), "name");
}
use of com.mvp4g.rebind.config.element.ViewElement 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.ViewElement 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.ViewElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method newView.
private ViewElement newView(Class<?> c, String name) {
ViewElement view = new ViewElement();
view.setName(name);
oracle.addClass(c);
view.setClassName(c.getCanonicalName());
return view;
}
use of com.mvp4g.rebind.config.element.ViewElement 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