ClusterEventObserver { public void broadcast(Object event) { if (!getClusterService().isAppFormerClustered()) { return; } ClusterSerializedCDIMessageWrapper wrapper = new ClusterSerializedCDIMessageWrapper(nodeId, toJSON(event), event.getClass().getName()); getClusterService().broadcast(ClusterService.DestinationType.PubSub, CHANNEL_NAME, wrapper); } 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 shouldBroadCastMessagesOnlyOnCluster() { when(clusterService.isAppFormerClustered()).thenReturn(false); observer.broadcast(new Object()); verify(clusterService, never()).broadcast(any(), any(), any()); }
@Test public void shouldBroadCastMessages() { when(clusterService.isAppFormerClustered()).thenReturn(true); observer.broadcast(new EventTest()); verify(clusterService).broadcast(any(), any(), any()); }