title: Spring-boot integration test, set request attribute for TestRestTemplate
body: <p>I am setting request attribute called <code>Id</code> in prehandle method of <code>RequestHandlerInterceptor</code>. I get this id from jwt token.</p>
  
   <pre class="lang-java prettyprint-override"><code> protected UserContext getCurrentUserContext() {
          return UserContextHolder.getCurrentContext();
   }
  
   @Override
   public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws AuthenticationException {
          UserProfile userProfile = null;
          try {
              UserContext userContext = getCurrentUserContext();
              userProfile = userContext.getUserProfile();         
              request.setAttribute("Id", String.valueOf(userProfile.getId()));
              return true;
          }
  </code></pre>
  
  <p>using <code>@RequestAttribute</code> in my controller method to get this attribute.</p>
  
  <pre class="lang-java prettyprint-override"><code>@DeleteMapping("/{id}")
  public void delete(@PathVariable Long id, @RequestAttribute("Id") String userId) throws EntityNotFoundException, ApiException {
          excessService.deleteExcess(id, userId); 
  }
  </code></pre>
  
  <p>But my integration tests are failing though I've overridden this <code>RequestHandlerInterceptor</code>.</p>
  
  <pre class="lang-java prettyprint-override"><code>    requestHandlerInterceptor = new RequestHandlerInterceptor() {
          @Override
          public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws AuthenticationException {
              request.setAttribute("Id", "123456");
              return true;
          }
      } 
  </code></pre>
  
  <p>How can I mock this request attribute in integration test, to pass that 'id' value into my controller methods?</p>