Search in sources :

Example 1 with HistoryConverterElement

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());
}
Also used : HistoryElement(com.mvp4g.rebind.config.element.HistoryElement) HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) Modules(com.mvp4g.rebind.test_tools.Modules) Test(org.junit.Test)

Example 2 with HistoryConverterElement

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();
}
Also used : HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) EventElement(com.mvp4g.rebind.config.element.EventElement) EventBusOk(com.mvp4g.rebind.test_tools.annotation.events.EventBusOk) Test(org.junit.Test)

Example 3 with HistoryConverterElement

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));
}
Also used : HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) InjectedElement(com.mvp4g.rebind.config.element.InjectedElement) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) ServiceElement(com.mvp4g.rebind.config.element.ServiceElement) Test(org.junit.Test)

Example 4 with HistoryConverterElement

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;
    }
}
Also used : HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) EventElement(com.mvp4g.rebind.config.element.EventElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 5 with HistoryConverterElement

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();
}
Also used : HistoryConverterElement(com.mvp4g.rebind.config.element.HistoryConverterElement) EventElement(com.mvp4g.rebind.config.element.EventElement) OneObject(com.mvp4g.rebind.test_tools.OneObject) Test(org.junit.Test)

Aggregations

HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)14 Test (org.junit.Test)12 EventElement (com.mvp4g.rebind.config.element.EventElement)4 InjectedElement (com.mvp4g.rebind.config.element.InjectedElement)3 BaseEventBus (com.mvp4g.client.event.BaseEventBus)2 EventBus (com.mvp4g.client.event.EventBus)2 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)2 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)2 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)2 Modules (com.mvp4g.rebind.test_tools.Modules)2 ClearHistory (com.mvp4g.client.history.ClearHistory)1 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)1 HistoryElement (com.mvp4g.rebind.config.element.HistoryElement)1 ServiceElement (com.mvp4g.rebind.config.element.ServiceElement)1 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)1 OneObject (com.mvp4g.rebind.test_tools.OneObject)1 EventBusOk (com.mvp4g.rebind.test_tools.annotation.events.EventBusOk)1 SimpleHistoryConverter01 (com.mvp4g.rebind.test_tools.annotation.history_converters.SimpleHistoryConverter01)1 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)1 SimpleView02 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView02)1