why my unit test failing after adding a parameter?

Here is my code when working fine

verify(loginService).getUser(eq(loginName));

here it is failing..

@Test
public void test_getUserFlow4() {
    ...
    LoginModel loginModelReturned = loginService.getUser(loginName, null);
    assertGeneralConditions(loginModelReturned);
    ...
}

private void assertGeneralConditions(LoginModel loginModelReturned){
    verify(loginService).getUser(eq(loginName), null);  //test failed here other lines not executed
    ....
    ....
}

here is the getUser method

public LoginModel getUser(String loginName, String userAgent) {
    // userAgent is not being used anywhere
    ....
    return model;
}

Exact Error:

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
Invalid use of argument matchers!
2 matchers expected, 1 recorded:
Jon Skeet
people
quotationmark

If you're using argument matches, you need to use them for all arguments. So to fix your test, you can just use:

verify(loginService).getUser(eq(loginName), Matchers.<String>eq(null));

Or:

verify(loginService).getUser(eq(loginName), (String) isNull());

Or personally, I'd clarify this by simply having a userAgent variable with a value of null:

String userAgent = null;
verify(loginService).getUser(eq(loginName), eq(userAgent));

people

See more on this question at Stackoverflow