Search in sources :

Example 1 with InvalidTypeException

use of com.mvp4g.rebind.exception.InvalidTypeException 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 2 with InvalidTypeException

use of com.mvp4g.rebind.exception.InvalidTypeException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testEventFiltersWrongEventBus.

@Test
public void testEventFiltersWrongEventBus() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    EventFilterElement filter = new EventFilterElement();
    oracle.addClass(EventFilters.EventFilter3.class);
    filter.setClassName(EventFilters.EventFilter3.class.getCanonicalName());
    eventFilters.add(filter);
    try {
        configuration.validateEventFilters();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
    }
}
Also used : 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) EventFilterElement(com.mvp4g.rebind.config.element.EventFilterElement) EventFilters(com.mvp4g.rebind.test_tools.annotation.EventFilters) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 3 with InvalidTypeException

use of com.mvp4g.rebind.exception.InvalidTypeException 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 InvalidTypeException

use of com.mvp4g.rebind.exception.InvalidTypeException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testGin01.

@Test
public void testGin01() throws InvalidMvp4gConfigurationException {
    GinModuleElement gin = new GinModuleElement();
    configuration.setGinModule(gin);
    try {
        configuration.validateGinModule();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertEquals(e.getMessage(), "You need to define at least one GIN module. If you don't want to specify a GIN module, don't override the GIN modules option to use the default Mvp4g GIN module.");
    }
    gin = new GinModuleElement();
    oracle.addClass(OneObject.class);
    gin.setModules(new String[] { OneObject.class.getCanonicalName() });
    configuration.setGinModule(gin);
    try {
        configuration.validateGinModule();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains(GinModule.class.getCanonicalName()));
    }
    String[] propertiesValues;
    gin = new GinModuleElement();
    oracle.addClass(DefaultMvp4gGinModule.class);
    gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
    configuration.setGinModule(gin);
    propertiesValues = configuration.validateGinModule();
    assertNull(propertiesValues);
    assertEquals(gin.getModules().size(), 1);
}
Also used : GinModuleElement(com.mvp4g.rebind.config.element.GinModuleElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) DefaultMvp4gGinModule(com.mvp4g.client.DefaultMvp4gGinModule) OneGinModule(com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule) DefaultMvp4gGinModule(com.mvp4g.client.DefaultMvp4gGinModule) GinModule(com.google.gwt.inject.client.GinModule) OneObject(com.mvp4g.rebind.test_tools.OneObject) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 5 with InvalidTypeException

use of com.mvp4g.rebind.exception.InvalidTypeException in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testDebug.

@Test
public void testDebug() throws NotFoundClassException, InvalidTypeException {
    DebugElement debug = new DebugElement();
    oracle.addClass(OneObject.class);
    debug.setLogger(OneObject.class.getCanonicalName());
    configuration.setDebug(debug);
    try {
        configuration.validateDebug();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains(Mvp4gLogger.class.getCanonicalName()));
    }
    debug = new DebugElement();
    oracle.addClass(DefaultMvp4gLogger.class);
    debug.setLogger(DefaultMvp4gLogger.class.getCanonicalName());
    configuration.setDebug(debug);
    configuration.validateDebug();
    configuration.setDebug(null);
    configuration.validateDebug();
}
Also used : DefaultMvp4gLogger(com.mvp4g.client.event.DefaultMvp4gLogger) DebugElement(com.mvp4g.rebind.config.element.DebugElement) Mvp4gLogger(com.mvp4g.client.event.Mvp4gLogger) DefaultMvp4gLogger(com.mvp4g.client.event.DefaultMvp4gLogger) OneObject(com.mvp4g.rebind.test_tools.OneObject) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Aggregations

InvalidTypeException (com.mvp4g.rebind.exception.InvalidTypeException)11 Test (org.junit.Test)11 BaseEventBus (com.mvp4g.client.event.BaseEventBus)5 EventBus (com.mvp4g.client.event.EventBus)5 EventBusElement (com.mvp4g.rebind.config.element.EventBusElement)5 EventElement (com.mvp4g.rebind.config.element.EventElement)5 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)4 GinModule (com.google.gwt.inject.client.GinModule)3 DefaultMvp4gGinModule (com.mvp4g.client.DefaultMvp4gGinModule)3 GinModuleElement (com.mvp4g.rebind.config.element.GinModuleElement)3 ViewElement (com.mvp4g.rebind.config.element.ViewElement)3 InvalidMvp4gConfigurationException (com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException)3 OneObject (com.mvp4g.rebind.test_tools.OneObject)3 OneGinModule (com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule)3 Loaders (com.mvp4g.rebind.test_tools.Loaders)2 DefaultMvp4gLogger (com.mvp4g.client.event.DefaultMvp4gLogger)1 Mvp4gLogger (com.mvp4g.client.event.Mvp4gLogger)1 ChildModuleElement (com.mvp4g.rebind.config.element.ChildModuleElement)1 DebugElement (com.mvp4g.rebind.config.element.DebugElement)1 EventFilterElement (com.mvp4g.rebind.config.element.EventFilterElement)1