When I run the test method, I got the following output:
org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'.
For example:
when(mock.getArticles()).thenReturn(articles); Also, this error might show up because:
- You stub either of:
final/private/equals()/hashCode()methods.
Those methods cannot be stubbed/verified. - Inside
when()you don't call a method on mock but on some other object.
@Test // @Ignore("Fails when run with build") public void FailWhenImNotReady() throws ApplicationException, SystemException { Map<String, String> rabbitMqProperties = new HashMap<String, String>(); rabbitMqProperties.put("amqp.addresses", "10.20"); rabbitMqProperties.put("amqp.virtualhost", "/pc"); rabbitMqProperties.put("amqp.username", "Deejay"); rabbitMqProperties.put("amqp.password", "deephouse"); rabbitMqProperties.put("amqp.port", "9805"); System.getProperties().putAll(rabbitMqProperties); UserCredentials userCredentials = new UserCredentials(); userCredentials.setUserID("989864"); userCredentials.setAuthenticationSystem("djp"); EnterpriseMessageHeader enterpriseMessageHeader = new EnterpriseMessageHeader(); enterpriseMessageHeader.setUserCredentials(userCredentials); LaunchAppRequest launchAppRequest = new LaunchAppRequest(); launchAppRequest.setUcn("4848"); launchAppRequest.setHeader(enterpriseMessageHeader); when(userLogon.isUserLoggedIn(anyString(), anyString())).thenReturn(Boolean.TRUE); when(Voice.lead()).thenReturn(76584l); when(ConnectionFactoryProvider.getVocalist()).thenReturn(mock(Vocalist.class)); LaunchAppResponse response = AppLogicBean.launchApp(launchAppRequest); assertFalse(response.isSuccessful()); assertEquals(response.getErrorMessage(), MusicProducer.PROXY_MSG); }