use of com.mvp4g.rebind.config.element.EventBusElement 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.EventBusElement 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.config.element.EventBusElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventFiltersWrongClass.
@Test
public void testEventFiltersWrongClass() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventFilterElement filter = new EventFilterElement();
filter.setClassName(Object.class.getName());
eventFilters.add(filter);
try {
configuration.validateEventFilters();
fail();
} catch (InvalidClassException e) {
assertTrue(e.getMessage().contains("This class must extend " + EventFilter.class.getCanonicalName()));
}
}
use of com.mvp4g.rebind.config.element.EventBusElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGenerateNotMultiple.
@Test
public void testGenerateNotMultiple() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event1 = newEvent("event1");
event1.setHandlers(new String[] { "generate2" });
event1.setGenerate(new String[] { "generate1", "generate2" });
events.add(event1);
ViewElement view = newView(SimpleView02.class, "view");
view.setClassName(SimpleView02.class.getCanonicalName());
views.add(view);
PresenterElement generate1 = newPresenter(SimplePresenter01.class, "generate1");
generate1.setView("view");
EventHandlerElement generate2 = newEventHandler(SimpleEventHandler01.class, "generate2");
presenters.add(generate1);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Event event1: you can generate only multiple handlers. Did you forget to set the attribute multiple to true for generate1?"));
}
presenters.clear();
eventHandlers.clear();
eventHandlers.add(generate2);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("Event event1: you can generate only multiple handlers. Did you forget to set the attribute multiple to true for generate2?"));
}
}
use of com.mvp4g.rebind.config.element.EventBusElement 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());
}
Aggregations