I have this method signature that i want to mock with EasyMock
public BigDecimal getRemainingPremium(BigDecimal baseAmount, Date commencementDate, Date effectiveDate, boolean isComplete)
My test code has
Premium premium = createMock(Premium.class);
// add this line
EasyMock.expect(premium.getCommencementDate()).andReturn(EasyMock.anyObject(Date.class)).anyTimes();
expect(
premium.getRemainingPremium(
EasyMock.anyObject(BigDecimal.class),
EasyMock.anyObject(Date.class),
EasyMock.anyObject(Date.class),
EasyMock.anyBoolean()
))
.andReturn(BigDecimal.TEN).anyTimes();
but i keep getting this matcher exception. I've tried all combinations of primitives and 'EasyMock.anyObject(Boolean.class)'. Any suggestions on a workaround?
java.lang.IllegalStateException: 4 matchers expected, 5 recorded.
This exception usually occurs when matchers are mixed with raw values when recording a method:
foo(5, eq(6)); // wrong
You need to use no matcher at all or a matcher for every single param:
foo(eq(5), eq(6)); // right
foo(5, 6); // also right
at org.easymock.internal.ExpectedInvocation.createMissingMatchers(ExpectedInvocation.java:48)
at org.easymock.internal.ExpectedInvocation.<init>(ExpectedInvocation.java:41)
at org.easymock.internal.RecordState.invoke(RecordState.java:79)
at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:41)