use of com.mvp4g.client.event.EventBus 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.client.event.EventBus 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.client.event.EventBus in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testParentEventBus.
@Test
public void testParentEventBus() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusOk.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
configuration.loadParentModule();
assertNull(configuration.getParentEventBus());
assertTrue(configuration.isRootModule());
configuration.setModule(oracle.addClass(Modules.Module01.class));
setParentEventBus(Modules.Module01.class, EventBus.class);
JClassType c = oracle.findType(EventBus.class.getCanonicalName());
configuration.loadParentModule();
assertEquals(c.getQualifiedSourceName(), configuration.getParentEventBus().getQualifiedSourceName());
assertFalse(configuration.isRootModule());
}
use of com.mvp4g.client.event.EventBus in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testChildModuleLoadersIncompatibleType.
@Test
public void testChildModuleLoadersIncompatibleType() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
oracle.addClass(Loaders.Loader1.class);
oracle.addClass(Modules.ModuleWithLoader.class);
ChildModuleElement withLoader = new ChildModuleElement();
withLoader.setName("withLoader");
withLoader.setClassName(Modules.ModuleWithLoader.class.getCanonicalName());
childModules.add(withLoader);
try {
configuration.findChildModuleHistoryNameAndLoader();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
}
}
use of com.mvp4g.client.event.EventBus in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHistoryConverterWrongEventBus.
@Test(expected = InvalidTypeException.class)
public void testEventHistoryConverterWrongEventBus() throws InvalidMvp4gConfigurationException {
try {
HistoryConverterElement hc = new HistoryConverterElement();
hc.setName("testHistoryConverter");
Class<?> c = HistoryConverters.HistoryConverterWithLookup.class;
oracle.addClass(c);
hc.setClassName(c.getCanonicalName());
historyConverters.add(hc);
EventElement event = newEvent("testEvent");
event.setHistory("testHistoryConverter");
events.add(event);
EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
configuration.validateHistoryConverters();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("Event Bus"));
throw e;
}
}
Aggregations