Search in sources :

Example 16 with SimplePresenter01

use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testListOk.

@Test
public void testListOk() throws Mvp4gAnnotationException {
    List<JClassType> annotedClasses = new ArrayList<JClassType>();
    annotedClasses.add(oracle.addClass(PresenterWithName.class));
    annotedClasses.add(oracle.addClass(SimplePresenter01.class));
    new PresenterAnnotationsLoader().load(annotedClasses, configuration);
    annotedClasses.clear();
    annotedClasses.add(oracle.addClass(HistoryConverterForEvent.class));
    new HistoryAnnotationsLoader().load(annotedClasses, configuration);
    annotedClasses.clear();
    JClassType type = oracle.addClass(EventBusOk.class);
    annotedClasses.add(type);
    loader.load(annotedClasses, configuration);
    Set<EventElement> events = configuration.getEvents();
    assertEquals(5, events.size());
    for (EventElement e : events) {
        if ("event1".equals(e.getType())) {
            assertEquals(String.class.getName(), e.getEventObjectClass()[0]);
            assertEquals("treatEvent1", e.getCalledMethod());
            assertFalse(e.isNavigationEvent());
            assertFalse(e.isWithTokenGeneration());
            assertFalse(e.isPassive());
            assertEquals("name", e.getHandlers().get(0));
            assertEquals("history", e.getHistory());
        } else if ("event2".equals(e.getType())) {
            assertNull(e.getEventObjectClass());
            assertEquals("onEvent2", e.getCalledMethod());
            assertTrue(e.isNavigationEvent());
            assertTrue(e.isWithTokenGeneration());
            assertTrue(e.isPassive());
        } else if ("event3".equals(e.getType())) {
            assertNull(e.getEventObjectClass());
            assertEquals("onEvent3", e.getCalledMethod());
            assertFalse(e.isNavigationEvent());
            assertFalse(e.isWithTokenGeneration());
            assertFalse(e.isPassive());
        } else if ("event4".equals(e.getType())) {
            assertNull(e.getEventObjectClass());
            assertEquals("onEvent4", e.getCalledMethod());
            assertFalse(e.isNavigationEvent());
            assertFalse(e.isWithTokenGeneration());
            assertFalse(e.isPassive());
        } else if ("event5".equals(e.getType())) {
            assertFalse(e.isNavigationEvent());
            assertFalse(e.isPassive());
            assertFalse(e.isWithTokenGeneration());
        } else {
            fail("Unknown event name");
        }
    }
    assertEquals("event2", configuration.getStart().getEventType());
    assertEquals("event2", configuration.getHistory().getInitEvent());
    assertEquals("event1", configuration.getHistory().getNotFoundEvent());
    assertEquals("event2", configuration.getStart().getForwardEventType());
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) HistoryConverterForEvent(com.mvp4g.rebind.test_tools.annotation.history_converters.HistoryConverterForEvent) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 17 with SimplePresenter01

use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testStart.

@Test
public void testStart() throws Mvp4gAnnotationException {
    List<JClassType> annotedClasses = new ArrayList<JClassType>();
    annotedClasses.add(oracle.addClass(SimplePresenter01.class));
    new PresenterAnnotationsLoader().load(annotedClasses, configuration);
    annotedClasses.clear();
    JClassType type = oracle.addClass(Events.SimpleEventBus.class);
    annotedClasses.add(type);
    loader.load(annotedClasses, configuration);
    StartElement start = configuration.getStart();
    assertEquals(configuration.getPresenters().iterator().next().getName(), start.getPresenter());
    assertFalse(start.hasHistory());
    assertTrue(configuration.getStart().hasPresenter());
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Events(com.mvp4g.rebind.test_tools.annotation.Events) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 18 with SimplePresenter01

use of com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01 in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testEventBus.

@Test
public void testEventBus() throws Mvp4gAnnotationException {
    List<JClassType> annotedClasses = new ArrayList<JClassType>();
    annotedClasses.add(oracle.addClass(SimplePresenter01.class));
    new PresenterAnnotationsLoader().load(annotedClasses, configuration);
    annotedClasses.clear();
    JClassType type = oracle.addClass(Events.SimpleEventBus.class);
    annotedClasses.add(type);
    loader.load(annotedClasses, configuration);
    EventBusElement eventBus = configuration.getEventBus();
    assertEquals(BaseEventBus.class.getName(), eventBus.getAbstractClassName());
    assertEquals(type.getQualifiedSourceName(), eventBus.getInterfaceClassName());
    assertFalse(eventBus.isWithLookUp());
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Events(com.mvp4g.rebind.test_tools.annotation.Events) BaseEventBus(com.mvp4g.client.event.BaseEventBus) 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