@Test public void getUserId() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpSession session = new MockHttpSession() { @Override public String getId() { return "535510n1D"; } }; request.setSession(session); RequestAttributes attributes = new ServletWebRequest(request); RequestContextHolder.setRequestAttributes(attributes); SessionUserIdSource source = new SessionUserIdSource(); assertEquals("535510n1D", source.getUserId()); }
@Override public String getUserId() { return RequestContextHolder.currentRequestAttributes().getSessionId(); }
SessionUserIdSource implements UserIdSource { @Override public String getUserId() { return RequestContextHolder.currentRequestAttributes().getSessionId(); } }
SessionUserIdSource implements UserIdSource { @Override public String getUserId() { return RequestContextHolder.currentRequestAttributes().getSessionId(); }  }
SessionUserIdSource implements UserIdSource { @Override public String getUserId() { return RequestContextHolder.currentRequestAttributes().getSessionId(); }  @Override String getUserId(); }
SessionUserIdSource implements UserIdSource { @Override public String getUserId() { return RequestContextHolder.currentRequestAttributes().getSessionId(); }  @Override String getUserId();  }