title: MockMvc fails because of method invocation inside the controller method
body: <p>I try to mock a controller which contains a util method inside even though I mock the util method, the mvcMock ignore the result from the when(...) and call the method again with empty parameters which lead to nullpointerexception </p>
  
  <p>How I can ship the call of</p>
  
  <pre><code>when(utilMock.getOperatorsAdNameWrapper(userName, adNames)).thenReturn(roleSet);
  </code></pre>
  
  <p>with the mockMvc.perform? </p>
  
  <pre><code>@GetMapping(value = {"/wellbore"})
  public String wellboreForm(Model model, @RequestParam("mode") String mode, HttpServletRequest request) {
  
      Set&lt;String&gt; operators = new LinkedHashSet&lt;&gt;();
      String userName = (String) request.getSession().getAttribute("userName");
      Set&lt;String&gt; operatorsSet = (HashSet&lt;String&gt;) request.getSession().getAttribute("userRoles");
  
  
      Set&lt;String&gt; operatorsAdName = util.getOperatorsAdNameWrapper(userName, operatorsSet);
      operatorsAdName.forEach(adName -&gt; {
          Query query = new Query()
                  .setClassname(Wellbore.CLASS)
                  .eq(Wellbore.operatorsGroup, adName);
          operators.addAll(getWellboresNameList(query));
      });
  
          model.addAttribute("wellboreDataList", operators);
          model.addAttribute("wellboreData", new WellboreForm());
  
          return "ui/selectWellbore";
  }
  
  
  
   public static Set&lt;String&gt; getOperatorsAdName(String userName, Set&lt;String&gt; operatorsAdName) {
      operatorsAdName.removeIf(x -&gt; x.equals(userName)
              || x.equals("SCOUT")
              || x.equals("GTO")
              || x.equals("KADME")
              || x.equals("offline_access")
              || x.equals("uma_authorization"));
  
      return operatorsAdName;
  }
  
  public Set&lt;String&gt; getOperatorsAdNameWrapper(String userName, Set&lt;String&gt; operatorsAdName) {
      return getOperatorsAdName(userName,operatorsAdName);
  }
  
  
  @Mock
  private Util utilMock;
  
  @Test
  @DisplayName("GET /wellbore - Select Wellbore")
  void testMockMvc() throws Exception {
  
  
      HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
      when(req.getAttribute("userName")).thenReturn("abcd");
  
      String userName = (String) req.getAttribute("userName");
  
      //Here I get the correct result Result 
      when(utilMock.getOperatorsAdNameWrapper(userName, adNames)).thenReturn(roleSet); 
  
      //another call made here with empy parameters to utilMock.getOperatorsAdNameWrapper("", null)
      mockMvc.perform(get("/wellbore").param("mode","selectWellbore")
              .sessionAttr("wellboreDataList", new LinkedHashSet&lt;&gt;())
              .sessionAttr("wellboreData", new WellboreForm())
      )
              .andExpect(status().isOk())
              .andExpect(view().name("ui/selectWellbore"))
              .andExpect(model().attribute("wellboreDataList", hasSize(2)));
  }
  </code></pre>