Search in sources :

Example 6 with Mvp4gAnnotationException

use of com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testStartWrongViewClass.

@Test(expected = Mvp4gAnnotationException.class)
public void testStartWrongViewClass() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        annotedClasses.add(oracle.addClass(PresenterWithName.class));
        new PresenterAnnotationsLoader().load(annotedClasses, configuration);
        annotedClasses.clear();
        JClassType type = oracle.addClass(Events.EventBusWithStartNameAndWrongClass.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("There is no instance with name"));
        assertTrue(e.getMessage().contains("that extends"));
        throw e;
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) Events(com.mvp4g.rebind.test_tools.annotation.Events) Mvp4gAnnotationException(com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException) Test(org.junit.Test)

Example 7 with Mvp4gAnnotationException

use of com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testDoubleNotFoundHistory.

@Test(expected = Mvp4gAnnotationException.class)
public void testDoubleNotFoundHistory() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        annotedClasses.add(oracle.addClass(PresenterWithName.class));
        new PresenterAnnotationsLoader().load(annotedClasses, configuration);
        annotedClasses.clear();
        JClassType type = oracle.addClass(Events.EventBusDoubleNotFoundHistory.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("Duplicate value for Not Found History event. It is already defined by another method or in your configuration file."));
        throw e;
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) Events(com.mvp4g.rebind.test_tools.annotation.Events) Mvp4gAnnotationException(com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException) Test(org.junit.Test)

Example 8 with Mvp4gAnnotationException

use of com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testOtherEventBus.

@Test
public void testOtherEventBus() {
    try {
        configuration.setEventBus(new EventBusElement(Object.class.getName(), BaseEventBus.class.getName(), false));
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        JClassType type = oracle.addClass(Events.SimpleEventBus.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
        fail();
    } catch (Mvp4gAnnotationException e) {
        assertEquals(e.getMessage(), Events.SimpleEventBus.class.getCanonicalName() + ": You can define only one event bus by Mvp4g module. Do you already have another EventBus interface for the module " + Mvp4gModule.class.getCanonicalName() + "?");
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Events(com.mvp4g.rebind.test_tools.annotation.Events) Mvp4gAnnotationException(com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException) Test(org.junit.Test)

Example 9 with Mvp4gAnnotationException

use of com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testDoubleAfterLoadChild.

@Test(expected = Mvp4gAnnotationException.class)
public void testDoubleAfterLoadChild() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        annotedClasses.add(oracle.addClass(PresenterWithName.class));
        new PresenterAnnotationsLoader().load(annotedClasses, configuration);
        annotedClasses.clear();
        JClassType type = oracle.addClass(Events.EventBusDoubleAfter.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("Duplicate value for After Load Child event. It is already defined by another method or in your configuration file."));
        throw e;
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) PresenterWithName(com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName) Events(com.mvp4g.rebind.test_tools.annotation.Events) Mvp4gAnnotationException(com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException) Test(org.junit.Test)

Example 10 with Mvp4gAnnotationException

use of com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException in project mvp4g by mvp4g.

the class EventsAnnotationsLoaderTest method testEventBusWithSameChild.

@Test(expected = Mvp4gAnnotationException.class)
public void testEventBusWithSameChild() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        JClassType type = oracle.addClass(Events.EventBusWithSameChild.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("You can't have two child modules describing the same module: " + Modules.Module01.class.getCanonicalName()));
        throw e;
    }
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) Events(com.mvp4g.rebind.test_tools.annotation.Events) Modules(com.mvp4g.rebind.test_tools.Modules) ChildModules(com.mvp4g.client.annotation.module.ChildModules) Mvp4gAnnotationException(com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException) Test(org.junit.Test)

Aggregations

Mvp4gAnnotationException (com.mvp4g.rebind.exception.loader.Mvp4gAnnotationException)29 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)26 Test (org.junit.Test)25 Events (com.mvp4g.rebind.test_tools.annotation.Events)17 PresenterWithName (com.mvp4g.rebind.test_tools.annotation.presenters.PresenterWithName)12 ArrayList (java.util.ArrayList)5 JMethod (com.google.gwt.core.ext.typeinfo.JMethod)2 JParameter (com.google.gwt.core.ext.typeinfo.JParameter)2 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)2 TypeOracle (com.google.gwt.core.ext.typeinfo.TypeOracle)1 InjectService (com.mvp4g.client.annotation.InjectService)1 ChildModules (com.mvp4g.client.annotation.module.ChildModules)1 NoStartPresenter (com.mvp4g.client.presenter.NoStartPresenter)1 InjectedElement (com.mvp4g.rebind.config.element.InjectedElement)1 Mvp4gWithServicesElement (com.mvp4g.rebind.config.element.Mvp4gWithServicesElement)1 Modules (com.mvp4g.rebind.test_tools.Modules)1 EventHandlers (com.mvp4g.rebind.test_tools.annotation.EventHandlers)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1