Search in sources :

Example 1 with ViewElement

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

the class PresenterAnnotationsLoaderTest method testViewWithName.

@Test
public void testViewWithName() throws Mvp4gAnnotationException {
    List<JClassType> annotedClasses = new ArrayList<JClassType>();
    JClassType type = oracle.addClass(Presenters.PresenterWithViewName.class);
    annotedClasses.add(type);
    loader.load(annotedClasses, configuration);
    ViewElement view = configuration.getViews().iterator().next();
    assertEquals(view.getClassName(), Object.class.getName());
    assertEquals(view.getName(), "name");
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) ArrayList(java.util.ArrayList) ViewElement(com.mvp4g.rebind.config.element.ViewElement) Test(org.junit.Test)

Example 2 with ViewElement

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

the class Mvp4gConfigurationTest method testEventHandlerValidationInvalidEventBus.

@Test
public void testEventHandlerValidationInvalidEventBus() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleView02.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    presenter.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    events.clear();
    configuration.validateEventHandlers();
    assertTrue(presenters.size() == 0);
    EventHandlerElement eventHandler = newEventHandler(SimpleEventHandler01.class, "testHandler");
    eventHandlers.add(eventHandler);
    events.add(event);
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    eventHandler.setMultiple(Boolean.TRUE.toString());
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Event Bus"));
    }
    events.clear();
    configuration.validateEventHandlers();
    assertTrue(eventHandlers.size() == 0);
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) EventHandlerElement(com.mvp4g.rebind.config.element.EventHandlerElement) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 3 with ViewElement

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

the class Mvp4gConfigurationTest method testEventHandlerWrongInjectedView.

@Test
public void testEventHandlerWrongInjectedView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleInjectedView.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(Presenters.MultiplePresenter.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    try {
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertEquals("view view: Invalid Presenter. Can not convert com.mvp4g.rebind.test_tools.annotation.Presenters.MultiplePresenter to com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01", e.getMessage());
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) Presenters(com.mvp4g.rebind.test_tools.annotation.Presenters) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 4 with ViewElement

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

the class Mvp4gConfigurationTest method newView.

private ViewElement newView(Class<?> c, String name) {
    ViewElement view = new ViewElement();
    view.setName(name);
    oracle.addClass(c);
    view.setClassName(c.getCanonicalName());
    return view;
}
Also used : ViewElement(com.mvp4g.rebind.config.element.ViewElement)

Example 5 with ViewElement

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

the class Mvp4gConfigurationTest method testEventHandlerValidationSucceedsWithInjectedView.

@Test
public void testEventHandlerValidationSucceedsWithInjectedView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleInjectedView.class, "view");
    views.add(view);
    PresenterElement presenter = newPresenter(SimplePresenter01.class, "testHandler");
    presenter.setView("view");
    presenters.add(presenter);
    EventElement event = newEvent("testEvent");
    event.setHandlers(new String[] { "testHandler" });
    events.add(event);
    setEventBus();
    configuration.validateEventHandlers();
    assertTrue(presenter.hasInverseView());
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Aggregations

ViewElement (com.mvp4g.rebind.config.element.ViewElement)17 Test (org.junit.Test)15 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)14 EventElement (com.mvp4g.rebind.config.element.EventElement)12 EventHandlerElement (com.mvp4g.rebind.config.element.EventHandlerElement)4 Presenters (com.mvp4g.rebind.test_tools.annotation.Presenters)4 BaseEventBus (com.mvp4g.client.event.BaseEventBus)3 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)3 InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)3 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)2 EventBusWithLookup (com.mvp4g.client.event.EventBusWithLookup)2 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)2 TestBroadcast (com.mvp4g.rebind.test_tools.annotation.TestBroadcast)2 SimpleView02 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView02)2 ArrayList (java.util.ArrayList)2 EventBus (com.mvp4g.client.event.EventBus)1 OneObject (com.mvp4g.rebind.test_tools.OneObject)1 TestBroadcast2 (com.mvp4g.rebind.test_tools.annotation.TestBroadcast2)1 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)1 SimpleView03 (com.mvp4g.rebind.test_tools.annotation.views.SimpleView03)1