Search in sources :

Example 1 with TestBroadcast2

use of com.mvp4g.rebind.test_tools.annotation.TestBroadcast2 in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testParentBroadcast.

@Test
public void testParentBroadcast() throws InvalidMvp4gConfigurationException {
    String parentModule = oracle.addClass(Modules.BroadcastModule2.class).getQualifiedSourceName();
    EventElement event = newEvent("testEvent");
    event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
    event.setEventObjectClass(new String[] { String.class.getCanonicalName() });
    events.add(event);
    EventElement event2 = newEvent("testEvent2");
    event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
    events.add(event2);
    Map<String, ChildModuleElement> childModuleMap = configuration.getModuleParentEventBusClassMap();
    JClassType parentEventBus = oracle.addClass(EventBusOk.class);
    configuration.setParentEventBus(parentEventBus);
    String currentModule = oracle.addClass(Modules.ModuleWithParent01.class).getQualifiedSourceName();
    ChildModuleElement module = new ChildModuleElement();
    module.setParentEventBus(parentEventBus);
    module.setParentModuleClass(parentModule);
    module.setClassName(currentModule);
    childModuleMap.put(currentModule, module);
    setEventBus();
    configuration.setModule(oracle.findType(Modules.ModuleWithParent01.class.getCanonicalName()));
    List<ChildModuleElement> siblings = configuration.getSiblings();
    assertEquals(0, siblings.size());
    assertFalse(event.hasForwardToParent());
    assertFalse(event2.hasForwardToParent());
    configuration.validateChildModules();
    assertTrue(event.hasForwardToParent());
    assertTrue(event2.hasForwardToParent());
}
Also used : TestBroadcast2(com.mvp4g.rebind.test_tools.annotation.TestBroadcast2) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) EventElement(com.mvp4g.rebind.config.element.EventElement) TestBroadcast(com.mvp4g.rebind.test_tools.annotation.TestBroadcast) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) Test(org.junit.Test)

Example 2 with TestBroadcast2

use of com.mvp4g.rebind.test_tools.annotation.TestBroadcast2 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));
}
Also used : TestBroadcast2(com.mvp4g.rebind.test_tools.annotation.TestBroadcast2) EventElement(com.mvp4g.rebind.config.element.EventElement) TestBroadcast(com.mvp4g.rebind.test_tools.annotation.TestBroadcast) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 3 with TestBroadcast2

use of com.mvp4g.rebind.test_tools.annotation.TestBroadcast2 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));
}
Also used : TestBroadcast2(com.mvp4g.rebind.test_tools.annotation.TestBroadcast2) EventElement(com.mvp4g.rebind.config.element.EventElement) TestBroadcast(com.mvp4g.rebind.test_tools.annotation.TestBroadcast) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) Test(org.junit.Test)

Example 4 with TestBroadcast2

use of com.mvp4g.rebind.test_tools.annotation.TestBroadcast2 in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testSiblingBroadcast.

@Test
public void testSiblingBroadcast() throws InvalidMvp4gConfigurationException {
    String siblingModule1 = oracle.addClass(Modules.BroadcastModule.class).getQualifiedSourceName();
    String siblingModule2 = oracle.addClass(Modules.BroadcastModule2.class).getQualifiedSourceName();
    String siblingModule3 = oracle.addClass(Modules.Module01.class).getQualifiedSourceName();
    EventElement event = newEvent("testEvent");
    event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
    event.setEventObjectClass(new String[] { String.class.getCanonicalName() });
    events.add(event);
    EventElement event2 = newEvent("testEvent2");
    event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
    event2.setForwardToModules(new String[] { siblingModule3 });
    events.add(event2);
    String currentParentModule = oracle.addClass(Modules.ModuleWithParentNoName.class).getQualifiedSourceName();
    Map<String, ChildModuleElement> childModuleMap = configuration.getModuleParentEventBusClassMap();
    JClassType parentEventBus = oracle.addClass(EventBusOk.class);
    ChildModuleElement sibling1 = new ChildModuleElement();
    sibling1.setParentEventBus(parentEventBus);
    sibling1.setParentModuleClass(currentParentModule);
    sibling1.setClassName(siblingModule1);
    ChildModuleElement sibling2 = new ChildModuleElement();
    sibling2.setParentEventBus(parentEventBus);
    sibling2.setParentModuleClass(currentParentModule);
    sibling2.setClassName(siblingModule2);
    ChildModuleElement sibling3 = new ChildModuleElement();
    sibling3.setParentEventBus(parentEventBus);
    sibling3.setParentModuleClass(currentParentModule);
    sibling3.setClassName(siblingModule3);
    childModuleMap.put("sibling1", sibling1);
    childModuleMap.put("sibling2", sibling2);
    childModuleMap.put("sibling3", sibling3);
    configuration.setParentEventBus(parentEventBus);
    configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
    String currentModule01 = Modules.ModuleWithParent01.class.getCanonicalName();
    ChildModuleElement module01 = new ChildModuleElement();
    module01.setParentEventBus(parentEventBus);
    module01.setParentModuleClass(currentParentModule);
    module01.setClassName(currentModule01);
    childModuleMap.put(currentModule01, module01);
    setEventBus();
    List<ChildModuleElement> siblings = configuration.getSiblings();
    assertEquals(3, siblings.size());
    assertSame(sibling1, siblings.get(0));
    assertSame(sibling3, siblings.get(1));
    assertSame(sibling2, siblings.get(2));
    assertEquals(0, event.getSiblingsToLoad().size());
    assertEquals(1, event2.getForwardToModules().size());
    configuration.validateChildModules();
    List<String> siblingsToLoad = event.getSiblingsToLoad();
    assertEquals(2, siblingsToLoad.size());
    assertEquals(sibling1.getClassName(), siblingsToLoad.get(0));
    assertEquals(sibling2.getClassName(), siblingsToLoad.get(1));
    siblingsToLoad = event2.getSiblingsToLoad();
    assertEquals(2, siblingsToLoad.size());
    assertEquals(sibling3.getClassName(), siblingsToLoad.get(0));
    assertEquals(sibling2.getClassName(), siblingsToLoad.get(1));
}
Also used : TestBroadcast(com.mvp4g.rebind.test_tools.annotation.TestBroadcast) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) TestBroadcast2(com.mvp4g.rebind.test_tools.annotation.TestBroadcast2) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) EventElement(com.mvp4g.rebind.config.element.EventElement) Test(org.junit.Test)

Aggregations

EventElement (com.mvp4g.rebind.config.element.EventElement)4 TestBroadcast (com.mvp4g.rebind.test_tools.annotation.TestBroadcast)4 TestBroadcast2 (com.mvp4g.rebind.test_tools.annotation.TestBroadcast2)4 Test (org.junit.Test)4 ChildModuleElement (com.mvp4g.rebind.config.element.ChildModuleElement)3 Modules (com.mvp4g.rebind.test_tools.Modules)3 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)2 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)1 ViewElement (com.mvp4g.rebind.config.element.ViewElement)1 Presenters (com.mvp4g.rebind.test_tools.annotation.Presenters)1