Search in sources :

Example 1 with Presenter

use of com.github.mvp4g.mvp4g2.core.ui.annotation.Presenter in project mvp4g2 by mvp4g.

the class HandlerTest method testHandlerWithWrongImplementation02.

@Test
public void testHandlerWithWrongImplementation02() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/handlerWithWrongImplementation02/EventBusHandlerWithNotImplementedEvent.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/handlerWithWrongImplementation02/MockOneEventHandler.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/handlerWithWrongImplementation02/MockShellPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/handlerWithWrongImplementation02/IMockShellView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/handlerWithWrongImplementation02/MockShellView01.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("event >>doSomethingInHandler()<< is never handled by a presenter or handler");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 2 with Presenter

use of com.github.mvp4g.mvp4g2.core.ui.annotation.Presenter in project mvp4g2 by mvp4g.

the class PresenterTest method testPresenterAnnotationAnnotatedOnAInterface.

@Test
public void testPresenterAnnotationAnnotatedOnAInterface() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterAnnotationAnnotatedOnAInterface/PresenterAnnotationAnnotatedOnAInterface.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("@Presenter can only be used with a class");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 3 with Presenter

use of com.github.mvp4g.mvp4g2.core.ui.annotation.Presenter in project mvp4g2 by mvp4g.

the class PresenterTest method testPresenterAnnotationUsingViewClassAsInterface.

@Test
public void testPresenterAnnotationUsingViewClassAsInterface() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterAnnotationUsingViewClassAsInterface/PresenterAnnotationUsingViewClassAsInterface.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("the viewInterface-attribute of a @Presenter must be a interface!");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 4 with Presenter

use of com.github.mvp4g.mvp4g2.core.ui.annotation.Presenter in project mvp4g2 by mvp4g.

the class PresenterTest method testEventHandlerWithNotImplementedEvent.

@Test
public void testEventHandlerWithNotImplementedEvent() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithNotImplementedEvent/EventBusEventHandlerWithNotImplementedEvent.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithNotImplementedEvent/MockShellPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithNotImplementedEvent/IMockShellView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithNotImplementedEvent/MockShellView01.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("event >>doSomething()<< is never handled by a presenter or handler");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 5 with Presenter

use of com.github.mvp4g.mvp4g2.core.ui.annotation.Presenter in project mvp4g2 by mvp4g.

the class PresenterTest method testPresenterWithViewCreationMethodPresenter01.

// missng IsViewCerator-interface
@Test
public void testPresenterWithViewCreationMethodPresenter01() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/EventBusPresenterWithViewCreationMethodPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/MockShellPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/IMockShellView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/MockShellView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/MockPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/IMockView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/presenterWithViewCreationMethodPresenter01/MockView01.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("@Presenter must implement the IsViewCreator interface");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Aggregations

Mvp4g2Processor (com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor)16 Compilation (com.google.testing.compile.Compilation)16 JavaFileObject (javax.tools.JavaFileObject)16 Test (org.junit.Test)16 Presenter (com.github.mvp4g.mvp4g2.core.ui.annotation.Presenter)3 ProcessorException (com.github.mvp4g.mvp4g2.processor.ProcessorException)3 PresenterMetaModel (com.github.mvp4g.mvp4g2.processor.model.PresenterMetaModel)3 ClassNameModel (com.github.mvp4g.mvp4g2.processor.model.intern.ClassNameModel)3 TypeElement (javax.lang.model.element.TypeElement)3 IsShell (com.github.mvp4g.mvp4g2.core.ui.IsShell)2 HandlerMetaData (com.github.mvp4g.mvp4g2.core.internal.ui.HandlerMetaData)1 AbstractPresenter (com.github.mvp4g.mvp4g2.core.ui.AbstractPresenter)1 IsViewCreator (com.github.mvp4g.mvp4g2.core.ui.IsViewCreator)1 ProcessorUtils (com.github.mvp4g.mvp4g2.processor.ProcessorUtils)1 EventBusMetaModel (com.github.mvp4g.mvp4g2.processor.model.EventBusMetaModel)1 EventMetaModel (com.github.mvp4g.mvp4g2.processor.model.EventMetaModel)1 HandlerMetaModel (com.github.mvp4g.mvp4g2.processor.model.HandlerMetaModel)1 PresenterAnnotationValidator (com.github.mvp4g.mvp4g2.processor.scanner.validation.PresenterAnnotationValidator)1 ClassName (com.squareup.javapoet.ClassName)1 JavaFile (com.squareup.javapoet.JavaFile)1