title: spring MockMvc testing for model attribute
body: <p>I have a controller method for which i have to write a junit test</p>
  
  <pre><code>@RequestMapping(value = "/new", method = RequestMethod.GET)
  public ModelAndView getNewView(Model model) {
      EmployeeForm form = new EmployeeForm()
      Client client = (Client) model.asMap().get("currentClient");
      form.setClientId(client.getId());
  
      model.addAttribute("employeeForm", form);
      return new ModelAndView(CREATE_VIEW, model.asMap());
  }
  </code></pre>
  
  <p>Junit test using spring mockMVC</p>
  
  <pre><code>@Test
  public void getNewView() throws Exception {
      this.mockMvc.perform(get("/new")).andExpect(status().isOk()).andExpect(model().attributeExists("employeeForm")
              .andExpect(view().name("/new"));
  }
  </code></pre>
  
  <p>I am getting NullPointerException as  model.asMap().get("currentClient"); is returning null when the test is run, how do i set that value using spring mockmvc framework</p>