Search in sources :

Example 1 with Started

use of io.micronaut.coherence.annotation.Started in project micronaut-coherence by micronaut-projects.

the class EventObserverSupportTest method testCreateObserverForSessionLifecycleEvent.

@Test
void testCreateObserverForSessionLifecycleEvent() {
    ExecutableMethodEventObserver observer = mock(ExecutableMethodEventObserver.class);
    @Starting
    @Started
    @Stopping
    @Stopped
    @Name("test")
    @SessionName("test")
    final class c {
    }
    Starting starting = c.class.getAnnotation(Starting.class);
    Started started = c.class.getAnnotation(Started.class);
    Stopping stopping = c.class.getAnnotation(Stopping.class);
    Stopped stopped = c.class.getAnnotation(Stopped.class);
    Name name = c.class.getAnnotation(Name.class);
    SessionName sessionName = c.class.getAnnotation(SessionName.class);
    Set<java.lang.annotation.Annotation> value = new java.util.HashSet<>();
    value.add(starting);
    value.add(started);
    value.add(stopping);
    value.add(stopped);
    value.add(name);
    value.add(sessionName);
    when(observer.getObservedQualifiers()).thenReturn(value);
    EventObserverSupport.EventHandler handler = EventObserverSupport.createObserver(SessionLifecycleEvent.class, observer);
    EnumSet<?> actual = handler.eventTypes();
    EnumSet<?> expected = EnumSet.allOf(SessionLifecycleEvent.Type.class);
    assertThat(actual, is(expected));
    assertThat(((EventObserverSupport.SessionLifecycleEventHandler) handler).name, is("test"));
}
Also used : Started(io.micronaut.coherence.annotation.Started) Stopped(io.micronaut.coherence.annotation.Stopped) SessionLifecycleEvent(com.tangosol.net.events.SessionLifecycleEvent) Stopping(io.micronaut.coherence.annotation.Stopping) SessionName(io.micronaut.coherence.annotation.SessionName) SessionName(io.micronaut.coherence.annotation.SessionName) Name(io.micronaut.coherence.annotation.Name) Starting(io.micronaut.coherence.annotation.Starting) Test(org.junit.jupiter.api.Test)

Example 2 with Started

use of io.micronaut.coherence.annotation.Started in project micronaut-coherence by micronaut-projects.

the class EventObserverSupportTest method testCreateObserverForCoherenceLifecycleEvent.

@Test
void testCreateObserverForCoherenceLifecycleEvent() {
    ExecutableMethodEventObserver observer = mock(ExecutableMethodEventObserver.class);
    @Starting
    @Started
    @Stopping
    @Stopped
    @Name("test")
    final class c {
    }
    Starting starting = c.class.getAnnotation(Starting.class);
    Started started = c.class.getAnnotation(Started.class);
    Stopping stopping = c.class.getAnnotation(Stopping.class);
    Stopped stopped = c.class.getAnnotation(Stopped.class);
    Name name = c.class.getAnnotation(Name.class);
    Set<java.lang.annotation.Annotation> value = new java.util.HashSet<>();
    value.add(starting);
    value.add(started);
    value.add(stopping);
    value.add(stopped);
    value.add(name);
    when(observer.getObservedQualifiers()).thenReturn(value);
    EventObserverSupport.EventHandler handler = EventObserverSupport.createObserver(CoherenceLifecycleEvent.class, observer);
    EnumSet<?> actual = handler.eventTypes();
    EnumSet<?> expected = EnumSet.allOf(CoherenceLifecycleEvent.Type.class);
    assertThat(actual, is(expected));
    assertThat(((EventObserverSupport.CoherenceLifecycleEventHandler) handler).name, is("test"));
}
Also used : Started(io.micronaut.coherence.annotation.Started) Stopped(io.micronaut.coherence.annotation.Stopped) CoherenceLifecycleEvent(com.tangosol.net.events.CoherenceLifecycleEvent) Stopping(io.micronaut.coherence.annotation.Stopping) SessionName(io.micronaut.coherence.annotation.SessionName) Name(io.micronaut.coherence.annotation.Name) Starting(io.micronaut.coherence.annotation.Starting) Test(org.junit.jupiter.api.Test)

Aggregations

Name (io.micronaut.coherence.annotation.Name)2 SessionName (io.micronaut.coherence.annotation.SessionName)2 Started (io.micronaut.coherence.annotation.Started)2 Starting (io.micronaut.coherence.annotation.Starting)2 Stopped (io.micronaut.coherence.annotation.Stopped)2 Stopping (io.micronaut.coherence.annotation.Stopping)2 Test (org.junit.jupiter.api.Test)2 CoherenceLifecycleEvent (com.tangosol.net.events.CoherenceLifecycleEvent)1 SessionLifecycleEvent (com.tangosol.net.events.SessionLifecycleEvent)1