Search in sources :

Example 6 with SimplePresenter01

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);
}
Also used : SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 7 with SimplePresenter01

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());
}
Also used : SimpleInjectedView(com.mvp4g.rebind.test_tools.annotation.views.SimpleInjectedView) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 8 with SimplePresenter01

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());
}
Also used : SimpleView02(com.mvp4g.rebind.test_tools.annotation.views.SimpleView02) SimpleView03(com.mvp4g.rebind.test_tools.annotation.views.SimpleView03) SimpleView04(com.mvp4g.rebind.test_tools.annotation.views.SimpleView04) EventElement(com.mvp4g.rebind.config.element.EventElement) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 9 with SimplePresenter01

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();
}
Also used : SimpleView02(com.mvp4g.rebind.test_tools.annotation.views.SimpleView02) HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) InjectedElement(com.mvp4g.rebind.config.element.InjectedElement) SimpleHistoryConverter01(com.mvp4g.rebind.test_tools.annotation.history_converters.SimpleHistoryConverter01) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 10 with SimplePresenter01

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);
}
Also used : TypeOracleStub(com.google.gwt.dev.javac.typemodel.TypeOracleStub) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) SimpleEventHandler01(com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Aggregations

SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)18 Test (org.junit.Test)16 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)8 Events (com.mvp4g.rebind.test_tools.annotation.Events)5 SimpleView02 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView02)4 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)3 SimpleHistoryConverter01 (com.mvp4g.rebind.test_tools.annotation.history_converters.SimpleHistoryConverter01)3 TypeOracleStub (com.google.gwt.dev.javac.typemodel.TypeOracleStub)2 EventElement (com.mvp4g.rebind.config.element.EventElement)2 InjectedElement (com.mvp4g.rebind.config.element.InjectedElement)2 Mvp4gAnnotationException (com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException)2 HistoryConverterForEvent (com.mvp4g.rebind.test_tools.annotation.history_converters.HistoryConverterForEvent)2 PresenterWithName (com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName)2 Before (org.junit.Before)2 TreeLogger (com.google.gwt.core.ext.TreeLogger)1 UnitTestTreeLogger (com.google.gwt.dev.util.UnitTestTreeLogger)1 DefaultMvp4gGinModule (com.mvp4g.client.DefaultMvp4gGinModule)1 Mvp4gModule (com.mvp4g.client.Mvp4gModule)1 BaseEventBus (com.mvp4g.client.event.BaseEventBus)1 BaseEventBusWithLookUp (com.mvp4g.client.event.BaseEventBusWithLookUp)1