@Test void givenExistingRoute_whenTheStatusOfRoutesIsRequested_thenTheListIsReturned() { Map<String, WebSocketRoutedSession> routedSessions = new HashMap<>(); WebSocketRoutedSession validSession = mock(WebSocketRoutedSession.class); when(validSession.getClientId()).thenReturn("12"); when(validSession.getClientUri()).thenReturn("ws: when(validSession.getServerUri()).thenReturn("ws: when(validSession.getServerRemoteAddress()).thenReturn("ws: routedSessions.put("webSocketSessionId", validSession); when(webSocketProxyServerHandler.getRoutedSessions()).thenReturn(routedSessions); String clientResponse = new JSONArray(underTest.getAll()).toString(); assertThat(clientResponse, is("[{\"gatewayPath\":\"ws:\\/\\/gateway:10010\\/api\\/v2\\/\",\"serviceUrl\":\"ws:\\/\\/localhost:8080\\/v2\",\"serviceSessionId\":\"12\",\"sessionId\":\"webSocketSessionId\",\"clientAddress\":\"ws:\\/\\/gateway:10010\"}]")); }
@ReadOperation public List<Map<String, String>> getAll() { List<Map<String, String>> result = new ArrayList<>(); for (Entry<String, WebSocketRoutedSession> entry : webSocketProxyServerHandler.getRoutedSessions().entrySet()) { WebSocketRoutedSession currentSession = entry.getValue(); Map<String, String> map = new LinkedHashMap<>(); map.put("sessionId", entry.getKey()); map.put("clientAddress", currentSession.getServerRemoteAddress()); map.put("gatewayPath", currentSession.getServerUri()); map.put("serviceUrl", currentSession.getClientUri()); map.put("serviceSessionId", currentSession.getClientId()); result.add(map); } return result; }
WebSocketActuatorEndpoint { @ReadOperation public List<Map<String, String>> getAll() { List<Map<String, String>> result = new ArrayList<>(); for (Entry<String, WebSocketRoutedSession> entry : webSocketProxyServerHandler.getRoutedSessions().entrySet()) { WebSocketRoutedSession currentSession = entry.getValue(); Map<String, String> map = new LinkedHashMap<>(); map.put("sessionId", entry.getKey()); map.put("clientAddress", currentSession.getServerRemoteAddress()); map.put("gatewayPath", currentSession.getServerUri()); map.put("serviceUrl", currentSession.getClientUri()); map.put("serviceSessionId", currentSession.getClientId()); result.add(map); } return result; } }
WebSocketActuatorEndpoint { @ReadOperation public List<Map<String, String>> getAll() { List<Map<String, String>> result = new ArrayList<>(); for (Entry<String, WebSocketRoutedSession> entry : webSocketProxyServerHandler.getRoutedSessions().entrySet()) { WebSocketRoutedSession currentSession = entry.getValue(); Map<String, String> map = new LinkedHashMap<>(); map.put("sessionId", entry.getKey()); map.put("clientAddress", currentSession.getServerRemoteAddress()); map.put("gatewayPath", currentSession.getServerUri()); map.put("serviceUrl", currentSession.getClientUri()); map.put("serviceSessionId", currentSession.getClientId()); result.add(map); } return result; } @Autowired  WebSocketActuatorEndpoint(WebSocketProxyServerHandler webSocketProxyServerHandler); }
WebSocketActuatorEndpoint { @ReadOperation public List<Map<String, String>> getAll() { List<Map<String, String>> result = new ArrayList<>(); for (Entry<String, WebSocketRoutedSession> entry : webSocketProxyServerHandler.getRoutedSessions().entrySet()) { WebSocketRoutedSession currentSession = entry.getValue(); Map<String, String> map = new LinkedHashMap<>(); map.put("sessionId", entry.getKey()); map.put("clientAddress", currentSession.getServerRemoteAddress()); map.put("gatewayPath", currentSession.getServerUri()); map.put("serviceUrl", currentSession.getClientUri()); map.put("serviceSessionId", currentSession.getClientId()); result.add(map); } return result; } @Autowired  WebSocketActuatorEndpoint(WebSocketProxyServerHandler webSocketProxyServerHandler); @ReadOperation List<Map<String, String>> getAll(); }
WebSocketActuatorEndpoint { @ReadOperation public List<Map<String, String>> getAll() { List<Map<String, String>> result = new ArrayList<>(); for (Entry<String, WebSocketRoutedSession> entry : webSocketProxyServerHandler.getRoutedSessions().entrySet()) { WebSocketRoutedSession currentSession = entry.getValue(); Map<String, String> map = new LinkedHashMap<>(); map.put("sessionId", entry.getKey()); map.put("clientAddress", currentSession.getServerRemoteAddress()); map.put("gatewayPath", currentSession.getServerUri()); map.put("serviceUrl", currentSession.getClientUri()); map.put("serviceSessionId", currentSession.getClientId()); result.add(map); } return result; } @Autowired  WebSocketActuatorEndpoint(WebSocketProxyServerHandler webSocketProxyServerHandler); @ReadOperation List<Map<String, String>> getAll();  }