use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testInjectedServiceValidationFailsForPresenter.
@Test(expected = UnknownConfigurationElementException.class)
public void testInjectedServiceValidationFailsForPresenter() throws UnknownConfigurationElementException, InvalidTypeException, InvalidClassException, NotFoundClassException {
events.add(newEvent("badService"));
views.add(newView(SimpleView02.class, "badService"));
presenters.add(newPresenter(SimplePresenter01.class, "badService"));
historyConverters.add(newHistoryConverter(SimpleHistoryConverter01.class, "badService"));
PresenterElement presenter = newPresenter(SimplePresenter02.class, "testPresenter");
presenter.getInjectedServices().add(new InjectedElement("badService", "setBadService"));
presenters.add(presenter);
configuration.validateServices();
}
use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method newPresenter.
private PresenterElement newPresenter(Class<? extends BaseEventHandler<? extends EventBus>> c, String name) {
PresenterElement presenter = new PresenterElement();
presenter.setName(name);
oracle.addClass(c);
presenter.setClassName(c.getCanonicalName());
return presenter;
}
use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testBroadcastHandlers.
@Test
public void testBroadcastHandlers() throws InvalidMvp4gConfigurationException {
oracle.addClass(TestBroadcast.class);
ViewElement view = newView(SimpleView01.class, "view");
views.add(view);
PresenterElement presenter = new PresenterElement();
presenter.setName("presenter");
Class<?> c = Presenters.BroadcastPresenter.class;
presenter.setClassName(c.getCanonicalName());
oracle.addClass(c);
presenter.setView("view");
presenters.add(presenter);
PresenterElement presenter2 = new PresenterElement();
presenter2.setName("presenter2");
c = Presenters.BroadcastPresenter2.class;
presenter2.setClassName(c.getCanonicalName());
oracle.addClass(c);
presenter2.setView("view");
presenters.add(presenter2);
PresenterElement presenter3 = new PresenterElement();
presenter3.setName("presenter3");
c = Presenters.BroadcastPresenter2.class;
presenter3.setClassName(c.getCanonicalName());
presenter3.setView("view");
presenters.add(presenter3);
EventElement event = newEvent("event");
event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
event.setHandlers(new String[0]);
events.add(event);
EventElement event2 = newEvent("event2");
event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
event2.setHandlers(new String[] { "presenter3" });
events.add(event2);
setEventBus();
configuration.validateEventHandlers();
List<String> handlers = event.getHandlers();
assertEquals(3, handlers.size());
assertEquals("presenter3", handlers.get(0));
assertEquals("presenter2", handlers.get(1));
assertEquals("presenter", handlers.get(2));
handlers = event2.getHandlers();
assertEquals(2, handlers.size());
assertEquals("presenter3", handlers.get(0));
assertEquals("presenter2", handlers.get(1));
}
use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testInjectedServiceRemove.
@Test
public void testInjectedServiceRemove() throws UnknownConfigurationElementException {
ServiceElement service1 = newService("service1");
ServiceElement service2 = newService("service2");
ServiceElement service3 = newService("service3");
ServiceElement service4 = newService("service4");
services.add(service1);
services.add(service2);
services.add(service3);
services.add(service4);
PresenterElement presenter = newPresenter(SimplePresenter01.class, "testPresenter");
presenter.getInjectedServices().add(new InjectedElement("service1", "setTestService"));
presenters.add(presenter);
HistoryConverterElement historyConverter = newHistoryConverter(SimpleHistoryConverter01.class, "testHistoryConverter");
historyConverter.getInjectedServices().add(new InjectedElement("service2", "setTestService"));
historyConverters.add(historyConverter);
EventHandlerElement eventHandlerElement = newEventHandler(SimpleEventHandler01.class, "testEventHandler");
eventHandlerElement.getInjectedServices().add(new InjectedElement("service3", "setTestService"));
eventHandlers.add(eventHandlerElement);
assertEquals(services.size(), 4);
assertTrue(services.contains(service1));
assertTrue(services.contains(service2));
assertTrue(services.contains(service3));
assertTrue(services.contains(service4));
configuration.validateServices();
assertEquals(services.size(), 3);
assertTrue(services.contains(service1));
assertTrue(services.contains(service2));
assertTrue(services.contains(service3));
assertFalse(services.contains(service4));
}
use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testActivateDeActivateOk.
@Test
public void testActivateDeActivateOk() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event = newEvent("event");
event.setHandlers(new String[] { "activate1", "deactivate1", "activate2", "deactivate2" });
events.add(event);
EventElement event1 = newEvent("event1");
event1.setActivate(new String[] { "activate1", "activate2" });
event1.setDeactivate(new String[] { "deactivate1", "deactivate2" });
events.add(event1);
PresenterElement activate1 = newPresenter(SimplePresenter01.class, "activate1");
EventHandlerElement activate2 = newEventHandler(SimpleEventHandler01.class, "activate2");
PresenterElement deactivate1 = newPresenter(SimplePresenter02.class, "deactivate1");
EventHandlerElement deactivate2 = newEventHandler(SimpleEventHandler02.class, "deactivate2");
eventHandlers.add(activate1);
eventHandlers.add(activate2);
eventHandlers.add(deactivate1);
eventHandlers.add(deactivate2);
configuration.validateEventHandlers();
List<String> activate = event1.getActivate();
assertTrue(activate.size() == 2);
assertEquals(activate.get(0), activate1.getName());
assertEquals(activate.get(1), activate2.getName());
List<String> deactivate = event1.getDeactivate();
assertTrue(deactivate.size() == 2);
assertEquals(deactivate.get(0), deactivate1.getName());
assertEquals(deactivate.get(1), deactivate2.getName());
}
Aggregations