use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.
the class BaseEventBusTest method testAddRemoveHandler.
@Test
public void testAddRemoveHandler() {
List<SimplePresenter01> list = bus.getHandlers(SimplePresenter01.class);
assertNull(list);
SimplePresenter01 p = bus.addHandler(SimplePresenter01.class);
list = bus.getHandlers(SimplePresenter01.class);
assertTrue(list.size() == 1);
assertEquals(list.get(0), p);
bus.removeHandler(p);
list = bus.getHandlers(SimplePresenter01.class);
assertTrue(list.size() == 0);
List<SimplePresenter01> list2 = bus.getHandlers(SimplePresenter01.class);
assertNotSame(list, list2);
assertEquals(list, list2);
}
use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.
the class BaseEventBusTest method testSetPresenter.
@Test
public void testSetPresenter() {
SimplePresenter01 presenter = new SimplePresenter01();
SimpleInjectedView view = new SimpleInjectedView();
SimplePresenter01 presenter2 = BaseEventBus.setPresenter(false, presenter, view, bus);
assertSame(presenter, presenter2);
assertSame(presenter.getEventBus(), bus);
assertSame(presenter.getView(), view);
presenter = new SimplePresenter01();
view = new SimpleInjectedView();
presenter2 = BaseEventBus.setPresenter(true, presenter, view, bus);
assertSame(presenter, presenter2);
assertSame(presenter.getEventBus(), bus);
assertSame(presenter.getView(), view);
assertSame(presenter, view.getPresenter());
}
use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testInstantiateViewAtStart.
@Test
public void testInstantiateViewAtStart() throws InvalidMvp4gConfigurationException {
ViewElement view1 = newView(SimpleView02.class, "view1");
view1.setClassName(SimpleView02.class.getCanonicalName());
views.add(view1);
ViewElement view2 = newView(SimpleView03.class, "view2");
view2.setClassName(SimpleView03.class.getCanonicalName());
views.add(view2);
ViewElement view3 = newView(SimpleView04.class, "view3");
view3.setClassName(SimpleView04.class.getCanonicalName());
views.add(view3);
PresenterElement presenter = new PresenterElement();
presenter.setName("presenter1");
Class<?> c = SimplePresenter01.class;
presenter.setClassName(c.getCanonicalName());
oracle.addClass(c);
presenter.setView("view1");
presenters.add(presenter);
PresenterElement presenter2 = new PresenterElement();
presenter2.setName("presenter2");
c = PresenterWithService.class;
presenter2.setClassName(c.getCanonicalName());
oracle.addClass(c);
presenter2.setView("view2");
presenter2.setMultiple("true");
presenters.add(presenter2);
PresenterElement presenter3 = new PresenterElement();
presenter3.setName("presenter3");
c = Presenters.AsyncPresenter.class;
oracle.addClass(c);
presenter3.setClassName(c.getCanonicalName());
presenter3.setView("view3");
presenter3.setAsync("true");
presenters.add(presenter3);
EventElement event = newEvent("event");
event.setHandlers(new String[] { "presenter1", "presenter2", "presenter3" });
events.add(event);
setEventBus();
configuration.validateEventHandlers();
assertTrue(view1.isInstantiateAtStart());
assertFalse(view2.isInstantiateAtStart());
assertFalse(view3.isInstantiateAtStart());
}
use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testInjectedServiceValidationFailsForHistoryConverter.
@Test(expected = UnknownConfigurationElementException.class)
public void testInjectedServiceValidationFailsForHistoryConverter() 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"));
HistoryConverterElement historyConverter = newHistoryConverter(SimpleHistoryConverter02.class, "testHistoryConverter");
historyConverter.getInjectedServices().add(new InjectedElement("badService", "setBadService"));
historyConverters.add(historyConverter);
configuration.validateServices();
}
use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.
the class Mvp4gConfigurationFileReaderTest method testWriteSplitterWithLoader.
@Test
public void testWriteSplitterWithLoader() {
ViewElement view = new ViewElement();
view.setName("view");
view.setClassName(String.class.getCanonicalName());
configuration.getViews().add(view);
PresenterElement presenter = new PresenterElement();
presenter.setName("presenter");
presenter.setClassName(SimplePresenter01.class.getCanonicalName());
presenter.setView("view");
configuration.getPresenters().add(presenter);
PresenterElement presenterWithView = new PresenterElement();
presenterWithView.setName("presenterWithView");
presenterWithView.setClassName(SimplePresenter01.class.getCanonicalName());
presenterWithView.setView("view");
presenterWithView.setInverseView("true");
configuration.getPresenters().add(presenterWithView);
EventHandlerElement eventHandler = new EventHandlerElement();
eventHandler.setName("eventHandler");
eventHandler.setClassName(SimpleEventHandler01.class.getCanonicalName());
configuration.getEventHandlers().add(eventHandler);
EventElement e1 = new EventElement();
e1.setType("event1");
e1.setSplitters(new String[] { "splitter" });
e1.setEventObjectClass(new String[] { "int", "String" });
EventElement e2 = new EventElement();
e2.setType("event2");
e2.setSplitters(new String[] { "splitter" });
EventElement e3 = new EventElement();
e3.setType("event3");
e3.setSplitters(new String[] { "splitter" });
SplitterElement splitter = new SplitterElement();
splitter.getHandlers().add(presenter);
splitter.getHandlers().add(presenterWithView);
splitter.getHandlers().add(eventHandler);
splitter.setName("splitter");
splitter.setClassName("Splitter");
EventAssociation<String> ea1 = new EventAssociation<String>();
ea1.getActivated().add("eventHandler");
ea1.getDeactivated().add("presenter");
ea1.getBinds().add("presenter");
ea1.getHandlers().add("eventHandler");
splitter.getEvents().put(e1, ea1);
EventAssociation<String> ea2 = new EventAssociation<String>();
ea2.getActivated().add("eventHandler");
ea2.getDeactivated().add("presenter");
splitter.getEvents().put(e2, ea2);
EventAssociation<String> ea3 = new EventAssociation<String>();
ea3.getBinds().add("presenter");
splitter.getEvents().put(e3, ea3);
JClassType loaderType = ((TypeOracleStub) configuration.getOracle()).addClass(Loaders.Loader1.class);
LoaderElement loader = new LoaderElement();
loader.setName("loader");
loader.setClassName(loaderType.getQualifiedSourceName());
configuration.getLoaders().add(loader);
splitter.setLoader("loader");
Set<EventElement> events = configuration.getEvents();
events.add(e1);
events.add(e2);
events.add(e3);
configuration.getSplitters().add(splitter);
assertOutput(getExpectedSplitter(false), false);
assertOutput(getExpectedSplitterLoadingConf(), false);
assertOutput(getExpectedSplitterPassiveGenerateMultiple(), false);
assertOutput(getExpectedSplitterNotPassive(), false);
assertOutput(getExpectedSplitterWithLoader(), false);
writer.writeConf();
assertOutput(getExpectedSplitter(false), true);
assertOutput(getExpectedSplitterLoadingConf(), false);
assertOutput(getExpectedSplitterPassiveGenerateMultiple(), false);
assertOutput(getExpectedSplitterNotPassive(), true);
assertOutput(getExpectedSplitterWithLoader(), true);
}
Aggregations