title: Junit - mockito Wanted but not invoked:
body: <p>Am writting <code>test class</code> for my service implementation class. That service impl class having communication with my repository interface for DB action.</p>
  
  <p>Code is working properly, but while i was writting the test cases for this implementation and getting "wanter but not invoked" error from junit.</p>
  
  <p>Please find my classes below.</p>
  
  <p>Following is my Repository interface</p>
  
  <pre><code>public interface UserRepository extends JpaSpecificationExecutor&lt;UserDeactivationThreshold&gt;,CrudRepository&lt;UserDeactivationThreshold,Long&gt; {
  
      @Query("SELECT bt from BusinessTypes bt where bt.code = :businessTypeCode")
      BusinessTypes findByBusinessCodeId(@Param("businessTypeCode") String businessTypeCode); 
      }
  </code></pre>
  
  <p>Following is my Service interface</p>
  
  <pre><code>public interface UserDeactivationThresholdService {
  
      public List&lt;UserDeactivationThreshold&gt; getThresholdValue(String businessTypeName);
  }
  </code></pre>
  
  <p>Following is my Service Implementation class</p>
  
  <pre><code>@Service
  @Transactional(readOnly = true)
  public class UserDeactivationThresholdServiceImpl implements UserDeactivationThresholdService {
  
      private UserRepository userRepository;
  
  
      @Autowired
      public UserDeactivationThresholdServiceImpl(UserRepository userRepository,SecurityClient securityClient, EmailDispatcherService emailDispatcherService) {
          this.userRepository = userRepository;
  
      }
  
  
      @Override
      public List&lt;UserDeactivationThreshold&gt; getThresholdValue(String businessTypeName){
          return userRepository.findByBusinessType(businessTypeName);
      }
  }
  </code></pre>
  
  <p>Please find my Test class</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class UserDeactivationThresholdServiceImplTest {
  
      @Mock
      private UserRepository userRepository;
  
      @Mock private UserDeactivationThresholdServiceImpl userDeactivationThresholdServiceImpl;
  
      @Test
      public void shouldGetThresholdValueTest() {
          UserDeactivationThreshold userDeactivationThreshold = make(a(UserDeactivationThresholdMaker.BCP));
          when(userRepository.findByBusinessType("BCP")).thenReturn(asList(userDeactivationThreshold));
  
          verify(userRepository, times(1)).findByBusinessType("BCP");
      }
  }
  </code></pre>
  
  <p>Following errors that am getting :</p>
  
  <pre><code>Wanted but not invoked:
  userDeactivationThresholdRepository.findByBusinessType(
      "BCP"
  );
  -&gt; at com.core.service.impl.UserDeactivationThresholdServiceImplTest.shouldGetThresholdValueTest(UserDeactivationThresholdServiceImplTest.java:58)
  Actually, there were zero interactions with this mock.
  </code></pre>
  
  <p><strong>* Update *</strong>  </p>
  
  <p>I tried in this way also, but that also not worked.</p>
  
  <pre><code>verify(userDeactivationThresholdServiceImpl, times(1)).getThresholdValue("BCP");
  </code></pre>
  
  <p>Following error that i was getting.</p>
  
  <pre><code>-&gt; at com.core.service.impl.UserDeactivationThresholdServiceImplTest.shouldGetThresholdValueTest(UserDeactivationThresholdServiceImplTest.java:58)
  Actually, there were zero interactions with this mock.
  </code></pre>
  
  <p><strong>* Update 2 *</strong></p>
  
  <p>I have added the below code in to my test class. But now am getting the different issue "The method is(Integer) is ambiguous for the type UserDeactivationThresholdServiceImplTest"</p>
  
  <pre><code>    List&lt;UserDeactivationThreshold&gt; userDeactivationThresholdList = userDeactivationThresholdServiceImpl.getThresholdValue("BCP");
      assertThat(userDeactivationThresholdList.size(), is(1));
  </code></pre>
  
  <p>Am getting the below messiage for <code>is(1)</code>.</p>
  
  <pre><code>The method is(Integer) is ambiguous for the type UserDeactivationThresholdServiceImplTest
  </code></pre>