use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHandlerValidationSucceedsNoInjectedView.
@Test
public void testEventHandlerValidationSucceedsNoInjectedView() throws InvalidMvp4gConfigurationException {
ViewElement view = newView(SimpleView01.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();
assertFalse(presenter.hasInverseView());
}
use of com.mvp4g.rebind.config.element.EventElement 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.EventElement 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'"));
}
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testInvalidChildModule.
@Test(expected = InvalidClassException.class)
public void testInvalidChildModule() throws InvalidMvp4gConfigurationException {
ChildModuleElement childModule1 = new ChildModuleElement();
childModule1.setName("child1");
childModule1.setClassName(Object.class.getName());
childModules.add(childModule1);
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { "child1" });
event.setEventObjectClass(new String[] { Object.class.getCanonicalName() });
events.add(event);
setEventBus();
configuration.validateChildModules();
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testChildModulesBroadcast.
@Test
public void testChildModulesBroadcast() throws InvalidMvp4gConfigurationException {
oracle.addClass(TestBroadcast.class);
ChildModuleElement childModule = new ChildModuleElement();
childModule.setName("child");
Class<?> c = Modules.BroadcastModule.class;
oracle.addClass(c);
childModule.setClassName(c.getCanonicalName());
childModule.setAutoDisplay("false");
childModules.add(childModule);
ChildModuleElement childModule2 = new ChildModuleElement();
childModule2.setName("child2");
c = Modules.BroadcastModule2.class;
oracle.addClass(c);
childModule2.setClassName(c.getCanonicalName());
childModule2.setAutoDisplay("false");
childModules.add(childModule2);
ChildModuleElement childModule3 = new ChildModuleElement();
childModule3.setName("child3");
c = Modules.BroadcastModule2.class;
childModule3.setClassName(c.getCanonicalName());
childModule3.setAutoDisplay("false");
childModules.add(childModule3);
EventElement event = newEvent("testEvent");
event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
event.setForwardToModules(new String[0]);
events.add(event);
EventElement event2 = newEvent("testEvent2");
event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
event2.setForwardToModules(new String[] { "child3" });
events.add(event2);
setEventBus();
configuration.validateChildModules();
List<String> modules = event.getForwardToModules();
assertEquals(3, modules.size());
assertEquals("child", modules.get(0));
assertEquals("child3", modules.get(1));
assertEquals("child2", modules.get(2));
modules = event2.getForwardToModules();
assertEquals(2, modules.size());
assertEquals("child3", modules.get(0));
assertEquals("child2", modules.get(1));
}
Aggregations