Search in sources :

Example 1 with SimpleEventHandler01

use of com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01 in project mvp4g by mvp4g.

the class BaseEventBusTest method testSetEventHandler.

@Test
public void testSetEventHandler() {
    SimpleEventHandler01 eventHandler = new SimpleEventHandler01();
    SimpleEventHandler01 eventHandler2 = BaseEventBus.setEventHandler(eventHandler, bus);
    assertSame(eventHandler, eventHandler2);
    assertSame(eventHandler.getEventBus(), bus);
}
Also used : SimpleEventHandler01(com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01) Test(org.junit.Test)

Example 2 with SimpleEventHandler01

use of com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01 in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testWrongEventHandlerClass.

@Test
public void testWrongEventHandlerClass() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventElement event = newEvent("event");
    event.setHandlers(new String[] { "test" });
    events.add(event);
    EventHandlerElement handler = new EventHandlerElement();
    handler.setClassName(Object.class.getCanonicalName());
    handler.setName("test");
    eventHandlers.add(handler);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
    handler.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
    PresenterElement presenter = new PresenterElement();
    Class<?> c = SimpleEventHandler01.class;
    oracle.addClass(c);
    presenter.setClassName(c.getCanonicalName());
    presenter.setName("test");
    presenters.add(presenter);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
    presenter.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidClassException e) {
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) SimpleEventHandler01(com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01) InvalidClassException(com.mvp4g.rebind.exception.InvalidClassException) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) EventBusWithLookup(com.mvp4g.client.event.EventBusWithLookup) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) OneObject(com.mvp4g.rebind.test_tools.OneObject) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 3 with SimpleEventHandler01

use of com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01 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

SimpleEventHandler01 (com.mvp4g.rebind.test_tools.annotation.handlers.SimpleEventHandler01)3 Test (org.junit.Test)3 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)1 TypeOracleStub (com.google.gwt.dev.javac.typemodel.TypeOracleStub)1 BaseEventBus (com.mvp4g.client.event.BaseEventBus)1 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)1 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)1 EventElement (com.mvp4g.rebind.config.element.EventElement)1 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)1 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)1 InvalidClassException (com.mvp4g.rebind.exception.InvalidClassException)1 OneObject (com.mvp4g.rebind.test_tools.OneObject)1 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)1