Search in sources :

Example 31 with PresenterElement

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

the class Mvp4gConfigurationTest method testActivateDeActivateUseless.

@Test
public void testActivateDeActivateUseless() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBusWithLookup.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    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() == 0);
    List<String> deactivate = event1.getDeactivate();
    assertTrue(deactivate.size() == 0);
}
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)

Example 32 with PresenterElement

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

the class PresenterAnnotationsLoader method loadHandler.

@Override
protected PresenterElement loadHandler(JClassType c, Presenter annotation, Mvp4gConfiguration configuration) throws Mvp4gAnnotationException {
    String className = c.getQualifiedSourceName();
    String viewName = buildElementNameIfNeeded(annotation.viewName(), className, "View");
    PresenterElement presenter = new PresenterElement();
    presenter.setView(viewName);
    ViewElement view = new ViewElement();
    view.setClassName(annotation.view().getCanonicalName());
    view.setName(viewName);
    addElement(configuration.getViews(), view, c, null);
    return presenter;
}
Also used : ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement)

Example 33 with PresenterElement

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

the class TestExceptions method testInvalidTypeException.

@Test
public void testInvalidTypeException() {
    PresenterElement p = new PresenterElement();
    p.setName("name");
    p.setClassName("com.test.Presenter");
    InvalidTypeException e = new InvalidTypeException(p, "Event Bus", EventBus.class.getName(), EventBusWithLookup.class.getName());
    assertEquals("presenter name: Invalid Event Bus. Can not convert " + EventBus.class.getName() + " to " + EventBusWithLookup.class.getName(), e.getMessage());
}
Also used : EventBusWithLookup(com.mvp4g.client.event.EventBusWithLookup) EventBus(com.mvp4g.client.event.EventBus) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Example 34 with PresenterElement

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

the class TestExceptions method testNotFoundClassException.

@Test
public void testNotFoundClassException() {
    PresenterElement p = new PresenterElement();
    p.setName("name");
    p.setClassName("com.test.Presenter");
    NotFoundClassException e = new NotFoundClassException(null, PresenterInterface.class.getName());
    assertEquals("No source code is available for " + PresenterInterface.class.getName(), e.getMessage());
    e = new NotFoundClassException(p, PresenterInterface.class.getName());
    assertEquals("presenter name: No source code is available for " + PresenterInterface.class.getName(), e.getMessage());
}
Also used : PresenterInterface(com.mvp4g.client.presenter.PresenterInterface) 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