Używam MockHttpSession, w teście daje
session.setAttribute("shoppingCart",shoppingCart);
Później mockuje metode która pobiera sesje
HttpSession currentSession(){
return SessionContextHolder.getSession();
}
doReturn(session).when(shoppingCartService).currentSession();
I jak już w testowanej metodzie pobieram koszyk z sesji to dostaje null