Search in sources :

Example 21 with Mvp4gAnnotationException

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

the class EventsAnnotationsLoaderTest method testDoubleErrorLoadChild.

@Test(expected = Mvp4gAnnotationException.class)
public void testDoubleErrorLoadChild() 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.EventBusDoubleError.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("Duplicate value for Error 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 22 with Mvp4gAnnotationException

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

the class EventsAnnotationsLoaderTest method testDoubleBeforeLoadChild.

@Test(expected = Mvp4gAnnotationException.class)
public void testDoubleBeforeLoadChild() 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.EventBusDoubleBefore.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("Duplicate value for Before 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 23 with Mvp4gAnnotationException

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

the class EventsAnnotationsLoaderTest method testSameEvent.

@Test(expected = Mvp4gAnnotationException.class)
public void testSameEvent() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        annotedClasses.add(oracle.addClass(SimplePresenter01.class));
        new PresenterAnnotationsLoader().load(annotedClasses, configuration);
        annotedClasses.clear();
        JClassType type = oracle.addClass(Events.EventBusWithSameMethod.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("Duplicate"));
        throw e;
    }
}
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) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 24 with Mvp4gAnnotationException

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

the class EventsAnnotationsLoaderTest method testEventNoAnnotation.

@Test(expected = Mvp4gAnnotationException.class)
public void testEventNoAnnotation() throws Mvp4gAnnotationException {
    try {
        List<JClassType> annotedClasses = new ArrayList<JClassType>();
        annotedClasses.add(oracle.addClass(SimplePresenter01.class));
        new PresenterAnnotationsLoader().load(annotedClasses, configuration);
        annotedClasses.clear();
        JClassType type = oracle.addClass(Events.EventBusWithMethodAndNoAnnotation.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("annotation missing."));
        throw e;
    }
}
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) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Test(org.junit.Test)

Example 25 with Mvp4gAnnotationException

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

the class EventsAnnotationsLoaderTest method testUnknownModuleForLoadModuleViewEvent.

@Test(expected = Mvp4gAnnotationException.class)
public void testUnknownModuleForLoadModuleViewEvent() 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.EventBusUnknownModuleForLoadModuleViewEvent.class);
        annotedClasses.add(type);
        loader.load(annotedClasses, configuration);
    } catch (Mvp4gAnnotationException e) {
        assertTrue(e.getMessage().contains("No instance of " + Modules.ModuleWithParent01.class.getCanonicalName() + " is defined."));
        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)

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