I want to match a method which has 3 paramters: A String, A Long and A customObject
The test should match the String exactly, ensure that the Long is null and ensure that the custom object passed is of the correct type.
Something like:
EasyMock.expect(mockClass.myMethod(
EasyMock.eq("exact string"),
EasyMock.isA(Long.class),
EasyMock.isA(CustomObject.class)));
This is not matching the method correctly probably because of the Long which is supposed to be null.
I cannot put EasyMock.isNull() since it will be a specific matching and generics and specifics can't go together. Any tips ?
I don't understand why you couldn't use isNull().
EasyMock.expect(mockClass.myMethod(
EasyMock.eq("exact string"),
EasyMock.isNull(Long.class),
EasyMock.isA(CustomObject.class)));
should be fine. Or
EasyMock.expect(mockClass.myMethod(
EasyMock.eq("exact string"),
EasyMock.<Long>isNull(),
EasyMock.isA(CustomObject.class)));
which should be fine as well.
What you can't have is
EasyMock.expect(mockClass.myMethod(
EasyMock.eq("exact string"),
null,
EasyMock.isA(CustomObject.class)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With