EasyMock Long null match in method parameter
easymock, java, unit-testing
Solution
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)));
Problem
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 ?