use of com.mvp4g.rebind.test_tools.Modules in project mvp4g by mvp4g.
the class EventsAnnotationsLoaderTest method testEventBusWithSameChild.
@Test(expected = Mvp4gAnnotationException.class)
public void testEventBusWithSameChild() throws Mvp4gAnnotationException {
try {
List<JClassType> annotedClasses = new ArrayList<JClassType>();
JClassType type = oracle.addClass(Events.EventBusWithSameChild.class);
annotedClasses.add(type);
loader.load(annotedClasses, configuration);
} catch (Mvp4gAnnotationException e) {
assertTrue(e.getMessage().contains("You can't have two child modules describing the same module: " + Modules.Module01.class.getCanonicalName()));
throw e;
}
}
use of com.mvp4g.rebind.test_tools.Modules in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testFindChildModuleSameHistory.
@Test(expected = InvalidMvp4gConfigurationException.class)
public void testFindChildModuleSameHistory() throws InvalidMvp4gConfigurationException {
setEventBus();
ChildModuleElement childModule1 = newChildModule(Modules.ModuleWithParent01.class, "child1");
childModules.add(childModule1);
ChildModuleElement childModule2 = new ChildModuleElement();
childModule2.setName("child2");
childModule2.setClassName(Modules.ModuleWithParent01.class.getCanonicalName());
childModules.add(childModule2);
JClassType module = oracle.findType(Mvp4gModule.class.getCanonicalName());
configuration.setModule(module);
try {
configuration.findChildModuleHistoryNameAndLoader();
fail();
} catch (InvalidMvp4gConfigurationException e) {
String.format("Module %s: You can't have two child modules with the same history name \"%s\".", module.getQualifiedSourceName(), "moduleWithParent");
throw e;
}
}
use of com.mvp4g.rebind.test_tools.Modules 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));
}
use of com.mvp4g.rebind.test_tools.Modules 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.Modules 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