use of com.mvp4g.rebind.config.element.EventBusElement 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;
}
}
use of com.mvp4g.rebind.config.element.EventBusElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSameActivateDeactivate.
@Test
public void testSameActivateDeactivate() {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event1 = newEvent("event1");
event1.setActivate(new String[] { "activate" });
event1.setDeactivate(new String[] { "activate" });
events.add(event1);
try {
configuration.validateEventHandlers();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("an event can't activate and deactivate the same handler: activate."));
}
}
use of com.mvp4g.rebind.config.element.EventBusElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSetterGetter.
@Test
public void testSetterGetter() {
StartElement start = new StartElement();
configuration.setStart(start);
assertSame(start, configuration.getStart());
HistoryElement history = new HistoryElement();
configuration.setHistory(history);
assertSame(history, configuration.getHistory());
EventBusElement eventBus = new EventBusElement("", "", false);
configuration.setEventBus(eventBus);
assertSame(eventBus, configuration.getEventBus());
JClassType module = oracle.findType(Mvp4gModule.class.getCanonicalName());
configuration.setModule(module);
assertSame(module, configuration.getModule());
JClassType parentEventBus = oracle.addClass(EventBus.class);
configuration.setParentEventBus(parentEventBus);
assertSame(parentEventBus, configuration.getParentEventBus());
String historyName = "historyName";
configuration.setHistoryName("historyName");
assertSame(historyName, configuration.getHistoryName());
ChildModulesElement childConfig = new ChildModulesElement();
configuration.setLoadChildConfig(childConfig);
assertSame(childConfig, configuration.getLoadChildConfig());
DebugElement debug = new DebugElement();
configuration.setDebug(debug);
assertSame(debug, configuration.getDebug());
GinModuleElement gin = new GinModuleElement();
configuration.setGinModule(gin);
assertSame(gin, configuration.getGinModule());
EventFiltersElement filters = new EventFiltersElement();
configuration.setEventFilterConfiguration(filters);
assertSame(filters, configuration.getEventFilterConfiguration());
}
use of com.mvp4g.rebind.config.element.EventBusElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testGenerate.
@Test
public void testGenerate() 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(SimpleView01.class, "view");
views.add(view);
PresenterElement generate1 = newPresenter(SimplePresenter01.class, "generate1");
generate1.setView("view");
EventHandlerElement generate2 = newEventHandler(SimpleEventHandler01.class, "generate2");
presenters.add(generate1);
eventHandlers.add(generate2);
generate1.setMultiple(Boolean.TRUE.toString());
generate2.setMultiple(Boolean.TRUE.toString());
configuration.validateEventHandlers();
List<String> generate = event1.getGenerate();
assertEquals(2, generate.size());
assertEquals(generate.get(0), generate1.getName());
assertEquals(generate.get(1), generate2.getName());
List<String> handlers = event1.getHandlers();
assertEquals(1, handlers.size());
assertEquals(generate2.getName(), handlers.get(0));
}
use of com.mvp4g.rebind.config.element.EventBusElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testUnknownActivateDeactivate.
@Test
public void testUnknownActivateDeactivate() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event1 = newEvent("event1");
event1.setActivate(new String[] { "activate" });
events.add(event1);
try {
configuration.validateEventHandlers();
fail();
} catch (UnknownConfigurationElementException e) {
assertTrue(e.getMessage().contains("Encountered a reference to unknown element 'activate'"));
}
events.clear();
EventElement event2 = newEvent("event2");
event2.setDeactivate(new String[] { "deactivate" });
events.add(event2);
try {
configuration.validateEventHandlers();
fail();
} catch (UnknownConfigurationElementException e) {
assertTrue(e.getMessage().contains("Encountered a reference to unknown element 'deactivate'"));
}
}
Aggregations