HttpSessionFactory implements Supplier<HttpSession> { @Override public HttpSession get() { return requestProvider.get().getSession(); } HttpSessionFactory(
            @Context final Provider<HttpServletRequest> requestProvider); @Override HttpSession get();  }
@Test public void get() { HttpServletRequest mockRequest = mock(HttpServletRequest.class); HttpSession mockSession = mock(HttpSession.class); doReturn(mockSession).when(mockRequest).getSession(); Provider<HttpServletRequest> requestProvider = () -> mockRequest; HttpSessionFactory factory = new HttpSessionFactory(requestProvider); HttpSession responseSession = factory.get(); assertSame(responseSession, mockSession); }