本文整理匯總了Java中org.mockito.invocation.InvocationOnMock.getMock方法的典型用法代碼示例。如果您正苦於以下問題:Java InvocationOnMock.getMock方法的具體用法?Java InvocationOnMock.getMock怎麽用?Java InvocationOnMock.getMock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mockito.invocation.InvocationOnMock
的用法示例。
在下文中一共展示了InvocationOnMock.getMock方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getKeyAnswer
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
private Answer<?> getKeyAnswer(final String segmentName,
final boolean isCompressedInput) {
return new Answer<Object>() {
int i = 0;
@SuppressWarnings("unchecked")
public Boolean answer(InvocationOnMock invocation) {
if (i++ == 3) {
return false;
}
Reader<Text,Text> mock = (Reader<Text,Text>) invocation.getMock();
int multiplier = isCompressedInput ? 100 : 1;
mock.bytesRead += 10 * multiplier;
Object[] args = invocation.getArguments();
DataInputBuffer key = (DataInputBuffer) args[0];
key.reset(("Segment Key " + segmentName + i).getBytes(), 20);
return true;
}
};
}
示例2: answer
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
public Object answer(InvocationOnMock invocation) throws Throwable {
Object mock = invocation.getMock();
if (invocation.getMethod().getReturnType().isInstance(mock)) {
return mock;
} else {
return RETURNS_DEFAULTS.answer(invocation);
}
}
示例3: answer
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object mock = invocation.getMock();
if (invocation.getMethod().getReturnType().isInstance(mock)) {
return mock;
}
return null;
}