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