Search in sources :

Example 1 with Events

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

the class EventsAnnotationsLoaderTest method testSameModuleForLoadModuleViewEvent.

@Test(expected = Mvp4gAnnotationException.class)
public void testSameModuleForLoadModuleViewEvent() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        annotedClasses.add(oracle.addClass(PresenterWithName.class));
        new PresenterAnnotationsLoader().load(annotedClasses, configuration);
        annotedClasses.clear();
        JClassType type = oracle.addClass(Events.EventBusSameModuleForLoadModuleViewEvent.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("Module " + Modules.Module01.class.getCanonicalName() + ": you can't have two events to load this module view."));
        throw e;
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) Events(com.mvp4g.rebind.test_tools.annotation.Events) Mvp4gAnnotationException(com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException) Test(org.junit.Test)

Example 2 with Events

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

the class EventsAnnotationsLoaderTest method testEventBusWithSiblingOk.

@Test
public void testEventBusWithSiblingOk() throws Mvp4gAnnotationException {
    List<JClassType> annotedClasses = new ArrayList<JClassType>();
    annotedClasses.add(oracle.addClass(PresenterWithName.class));
    new PresenterAnnotationsLoader().load(annotedClasses, configuration);
    annotedClasses.clear();
    JClassType type = oracle.addClass(Events.EventBusWithSiblings.class);
    annotedClasses.add(type);
    loader.load(annotedClasses, configuration);
    Set<ChildModuleElement> childModules = configuration.getChildModules();
    assertEquals(0, childModules.size());
    Set<EventElement> events = configuration.getEvents();
    assertEquals(2, events.size());
    List<String> modules;
    for (EventElement e : events) {
        modules = e.getForwardToModules();
        if ("event1".equals(e.getType())) {
            assertEquals(1, modules.size());
            assertEquals(Modules.Module01.class.getCanonicalName(), modules.get(0));
            assertFalse(e.hasForwardToParent());
        } else if ("event2".equals(e.getType())) {
            assertEquals(2, modules.size());
            assertEquals(Modules.ModuleWithParent01.class.getCanonicalName(), modules.get(0));
            assertEquals(Modules.Module01.class.getCanonicalName(), modules.get(1));
        } else {
            fail("Unknown event name");
        }
    }
}
Also used : PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModules(com.mvp4g.client.annotation.module.ChildModules) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Events(com.mvp4g.rebind.test_tools.annotation.Events) Test(org.junit.Test)

Example 3 with Events

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

the class EventsAnnotationsLoaderTest method testEventBusWithChildrenOk.

@Test
public void testEventBusWithChildrenOk() throws Mvp4gAnnotationException {
    List<JClassType> annotedClasses = new ArrayList<JClassType>();
    annotedClasses.add(oracle.addClass(PresenterWithName.class));
    new PresenterAnnotationsLoader().load(annotedClasses, configuration);
    annotedClasses.clear();
    JClassType type = oracle.addClass(Events.EventBusWithChildren.class);
    annotedClasses.add(type);
    loader.load(annotedClasses, configuration);
    Set<ChildModuleElement> childModules = configuration.getChildModules();
    assertEquals(2, childModules.size());
    for (ChildModuleElement child : childModules) {
        if (Modules.Module01.class.getCanonicalName().equals(child.getClassName())) {
            assertTrue(child.isAsync());
            assertTrue(child.isAutoDisplay());
            assertEquals("event1", child.getEventToDisplayView());
        } else if (Modules.ModuleWithParent01.class.getCanonicalName().equals(child.getClassName())) {
            assertFalse(child.isAsync());
            assertFalse(child.isAutoDisplay());
        } else {
            fail("Unknown child module");
        }
    }
    Set<EventElement> events = configuration.getEvents();
    assertEquals(4, events.size());
    List<String> modules;
    for (EventElement e : events) {
        if ("event1".equals(e.getType())) {
        } else if ("event2".equals(e.getType())) {
            modules = e.getForwardToModules();
            assertEquals(1, modules.size());
            assertEquals(Modules.Module01.class.getCanonicalName().replace(".", "_"), modules.get(0));
            assertFalse(e.hasForwardToParent());
        } else if ("event3".equals(e.getType())) {
            modules = e.getForwardToModules();
            assertEquals(2, modules.size());
            assertEquals(Modules.ModuleWithParent01.class.getCanonicalName().replace(".", "_"), modules.get(0));
            assertEquals(Modules.Module01.class.getCanonicalName().replace(".", "_"), modules.get(1));
            assertFalse(e.hasForwardToParent());
        } else if ("event4".equals(e.getType())) {
            assertTrue(e.hasForwardToParent());
        } else {
            fail("Unknown event name");
        }
    }
}
Also used : PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModules(com.mvp4g.client.annotation.module.ChildModules) JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Events(com.mvp4g.rebind.test_tools.annotation.Events) Test(org.junit.Test)

Aggregations

JClassType (com.google.gwt.core.ext.typeinfo.JClassType)3 Events (com.mvp4g.rebind.test_tools.annotation.Events)3 PresenterWithName (com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName)3 Test (org.junit.Test)3 ChildModules (com.mvp4g.client.annotation.module.ChildModules)2 Modules (com.mvp4g.rebind.test_tools.Modules)2 Mvp4gAnnotationException (com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException)1