title: Mockito Argument Captor Test Returning Whole JSON Object
body: <p>I have a Mockito test that uses Argument Captor to verify a new user was POSTed properly:</p>
  
  <pre><code>@Test
  public void testPostUser() throws Exception{
     User user = new User(1L, "tonkatruck");
  
     when(userService.addUser(any(User.class))).thenReturn(user);
  
     mockMvc.perform(post("/api/user")
          .content("{\"userId\":\"1\",\"userName\":\"tonkatruck\"}")
          .contentType(MediaType.APPLICATION_JSON))
              .andExpect(jsonPath("$.userName", is(user.getUserName())))
              .andExpect(status().isCreated())
              .andDo(print());
  
  
     //verify(userService).addUser(any(User.class));
     verify(userService).addUser(userCaptor.capture());
  
     //get the username from what was captured in the POST method and assert that it posted the correct username
     String username = userCaptor.getValue().getUserName();
     assertEquals("tonkatruck", username);
  }
  </code></pre>
  
  <p>The test fails with an error of:</p>
  
  <pre><code>Failed tests:   testPostUser(com.ucrisko.libroomreserve.tests.UserControllerTest): expected:&lt;[tonkatruck]&gt; but was:&lt;[{"userId":"1","userName":"tonkatruck"}]&gt;
  </code></pre>
  
  <p>I am calling the User class's getUserName() method on the userCaptor object, so any idea why the assertion comes out as the entire JSON User object?</p>