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());
}
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());
}
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());
}
Aggregations