use of com.mvp4g.rebind.config.element.EventAssociation in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testValidateSplitterSingle.
@Test
public void testValidateSplitterSingle() throws InvalidMvp4gConfigurationException {
setEventBus();
PresenterElement presenter = newPresenter(SimplePresenter01.class, "presenter");
presenter.setAsync(SingleSplitter.class.getCanonicalName());
presenters.add(presenter);
PresenterElement presenterMultiple = newPresenter(SimplePresenter02.class, "presenterMultiple");
presenterMultiple.setAsync(SingleSplitter.class.getCanonicalName());
presenterMultiple.setMultiple("true");
presenters.add(presenterMultiple);
EventHandlerElement eventHandler = newEventHandler(SimpleEventHandler01.class, "eventHandler");
eventHandler.setAsync(SingleSplitter.class.getCanonicalName());
eventHandlers.add(eventHandler);
EventHandlerElement eventHandlerMultiple = newEventHandler(SimpleEventHandler02.class, "eventHandlerMultiple");
eventHandlerMultiple.setAsync(SingleSplitter.class.getCanonicalName());
eventHandlerMultiple.setMultiple("true");
eventHandlers.add(eventHandlerMultiple);
EventElement event = new EventElement();
event.setType("event");
event.setHandlers(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setBinds(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setActivate(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setDeactivate(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
events.add(event);
configuration.validateSplitters();
assertEquals(4, configuration.getSplitters().size());
SplitterElement splitter;
Iterator<SplitterElement> it = configuration.getSplitters().iterator();
List<String> list;
while (it.hasNext()) {
splitter = it.next();
if ("com_mvp4g_client_SingleSplitter0".equals(splitter.getClassName())) {
list = Arrays.asList("eventHandler");
assertEquals("com_mvp4g_client_SingleSplitter0", splitter.getName());
assertNull(splitter.getLoader());
assertEquals(1, splitter.getHandlers().size());
assertTrue(splitter.getHandlers().contains(eventHandler));
Map<EventElement, EventAssociation<String>> events = splitter.getEvents();
assertEquals(1, events.size());
EventElement key = events.keySet().iterator().next();
assertSame(event, key);
EventAssociation<String> association = events.get(key);
assertList(list, association.getActivated());
assertList(list, association.getDeactivated());
assertList(list, association.getBinds());
assertList(list, association.getHandlers());
} else if ("com_mvp4g_client_SingleSplitter1".equals(splitter.getClassName())) {
list = Arrays.asList("eventHandlerMultiple");
assertEquals("com_mvp4g_client_SingleSplitter1", splitter.getName());
assertNull(splitter.getLoader());
assertEquals(1, splitter.getHandlers().size());
assertTrue(splitter.getHandlers().contains(eventHandlerMultiple));
Map<EventElement, EventAssociation<String>> events = splitter.getEvents();
assertEquals(1, events.size());
EventElement key = events.keySet().iterator().next();
assertSame(event, key);
EventAssociation<String> association = events.get(key);
assertList(list, association.getActivated());
assertList(list, association.getDeactivated());
assertList(list, association.getBinds());
assertList(list, association.getHandlers());
} else if ("com_mvp4g_client_SingleSplitter2".equals(splitter.getClassName())) {
list = Arrays.asList("presenterMultiple");
assertEquals("com_mvp4g_client_SingleSplitter2", splitter.getName());
assertNull(splitter.getLoader());
assertEquals(1, splitter.getHandlers().size());
assertTrue(splitter.getHandlers().contains(presenterMultiple));
Map<EventElement, EventAssociation<String>> events = splitter.getEvents();
assertEquals(1, events.size());
EventElement key = events.keySet().iterator().next();
assertSame(event, key);
EventAssociation<String> association = events.get(key);
assertList(list, association.getActivated());
assertList(list, association.getDeactivated());
assertList(list, association.getBinds());
assertList(list, association.getHandlers());
} else if ("com_mvp4g_client_SingleSplitter3".equals(splitter.getClassName())) {
list = Arrays.asList("presenter");
assertEquals("com_mvp4g_client_SingleSplitter3", splitter.getName());
assertNull(splitter.getLoader());
assertEquals(1, splitter.getHandlers().size());
assertTrue(splitter.getHandlers().contains(presenter));
Map<EventElement, EventAssociation<String>> events = splitter.getEvents();
assertEquals(1, events.size());
EventElement key = events.keySet().iterator().next();
assertSame(event, key);
EventAssociation<String> association = events.get(key);
assertList(list, association.getActivated());
assertList(list, association.getDeactivated());
assertList(list, association.getBinds());
assertList(list, association.getHandlers());
} else {
fail("Unknown splitter");
}
}
}
use of com.mvp4g.rebind.config.element.EventAssociation in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testValidateSplitterTogether.
@Test
public void testValidateSplitterTogether() throws InvalidMvp4gConfigurationException {
setEventBus();
String splitterName = oracle.addClass(Splitters.SimpleSplitter.class).getQualifiedSourceName();
PresenterElement presenter = newPresenter(SimplePresenter01.class, "presenter");
presenter.setAsync(splitterName);
presenters.add(presenter);
PresenterElement presenterMultiple = newPresenter(SimplePresenter02.class, "presenterMultiple");
presenterMultiple.setAsync(splitterName);
presenterMultiple.setMultiple("true");
presenters.add(presenterMultiple);
EventHandlerElement eventHandler = newEventHandler(SimpleEventHandler01.class, "eventHandler");
eventHandler.setAsync(splitterName);
eventHandlers.add(eventHandler);
EventHandlerElement eventHandlerMultiple = newEventHandler(SimpleEventHandler02.class, "eventHandlerMultiple");
eventHandlerMultiple.setAsync(splitterName);
eventHandlerMultiple.setMultiple("true");
eventHandlers.add(eventHandlerMultiple);
EventElement event = new EventElement();
event.setType("event");
event.setHandlers(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setBinds(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setActivate(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setDeactivate(new String[] { "presenter", "eventHandler", "presenterMultiple", "eventHandlerMultiple" });
event.setGenerate(new String[] { "presenterMultiple", "eventHandlerMultiple" });
events.add(event);
configuration.validateSplitters();
splitterName = Splitters.SimpleSplitter.class.getCanonicalName().replace(".", "_");
assertEquals(1, configuration.getSplitters().size());
SplitterElement splitter = configuration.getSplitters().iterator().next();
assertEquals(splitterName, splitter.getClassName());
assertEquals(splitterName, splitter.getName());
assertNull(splitter.getLoader());
assertEquals(4, splitter.getHandlers().size());
assertTrue(splitter.getHandlers().contains(eventHandler));
assertTrue(splitter.getHandlers().contains(presenter));
assertTrue(splitter.getHandlers().contains(eventHandlerMultiple));
assertTrue(splitter.getHandlers().contains(presenterMultiple));
Map<EventElement, EventAssociation<String>> events = splitter.getEvents();
assertEquals(1, events.size());
EventElement key = events.keySet().iterator().next();
assertSame(event, key);
EventAssociation<String> association = events.get(key);
List<String> list = Arrays.asList("eventHandler", "eventHandlerMultiple", "presenter", "presenterMultiple");
assertCollection(list, association.getActivated());
assertCollection(list, association.getDeactivated());
assertCollection(list, association.getBinds());
assertCollection(list, association.getHandlers());
assertCollection(Arrays.asList("eventHandlerMultiple", "presenterMultiple"), association.getGenerate());
}
Aggregations