use of com.mvp4g.rebind.config.element.HistoryConverterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testHistoryWhenParent.
@Test
public void testHistoryWhenParent() throws InvalidMvp4gConfigurationException {
historyConverters.add(new HistoryConverterElement());
configuration.setModule(oracle.addClass(Modules.ModuleWithParent01.class));
// configuration.setModule( oracle.addClass( Modules.ModuleWithParent01.class ) );
setParentEventBus(Modules.ModuleWithParent01.class, EventBusOk.class);
configuration.loadParentModule();
configuration.getHistory().setInitEvent("event");
try {
configuration.validateHistory();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Module com.mvp4g.rebind.test_tools.Modules.ModuleWithParent01: History configuration (init, not found event and history parameter separator) should be set only for root module (only module with no parent)", e.getMessage());
}
HistoryElement history = new HistoryElement();
configuration.setHistory(history);
history.setNotFoundEvent("event");
try {
configuration.validateHistory();
fail();
} catch (InvalidMvp4gConfigurationException e) {
assertEquals("Module com.mvp4g.rebind.test_tools.Modules.ModuleWithParent01: History configuration (init, not found event and history parameter separator) should be set only for root module (only module with no parent)", e.getMessage());
}
history = new HistoryElement();
configuration.setHistory(history);
configuration.validateHistory();
assertNull(configuration.getHistory());
}
use of com.mvp4g.rebind.config.element.HistoryConverterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testTokenGenerationOk.
// ------------------------------------------------------------------------------
@Test
public void testTokenGenerationOk() throws InvalidMvp4gConfigurationException {
EventElement event = new EventElement();
event.setWithTokenGeneration("true");
event.setType("event1");
event.setHistory("history");
events.add(event);
event = new EventElement();
event.setWithTokenGeneration("true");
event.setType("event2");
event.setForwardToParent("true");
events.add(event);
HistoryConverterElement hc1 = newHistoryConverter(SimpleHistoryConverter01.class, "history");
historyConverters.add(hc1);
configuration.setModule(oracle.addClass(Modules.Module01.class));
setEventBus();
configuration.setParentEventBus(oracle.addClass(EventBusOk.class));
configuration.validateHistoryConverters();
}
use of com.mvp4g.rebind.config.element.HistoryConverterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testInjectedServiceRemove.
@Test
public void testInjectedServiceRemove() throws UnknownConfigurationElementException {
ServiceElement service1 = newService("service1");
ServiceElement service2 = newService("service2");
ServiceElement service3 = newService("service3");
ServiceElement service4 = newService("service4");
services.add(service1);
services.add(service2);
services.add(service3);
services.add(service4);
PresenterElement presenter = newPresenter(SimplePresenter01.class, "testPresenter");
presenter.getInjectedServices().add(new InjectedElement("service1", "setTestService"));
presenters.add(presenter);
HistoryConverterElement historyConverter = newHistoryConverter(SimpleHistoryConverter01.class, "testHistoryConverter");
historyConverter.getInjectedServices().add(new InjectedElement("service2", "setTestService"));
historyConverters.add(historyConverter);
EventHandlerElement eventHandlerElement = newEventHandler(SimpleEventHandler01.class, "testEventHandler");
eventHandlerElement.getInjectedServices().add(new InjectedElement("service3", "setTestService"));
eventHandlers.add(eventHandlerElement);
assertEquals(services.size(), 4);
assertTrue(services.contains(service1));
assertTrue(services.contains(service2));
assertTrue(services.contains(service3));
assertTrue(services.contains(service4));
configuration.validateServices();
assertEquals(services.size(), 3);
assertTrue(services.contains(service1));
assertTrue(services.contains(service2));
assertTrue(services.contains(service3));
assertFalse(services.contains(service4));
}
use of com.mvp4g.rebind.config.element.HistoryConverterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHistoryConverterWrongEventBus.
@Test(expected = InvalidTypeException.class)
public void testEventHistoryConverterWrongEventBus() throws InvalidMvp4gConfigurationException {
try {
HistoryConverterElement hc = new HistoryConverterElement();
hc.setName("testHistoryConverter");
Class<?> c = HistoryConverters.HistoryConverterWithLookup.class;
oracle.addClass(c);
hc.setClassName(c.getCanonicalName());
historyConverters.add(hc);
EventElement event = newEvent("testEvent");
event.setHistory("testHistoryConverter");
events.add(event);
EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
configuration.setEventBus(eventBus);
configuration.validateHistoryConverters();
fail();
} catch (InvalidTypeException e) {
assertTrue(e.getMessage().contains("Event Bus"));
throw e;
}
}
use of com.mvp4g.rebind.config.element.HistoryConverterElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testEventHistoryConverterWrongInterface.
@Test(expected = InvalidClassException.class)
public void testEventHistoryConverterWrongInterface() throws InvalidMvp4gConfigurationException {
HistoryConverterElement hc = new HistoryConverterElement();
hc.setName("testHistoryConverter");
hc.setClassName(Object.class.getName());
historyConverters.add(hc);
EventElement event = newEvent("testEvent");
event.setHistory("testHistoryConverter");
events.add(event);
setEventBus();
configuration.validateHistoryConverters();
}
Aggregations