ClusterEventObserver { boolean shouldObserveThisEvent(Object event, EventMetadata metaData) { return event.getClass().isAnnotationPresent(Clustered.class) && !createdOnThisClass(metaData); } ClusterEventObserver(); @Inject  ClusterEventObserver(Event<Object> eventBus); @PreDestroy void shutdown(); void observeAllEvents(@Observes(notifyObserver = Reception.IF_EXISTS) Object event,
                                 EventMetadata metaData); void broadcast(Object event); static final String CHANNEL_NAME; }
@Test public void shouldObserveThisEventTest() { EventMetadata eventMetadataMock = mock(EventMetadata.class); InjectionPoint injectionPointMock = mock(InjectionPoint.class); Bean beanMock = mock(Bean.class); when(eventMetadataMock.getInjectionPoint()).thenReturn(injectionPointMock); when(injectionPointMock.getBean()).thenReturn(beanMock); assertFalse(observer.shouldObserveThisEvent(new Object(), null)); assertTrue(observer.shouldObserveThisEvent(new EventTest(), null)); when(beanMock.getBeanClass()).thenReturn(Object.class); assertTrue(observer.shouldObserveThisEvent(new EventTest(), eventMetadataMock)); when(beanMock.getBeanClass()).thenReturn(observer.getClass()); assertFalse(observer.shouldObserveThisEvent(new EventTest(), eventMetadataMock)); when(eventMetadataMock.getInjectionPoint()).thenReturn(null); assertTrue(observer.shouldObserveThisEvent(new EventTest(), eventMetadataMock)); }