Sunday 15 January 2012

java - Mockito calls Object's equals() method -


I am new to Mokito I have

  Maps & lt; String, Object & gt; Expected Filter = New Hashmap & lt; String, Object & gt; () Expected Filters.Put ("id", new integer [] {22}); Expected filter.poot ("code", new integer [] {1});   

And use this map as logic to write stubbing. Is the value of the real value in the map integer, whereas the mokitō is equal to the call object?

Thank you!

You are putting an integer [] in the map, not integers. Integer [] Override objects are not equal, so it will be called. To get around it you can write a wrapper class which is equal to the array's contents in this way:

  public class ArrayWrapper   

and add examples of this class to the map instead of the integer [], so the counterparts of this class will be called.

No comments:

Post a Comment