use of com.mvp4g.rebind.exception.InvalidTypeException 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.exception.InvalidTypeException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventFiltersWrongEventBus.
@Test
public void testEventFiltersWrongEventBus() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventFilterElement filter = new EventFilterElement();
oracle.addClass(EventFilters.EventFilter3.class);
filter.setClassName(EventFilters.EventFilter3.class.getCanonicalName());
eventFilters.add(filter);
try {
configuration.validateEventFilters();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
}
}
use of com.mvp4g.rebind.exception.InvalidTypeException 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.exception.InvalidTypeException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGin01.
@Test
public void testGin01() throws InvalidMvp4gConfigurationException {
GinModuleElement gin = new GinModuleElement();
configuration.setGinModule(gin);
try {
configuration.validateGinModule();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals(e.getMessage(), "You need to define at least one GIN module. If you don't want to specify a GIN module, don't override the GIN modules option to use the default Mvp4g GIN module.");
}
gin = new GinModuleElement();
oracle.addClass(OneObject.class);
gin.setModules(new String[] { OneObject.class.getCanonicalName() });
configuration.setGinModule(gin);
try {
configuration.validateGinModule();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains(GinModule.class.getCanonicalName()));
}
String[] propertiesValues;
gin = new GinModuleElement();
oracle.addClass(DefaultMvp4gGinModule.class);
gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
configuration.setGinModule(gin);
propertiesValues = configuration.validateGinModule();
assertNull(propertiesValues);
assertEquals(gin.getModules().size(), 1);
}
use of com.mvp4g.rebind.exception.InvalidTypeException in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testDebug.
@Test
public void testDebug() throws NotFoundClassException, InvalidTypeException {
DebugElement debug = new DebugElement();
oracle.addClass(OneObject.class);
debug.setLogger(OneObject.class.getCanonicalName());
configuration.setDebug(debug);
try {
configuration.validateDebug();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains(Mvp4gLogger.class.getCanonicalName()));
}
debug = new DebugElement();
oracle.addClass(DefaultMvp4gLogger.class);
debug.setLogger(DefaultMvp4gLogger.class.getCanonicalName());
configuration.setDebug(debug);
configuration.validateDebug();
configuration.setDebug(null);
configuration.validateDebug();
}
Aggregations