@Override public NotificationService getNotificationService() { return WebSocketNotificationService.getInstance(); } }
@Override public void notify(final ServerInstanceDeleted serverInstanceDeleted) { LOGGER.info("WebSocket notify on instance deleted :: {}", serverInstanceDeleted); notifySessions(serverInstanceDeleted); }
private void notifySessions(final KieServerControllerEvent event) { final KieServerControllerNotification notification = new KieServerControllerNotification(event); LOGGER.debug("Sending notification to all Web Socket sessions"); manager.broadcastObject(notification); }
@Test public void testSessionCleanUp() { manager.addSession(session); assertTrue(manager.getExecutorsBySession().containsKey(session)); manager.removeSession(session); assertFalse(manager.getExecutorsBySession().containsKey(session)); }
@Test public void testBroadcast() throws Exception { final RemoteEndpoint.Basic endpoint = mock(RemoteEndpoint.Basic.class); when(session.getBasicRemote()).thenReturn(endpoint); when(session.isOpen()).thenReturn(true); manager.addSession(session); final KieServerControllerNotification notification = new KieServerControllerNotification(); manager.broadcastObject(notification); verify(endpoint, timeout(TIMEOUT)).sendObject(notification); }
@Before public void setUp() { when(session.getId()).thenReturn("id"); when(session.getBasicRemote()).thenReturn(endpoint); when(session.isOpen()).thenReturn(true); WebSocketNotificationSessionManager.getInstance().addSession(session); }
@Test public void testServerInstanceDisconnected() throws Exception { final ServerInstanceDisconnected event = new ServerInstanceDisconnected("serverId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@OnOpen public void onNotificationClientConnect(final Session session) { LOGGER.debug("New Web Socket Notification Client session: {}", session.getId()); manager.addSession(session); }
@OnClose public void onNotificationClientDisconnect(final Session session, final CloseReason closeReason) { LOGGER.debug("Web Socket Notification Client session: {}, disconnected, reason: {}", session.getId(), closeReason); manager.removeSession(session); }
@Override public void notify(final ServerTemplateDeleted serverTemplateDeleted) { LOGGER.info("WebSocket notify on deleted :: {}", serverTemplateDeleted); notifySessions(serverTemplateDeleted); }
@Test public void testServerInstanceDeleted() throws Exception { final ServerInstanceDeleted event = new ServerInstanceDeleted("serverId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void notify(final ServerInstanceConnected serverInstanceConnected) { LOGGER.info("WebSocket notify on instance connected :: {}", serverInstanceConnected); notifySessions(serverInstanceConnected); }
@Test public void testServerTemplateDeleted() throws Exception { final ServerTemplateDeleted event = new ServerTemplateDeleted("serverTemplateId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void notify(final ServerInstanceDisconnected serverInstanceDisconnected) { LOGGER.info("WebSocket notify on instance disconnected :: {}", serverInstanceDisconnected); notifySessions(serverInstanceDisconnected); } }
@Test public void testServerTemplateUpdated() throws Exception { final ServerTemplateUpdated event = new ServerTemplateUpdated(new ServerTemplate()); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void notify(final ServerInstanceUpdated serverInstanceUpdated) { LOGGER.info("WebSocket notify on instance updated :: {}", serverInstanceUpdated); notifySessions(serverInstanceUpdated); }
@Test public void testServerInstanceConnected() throws Exception { final ServerInstanceConnected event = new ServerInstanceConnected(new ServerInstance()); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void notify(final ServerTemplateUpdated serverTemplateUpdated) { LOGGER.info("WebSocket notify on updated :: {}", serverTemplateUpdated); notifySessions(serverTemplateUpdated); }
@Test public void testServerInstanceUpdated() throws Exception { final ServerInstanceUpdated event = new ServerInstanceUpdated(new ServerInstance()); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void notify(final ServerTemplate serverTemplate, final ContainerSpec containerSpec, final List<Container> containers) { LOGGER.info("WebSocket notification about change requested on server {} with container spec {} with following result {}", serverTemplate, containerSpec, containers); notifySessions(new ContainerSpecUpdated(serverTemplate, containerSpec, containers)); }