title: How to only mock a method of a bean in Spring using Mockito?
body: <p>I use <code>@Primary</code> and <code>@Profile</code> to mock a bean in Spring test:</p>
  
  <pre><code>@Profile("test")
  @Configuration
  public class TestBeanConf {
  
  @Bean
  @Primary
  public UserService userService() {
      UserService userService = Mockito.mock(UserService.class);
      TokenValidationUrl validation = new TokenValidationUrl();
      validation.setValid(true);
      validation.setUid("123456789");
      Mockito.when(userService.tokenValidation("23456")).thenReturn(validation);
      return userService;
  }
  </code></pre>
  
  <p>But other methods of <code>UserService</code> bean return <code>null</code>, how can i spy the real created bean and only mock <code>tokenValidation</code> method?</p>