use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method validateHistoryName.
@Test
public void validateHistoryName() throws InvalidMvp4gConfigurationException {
EventElement element = newEvent("forward");
try {
configuration.validateHistoryName("!test", element);
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("history name can't start with '" + PlaceService.CRAWLABLE + "' or contain '" + PlaceService.MODULE_SEPARATOR + "'."));
}
try {
configuration.validateHistoryName("/test", element);
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("history name can't start with '" + PlaceService.CRAWLABLE + "' or contain '" + PlaceService.MODULE_SEPARATOR + "'."));
}
try {
configuration.validateHistoryName("te/st", element);
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertTrue(e.getMessage().contains("history name can't start with '" + PlaceService.CRAWLABLE + "' or contain '" + PlaceService.MODULE_SEPARATOR + "'."));
}
configuration.validateHistoryName("test", element);
configuration.validateHistoryName("tes!t", element);
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventWithNoObjectForAutoDisplay.
@Test(expected = InvalidMvp4gConfigurationException.class)
public void testEventWithNoObjectForAutoDisplay() throws InvalidMvp4gConfigurationException {
ChildModuleElement childModule1 = newChildModule(Modules.ChildModule01.class, "child1");
childModule1.setEventToDisplayView("testEvent");
childModules.add(childModule1);
EventElement event = newEvent("testEvent");
event.setForwardToModules(new String[] { "child1" });
events.add(event);
setEventBus();
try {
configuration.validateChildModules();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Event testEvent: event must have one and only one an object associated with it as it loads a child view.", e.getMessage());
throw e;
}
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testTokenGenerationNotOk.
@Test
public void testTokenGenerationNotOk() {
EventElement event = new EventElement();
event.setWithTokenGeneration("true");
event.setType("event1");
events.add(event);
try {
configuration.validateHistoryConverters();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Event event1: you can't generate a token for this event if it has no history converter.", e.getMessage());
}
configuration.setModule(oracle.addClass(Modules.Module01.class));
try {
configuration.validateHistoryConverters();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Event event1: you can't generate a token for this event if it has no history converter.", e.getMessage());
}
configuration.setParentEventBus(oracle.addClass(EventBusOk.class));
try {
configuration.validateHistoryConverters();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Event event1: you can't generate a token for this event if it has no history converter.", e.getMessage());
}
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testActivateDeActivateOk.
@Test
public void testActivateDeActivateOk() throws InvalidMvp4gConfigurationException {
EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
EventElement event = newEvent("event");
event.setHandlers(new String[] { "activate1", "deactivate1", "activate2", "deactivate2" });
events.add(event);
EventElement event1 = newEvent("event1");
event1.setActivate(new String[] { "activate1", "activate2" });
event1.setDeactivate(new String[] { "deactivate1", "deactivate2" });
events.add(event1);
PresenterElement activate1 = newPresenter(SimplePresenter01.class, "activate1");
EventHandlerElement activate2 = newEventHandler(SimpleEventHandler01.class, "activate2");
PresenterElement deactivate1 = newPresenter(SimplePresenter02.class, "deactivate1");
EventHandlerElement deactivate2 = newEventHandler(SimpleEventHandler02.class, "deactivate2");
eventHandlers.add(activate1);
eventHandlers.add(activate2);
eventHandlers.add(deactivate1);
eventHandlers.add(deactivate2);
configuration.validateEventHandlers();
List<String> activate = event1.getActivate();
assertTrue(activate.size() == 2);
assertEquals(activate.get(0), activate1.getName());
assertEquals(activate.get(1), activate2.getName());
List<String> deactivate = event1.getDeactivate();
assertTrue(deactivate.size() == 2);
assertEquals(deactivate.get(0), deactivate1.getName());
assertEquals(deactivate.get(1), deactivate2.getName());
}
use of com.mvp4g.rebind.config.element.EventElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSplitterLoaders.
@Test
public void testSplitterLoaders() throws InvalidMvp4gConfigurationException {
setEventBus();
oracle.addClass(Loaders.Loader1.class);
oracle.addClass(Loaders.Loader2.class);
oracle.addClass(Splitters.SplitterWithLoader.class);
oracle.addClass(Splitters.SplitterWithSameLoader1.class);
oracle.addClass(Splitters.SplitterWithSameLoader2.class);
PresenterElement presenter1 = newPresenter(SimplePresenter01.class, "presenter1");
presenter1.setAsync(Splitters.SplitterWithLoader.class.getCanonicalName());
presenters.add(presenter1);
PresenterElement presenter2 = newPresenter(SimplePresenter02.class, "presenter2");
presenter2.setAsync(Splitters.SplitterWithSameLoader1.class.getCanonicalName());
presenters.add(presenter2);
PresenterElement presenter3 = newPresenter(SimplePresenter03.class, "presenter3");
presenter3.setAsync(Splitters.SplitterWithSameLoader2.class.getCanonicalName());
presenters.add(presenter3);
EventElement event = new EventElement();
event.setHandlers(new String[] { "presenter1", "presenter2", "presenter3" });
configuration.getEvents().add(event);
configuration.validateSplitters();
assertEquals(3, configuration.getSplitters().size());
String loader1Name = "loader" + Loaders.Loader1.class.getCanonicalName().replace(".", "_");
String loader2Name = "loader" + Loaders.Loader2.class.getCanonicalName().replace(".", "_");
String splitter1Name = Splitters.SplitterWithLoader.class.getCanonicalName().replace(".", "_");
String splitter2Name = Splitters.SplitterWithSameLoader1.class.getCanonicalName().replace(".", "_");
String splitter3Name = Splitters.SplitterWithSameLoader2.class.getCanonicalName().replace(".", "_");
Set<SplitterElement> splitters = configuration.getSplitters();
Iterator<SplitterElement> itSplitter = splitters.iterator();
SplitterElement splitter;
String splitterName;
while (itSplitter.hasNext()) {
splitter = itSplitter.next();
splitterName = splitter.getName();
if (splitter1Name.equals(splitterName)) {
assertEquals(splitter.getLoader(), loader1Name);
} else if (splitter2Name.equals(splitterName)) {
assertEquals(splitter.getLoader(), loader2Name);
} else if (splitter3Name.equals(splitterName)) {
assertEquals(splitter.getLoader(), loader2Name);
} else {
fail("Unknown splitter " + splitterName);
}
}
Set<LoaderElement> loaders = configuration.getLoaders();
assertEquals(2, loaders.size());
Iterator<LoaderElement> it = loaders.iterator();
LoaderElement next;
String name;
while (it.hasNext()) {
next = it.next();
name = next.getName();
if (name.equals(loader1Name)) {
assertEquals(Loaders.Loader1.class.getCanonicalName(), next.getClassName());
} else if (name.equals(loader2Name)) {
assertEquals(Loaders.Loader2.class.getCanonicalName(), next.getClassName());
} else {
fail("Unknown loader " + next.getName());
}
}
}
Aggregations