Search in sources :

Example 6 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2 by mvp4g.

the class StartEventTest method testStartEventTestEventBusWithOneStartAnnotation.

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

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/StartEventTestEventBusWithOneStartAnnotation.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/MockShellPresenter.java"));
        }
    });
    CompilationSubject.assertThat(compilation).succeeded();
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/StartEventTestEventBusWithOneStartAnnotationImpl.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/StartEventTestEventBusWithOneStartAnnotationImpl.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/Com_github_mvp4g_mvp4g2_processor_event_startEventTestEventBusWithOneStartAnnotation_MockShellPresenterMetaData.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/Com_github_mvp4g_mvp4g2_processor_event_startEventTestEventBusWithOneStartAnnotation_MockShellPresenterMetaData.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/Com_github_mvp4g_mvp4g2_processor_event_startEventTestEventBusWithOneStartAnnotation_StartEventTestEventBusWithOneStartAnnotation_start.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithOneStartAnnotation/Com_github_mvp4g_mvp4g2_processor_event_startEventTestEventBusWithOneStartAnnotation_StartEventTestEventBusWithOneStartAnnotation_start.java"));
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 7 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2 by mvp4g.

the class EventbusTest method testStartEventTestEventBusWithMoreThanOneStartAnnotation.

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

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestEventBusWithMoreThanOneStartAnnotation/StartEventTestEventBusWithMoreThanOneStartAnnotation.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("@Start-annotation can only be used a single time in a eventbus 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 8 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2 by mvp4g.

the class EventbusTest method testStartEventTestWithNonZeroArgumentMethod.

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

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/startEventTestWithNonZeroArgumentMethod/StartEventTestWithNonZeroArgumentMethod.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("@Start-annotation can only be used on zero argument methods");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 9 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event 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 10 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event 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)

Aggregations

Mvp4g2Processor (com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor)25 Compilation (com.google.testing.compile.Compilation)25 JavaFileObject (javax.tools.JavaFileObject)25 Test (org.junit.Test)25 TypeElement (javax.lang.model.element.TypeElement)5 LazyReverseView (com.github.mvp4g.mvp4g2.core.ui.LazyReverseView)4 ProcessorException (com.github.mvp4g.mvp4g2.processor.ProcessorException)4 Element (elemental2.dom.Element)4 HTMLButtonElement (elemental2.dom.HTMLButtonElement)4 HTMLDivElement (elemental2.dom.HTMLDivElement)4 Elements.button (org.jboss.gwt.elemento.core.Elements.button)4 Elements.div (org.jboss.gwt.elemento.core.Elements.div)4 EventType.click (org.jboss.gwt.elemento.core.EventType.click)4 Element (javax.lang.model.element.Element)3 ExecutableElement (javax.lang.model.element.ExecutableElement)3 Event (com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event)2 InitHistory (com.github.mvp4g.mvp4g2.core.history.annotation.InitHistory)2 NotFoundHistory (com.github.mvp4g.mvp4g2.core.history.annotation.NotFoundHistory)2 EventBusMetaModel (com.github.mvp4g.mvp4g2.processor.model.EventBusMetaModel)2 EventMetaModel (com.github.mvp4g.mvp4g2.processor.model.EventMetaModel)2