RSMessageToClientManager extends MessageToClientManager<HttpSession> implements RSMessageToClientService { @Override public Map<String, Object> getSessionBeans(HttpSession session) { Map<String, Object> result = (Map<String, Object>) session.getAttribute(Constants.SESSION_BEANS); if (result == null) { result = new HashMap<>(); session.setAttribute(Constants.SESSION_BEANS, result); } return result; }  @Override Map<String, Object> getSessionBeans(HttpSession session); @Override MessageToClient createMessageToClient(MessageFromClient message, HttpSession client);  }
@Test public void testGetSessionBeans() { System.out.println("getSessionBeans"); HttpSession session = mock(HttpSession.class); Map<String, Object> map = mock(Map.class); when(session.getAttribute(eq(Constants.SESSION_BEANS))).thenReturn(null).thenReturn(map); Map<String, Object> result = instance.getSessionBeans(session); assertThat(result).isNotNull(); assertThat(result).isNotSameAs(map); result = instance.getSessionBeans(session); verify(session, times(1)).setAttribute(eq(Constants.SESSION_BEANS), any(Map.class)); assertThat(result).isEqualTo(map); }