Search in sources :

Example 6 with InvalidTypeException

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

the class Mvp4gConfigurationTest method testChildModuleLoadersIncompatibleType.

@Test
public void testChildModuleLoadersIncompatibleType() throws InvalidMvp4gConfigurationException {
    EventBusElement eventBus = new EventBusElement(EventBus.class.getName(), BaseEventBus.class.getName(), false);
    configuration.setEventBus(eventBus);
    oracle.addClass(Loaders.Loader1.class);
    oracle.addClass(Modules.ModuleWithLoader.class);
    ChildModuleElement withLoader = new ChildModuleElement();
    withLoader.setName("withLoader");
    withLoader.setClassName(Modules.ModuleWithLoader.class.getCanonicalName());
    childModules.add(withLoader);
    try {
        configuration.findChildModuleHistoryNameAndLoader();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("Can not convert " + EventBus.class.getCanonicalName()));
    }
}
Also used : Modules(com.mvp4g.rebind.test_tools.Modules) EventBusElement(com.mvp4g.rebind.config.element.EventBusElement) BaseEventBus(com.mvp4g.client.event.BaseEventBus) Loaders(com.mvp4g.rebind.test_tools.Loaders) EventBus(com.mvp4g.client.event.EventBus) BaseEventBus(com.mvp4g.client.event.BaseEventBus) ChildModuleElement(com.mvp4g.rebind.config.element.ChildModuleElement) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 7 with InvalidTypeException

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

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

the class Mvp4gConfigurationTest method testGinWithProperties.

@Test
public void testGinWithProperties() throws InvalidMvp4gConfigurationException {
    String[] propertiesValues;
    GinModuleElement gin = new GinModuleElement();
    oracle.addClass(DefaultMvp4gGinModule.class);
    gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
    gin.setModuleProperties(new String[] { PropertyOracleStub.PROPERTY_OK });
    configuration.setGinModule(gin);
    propertiesValues = configuration.validateGinModule();
    assertEquals(gin.getModules().size(), 2);
    assertEquals(gin.getModules().get(0), DefaultMvp4gGinModule.class.getCanonicalName());
    assertEquals(gin.getModules().get(1), DefaultMvp4gGinModule.class.getCanonicalName());
    assertEquals(1, propertiesValues.length);
    assertEquals(DefaultMvp4gGinModule.class.getCanonicalName(), propertiesValues[0]);
    gin = new GinModuleElement();
    oracle.addClass(OneGinModule.class);
    gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
    gin.setModuleProperties(new String[] { PropertyOracleStub.PROPERTY_OK, PropertyOracleStub.PROPERTY_OK2 });
    configuration.setGinModule(gin);
    propertiesValues = configuration.validateGinModule();
    assertEquals(gin.getModules().size(), 3);
    assertEquals(gin.getModules().get(0), DefaultMvp4gGinModule.class.getCanonicalName());
    assertEquals(gin.getModules().get(1), DefaultMvp4gGinModule.class.getCanonicalName());
    assertEquals(gin.getModules().get(2), OneGinModule.class.getCanonicalName());
    assertEquals(2, propertiesValues.length);
    assertEquals(DefaultMvp4gGinModule.class.getCanonicalName(), propertiesValues[0]);
    assertEquals(OneGinModule.class.getCanonicalName(), propertiesValues[1]);
    gin = new GinModuleElement();
    gin.setModuleProperties(new String[] { "unknown" });
    configuration.setGinModule(gin);
    try {
        configuration.validateGinModule();
        fail();
    } catch (InvalidMvp4gConfigurationException e) {
        assertTrue(e.getMessage().contains("couldn't find a value for the GIN module property unknown"));
    }
    gin = new GinModuleElement();
    oracle.addClass(String.class);
    gin.setModuleProperties(new String[] { PropertyOracleStub.PROPERTY_NOT_GIN_MODULE });
    configuration.setGinModule(gin);
    try {
        configuration.validateGinModule();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains(GinModule.class.getCanonicalName()));
    }
}
Also used : GinModuleElement(com.mvp4g.rebind.config.element.GinModuleElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) OneGinModule(com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule) 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) InvalidTypeException(com.mvp4g.rebind.exception.InvalidTypeException) Test(org.junit.Test)

Example 9 with InvalidTypeException

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

the class Mvp4gConfigurationTest method testGin02.

@Test
public void testGin02() 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);
    oracle.addClass(OneGinModule.class);
    gin.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName(), OneGinModule.class.getCanonicalName() });
    configuration.setGinModule(gin);
    propertiesValues = configuration.validateGinModule();
    assertNull(propertiesValues);
    assertEquals(gin.getModules().size(), 2);
}
Also used : GinModuleElement(com.mvp4g.rebind.config.element.GinModuleElement) InvalidMvp4gConfigurationException(com.mvp4g.rebind.exception.InvalidMvp4gConfigurationException) OneGinModule(com.mvp4g.rebind.test_tools.annotation.gin.OneGinModule) 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 10 with InvalidTypeException

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

the class Mvp4gConfigurationTest method testEventHandlerValidationInvalidView.

@Test
public void testEventHandlerValidationInvalidView() throws InvalidMvp4gConfigurationException {
    ViewElement view = newView(SimpleView02.class, "view");
    view.setClassName(Integer.class.getName());
    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);
    try {
        setEventBus();
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("View"));
    }
    presenter.setMultiple(Boolean.TRUE.toString());
    try {
        setEventBus();
        configuration.validateEventHandlers();
        fail();
    } catch (InvalidTypeException e) {
        assertTrue(e.getMessage().contains("View"));
    }
}
Also used : EventElement(com.mvp4g.rebind.config.element.EventElement) ViewElement(com.mvp4g.rebind.config.element.ViewElement) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) 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