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"));
}
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"));
}
Aggregations