Reputation: 11257
I got method of class
interface Class1{
void method1(SomeObject... parameters);
}
I have a custom Hamcrest matcher
public class SomeObjectMatcher extends BaseMatcher<SomeObject>{...}
How to write expectation matching that object passed to the method1
SomeObject someObject = new SomeObject(...);
...
mockery.checking(new Expectations(){{
oneOf(class1).method1(with(new SomeObjectMatcher(someObject1)));
}}
The actual call is
class1.method1(someObject);
The passed object and the expected one are same, but SomeObjectMatcher fails, because the actual passed parameter is not someObject1, but it is SomeObject[]{someObject1} (array with only one object - someObject1)? Is there a way to add a new matcher in the chain, something like
oneOf(class1).method1(with(arrayHas(new SomeObjectMatcher(someObject1))));
Upvotes: 2
Views: 945
Reputation: 36522
Try replacing arrayHas
with hasItemInArray
. To match multiple items in an array you can use arrayContaining
and arrayContainingInAnyOrder
.
Upvotes: 1