Getting httpServletRequest attribute with MockMvc
You could use
mvc.perform(post("/api/v1/...")
.with(request -> {
request.addHeader(HEADER_USERNAME_KEY, approver);
request.setAttribute("attrName", "attrValue");
return request;
})
.contentType(MediaType.APPLICATION_JSON)...
You add a request attribute by calling requestAttr
^^
mockMvc.perform(get("/api/test").requestAttr("userId", "testUserId")...