I'm back to issue #837 (upgrading Lucene version).
There are two mockito based test cases in PensieveSeekerTest are throwing
org.mockito.exceptions.misusing.UnfinishedStubbingException
instead of the expected OkapiIOException.
One of them looks like this:
@Test(expected = OkapiIOException.class)
public void iteratorNextIOException() throws Exception {
PensieveWriter writer = getWriter();
populateIndex(writer, 1, "patents are evil", "unittest");
writer.close();
Iterator<TranslationUnit> iterator = seeker.iterator();
IndexReader mockIndexReader = mock(IndexReader.class);
doThrow(new IOException("some exception")).when(mockIndexReader).document(anyInt());
Helper.setPrivateMember(iterator, "ir", mockIndexReader);
iterator.next();
}
The error message is:
java.lang.Exception: Unexpected exception, expected<net.sf.okapi.common.exceptions.OkapiIOException> but was<org.mockito.exceptions.misusing.InvalidUseOfMatchersException>
Caused by: org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
2 matchers expected, 1 recorded:
-> at net.sf.okapi.tm.pensieve.seeker.PensieveSeekerTest.iteratorNextIOException(PensieveSeekerTest.java:185)
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
For more info see javadoc for Matchers class.
at org.apache.lucene.index.IndexReader.document(IndexReader.java:352)
at net.sf.okapi.tm.pensieve.seeker.PensieveSeekerTest.iteratorNextIOException(PensieveSeekerTest.java:185)
It seems that this isn't working with the new Lucene version because the document(int)
method is now final while it wasn't in older Lucene versions, and Mockito does not
support stubbing final methods.
Any suggestion how I port the test cases like this?
Kuro