I'm using the following doThrow - doThrow(new
RuntimeException()).when(messageCenterManagerMock).markMessagesRead(messageList);
to call the void method markMessagesRead in a piece of code.
The problem appears to be that since this method exists inside of the
following block of code (written by someone else) and that the
markMessageRead method is called with the messages List that is
created inside of the method, it appears to get confused between the
mock I'm passing it and the call internally. I'm basing this
assumption off the fact that when I call -
verify(messageCenterManagerMock).markMessagesRead(messageList)); - it
tells me the Arguments are different and comparing them in Eclipse the
IDs are different.
public ModelAndView mark_read(HttpServletRequest request,
HttpServletResponse response) {
String idsCSList = request.getParameter("ids");
logger.trace(idsCSList);
String ids[] = idsCSList.split(",");
List<Message> messages = new ArrayList<Message>();
for (int i = 0; i < ids.length; i++) {
logger.debug("Message with ID of " + ids[i] + "to be marked as
read.");
Message message = new Message();
message.setId(ids[i]);
messages.add(message);
}
try {
messageCenterManager.markMessagesRead(messages);
return JsonViewUtil.generateJsonView(true, "");
} catch (Exception e) {
return JsonViewUtil.generateJsonView(false, e.getMessage());
}
}
I swear once upon a time (3 months ago) myself or a coworker figured
out what we needed to do to get around this argument inconsistency
between the objects but for the life of me we can't remember. Any
ideas anyone?
Thanks.
--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to
moc...@googlegroups.com.
To unsubscribe from this group, send email to
mockito+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mockito?hl=en.