Search in sources :

Example 11 with PresenterElement

use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testInjectedServiceValidationFailsForPresenter.

@Test(expected = UnknownConfigurationElementException.class)
public void testInjectedServiceValidationFailsForPresenter() throws UnknownConfigurationElementException, InvalidTypeException, InvalidClassException, NotFoundClassException {
    events.add(newEvent("badService"));
    views.add(newView(SimpleView02.class, "badService"));
    presenters.add(newPresenter(SimplePresenter01.class, "badService"));
    historyConverters.add(newHistoryConverter(SimpleHistoryConverter01.class, "badService"));
    PresenterElement presenter = newPresenter(SimplePresenter02.class, "testPresenter");
    presenter.getInjectedServices().add(new InjectedElement("badService", "setBadService"));
    presenters.add(presenter);
    configuration.validateServices();
}
Also used : SimpleView02(com.mvp4g.rebind.test_tools.annotation.views.SimpleView02) InjectedElement(com.mvp4g.rebind.config.element.InjectedElement) SimpleHistoryConverter01(com.mvp4g.rebind.test_tools.annotation.history_converters.SimpleHistoryConverter01) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 12 with PresenterElement

use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method newPresenter.

private PresenterElement newPresenter(Class<? extends BaseEventHandler<? extends EventBus>> c, String name) {
    PresenterElement presenter = new PresenterElement();
    presenter.setName(name);
    oracle.addClass(c);
    presenter.setClassName(c.getCanonicalName());
    return presenter;
}
Also used : PresenterElement(com.mvp4g.rebind.config.element.PresenterElement)

Example 13 with PresenterElement

use of com.mvp4g.rebind.config.element.PresenterElement in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testBroadcastHandlers.

@Test
public void testBroadcastHandlers() throws InvalidMvp4gConfigurationException {
    oracle.addClass(TestBroadcast.class);
    ViewElement view = newView(SimpleView01.class, "view");
    views.add(view);
    PresenterElement presenter = new PresenterElement();
    presenter.setName("presenter");
    Class<?> c = Presenters.BroadcastPresenter.class;
    presenter.setClassName(c.getCanonicalName());
    oracle.addClass(c);
    presenter.setView("view");
    presenters.add(presenter);
    PresenterElement presenter2 = new PresenterElement();
    presenter2.setName("presenter2");
    c = Presenters.BroadcastPresenter2.class;
    presenter2.setClassName(c.getCanonicalName());
    oracle.addClass(c);
    presenter2.setView("view");
    presenters.add(presenter2);
    PresenterElement presenter3 = new PresenterElement();
    presenter3.setName("presenter3");
    c = Presenters.BroadcastPresenter2.class;
    presenter3.setClassName(c.getCanonicalName());
    presenter3.setView("view");
    presenters.add(presenter3);
    EventElement event = newEvent("event");
    event.setBroadcastTo(TestBroadcast.class.getCanonicalName());
    event.setHandlers(new String[0]);
    events.add(event);
    EventElement event2 = newEvent("event2");
    event2.setBroadcastTo(TestBroadcast2.class.getCanonicalName());
    event2.setHandlers(new String[] { "presenter3" });
    events.add(event2);
    setEventBus();
    configuration.validateEventHandlers();
    List<String> handlers = event.getHandlers();
    assertEquals(3, handlers.size());
    assertEquals("presenter3", handlers.get(0));
    assertEquals("presenter2", handlers.get(1));
    assertEquals("presenter", handlers.get(2));
    handlers = event2.getHandlers();
    assertEquals(2, handlers.size());
    assertEquals("presenter3", handlers.get(0));
    assertEquals("presenter2", handlers.get(1));
}
Also used : TestBroadcast2(com.mvp4g.rebind.test_tools.annotation.TestBroadcast2) EventElement(com.mvp4g.rebind.config.element.EventElement) TestBroadcast(com.mvp4g.rebind.test_tools.annotation.TestBroadcast) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 14 with PresenterElement

use of com.mvp4g.rebind.config.element.PresenterElement 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 15 with PresenterElement

use of com.mvp4g.rebind.config.element.PresenterElement 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());
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) EventBusWithLookup(com.mvp4g.client.event.EventBusWithLookup) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Aggregations

PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)34 Test (org.junit.Test)32 EventElement (com.mvp4g.rebind.config.element.EventElement)22 ViewElement (com.mvp4g.rebind.config.element.ViewElement)14 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)11 BaseEventBus (com.mvp4g.client.event.BaseEventBus)8 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)8 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)7 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)4 SimpleView02 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView02)4 EventBus (com.mvp4g.client.event.EventBus)3 InjectedElement (com.mvp4g.rebind.config.element.InjectedElement)3 SplitterElement (com.mvp4g.rebind.config.element.SplitterElement)3 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)3 Splitters (com.mvp4g.rebind.test_tools.Splitters)3 Presenters (com.mvp4g.rebind.test_tools.annotation.Presenters)3 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)3 PresenterInterface (com.mvp4g.client.presenter.PresenterInterface)2 EventAssociation (com.mvp4g.rebind.config.element.EventAssociation)2 HistoryConverterElement (com.mvp4g.rebind.config.element.HistoryConverterElement)2