I’m using Mockito 1.9.5, Maven 3.2.3, and JUnit 4.11. I have the following set up in a JUnit test ...
final Set<Account> accounts = new HashSet<Account>();
final Account acct1 = new Account();
acct1.setId(“id1”);
accounts.add(acct1);
…
Mockito.doReturn(acctTeamMemberMap).when(m_accountTeamMemberDao).getManagers(accounts);
The problem is the Account objects I’m creating in my JUnit test are not the same objects that are actually being passed in as parameters when I execute the method call. My question is, how do I tell Mockito to return the results when the ID fields of the various objects match the IDs I have in my JUnit test? In other words, if the above Account objects have ids “id1” and “id2”, I would want Mockito to return the results always if the actual parameters also have ids “id1” and “id2”.
Thanks, - Dave