I have the following Java code:
Index userNameIndex = userTable.getIndex("userNameIndex");
ItemCollection<QueryOutcome> userItems = userNameIndex.query("userName", userName);
for (Item userItem : userItems) {
}
I am trying to write a unit test and I would like to mock the ItemCollection<QueryOutcome>
. The issue is that the iterator returned by ItemCollection<QueryOutcome>::iterator
is of type IteratorSupport
, which is a package protected class. Therefore, it is impossible to mock the return type of this iterator. What can I do instead?
Thanks!
This may not be the best way to do it, but it works and may require you to change the way you get the iterator in the class under test.