本文整理匯總了Java中org.mockito.invocation.InvocationOnMock.getArgument方法的典型用法代碼示例。如果您正苦於以下問題:Java InvocationOnMock.getArgument方法的具體用法?Java InvocationOnMock.getArgument怎麽用?Java InvocationOnMock.getArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mockito.invocation.InvocationOnMock
的用法示例。
在下文中一共展示了InvocationOnMock.getArgument方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: before
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Before
public void before() throws Exception {
Answer<Cancelable> runAndReturn = new Answer<Cancelable>() {
@Override
public Cancelable answer(InvocationOnMock invocation) throws Exception {
try {
Function0<Unit> block = invocation.getArgument(0);
block.invoke();
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
return canceler;
}
};
doAnswer(runAndReturn).when(mockRunner).runWithCancel(ArgumentMatchers.<Function0<Unit>>any());
doAnswer(runAndReturn).when(mockRunner).run(ArgumentMatchers.<Function0<Unit>>any());
}
示例2: answer
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override
public LocalResponse answer(InvocationOnMock invocation) throws Throwable {
LocalRequest request = invocation.getArgument(0);
if (!localRequests.containsKey(request.getPath())) {
throw new IllegalStateException("No local request for '" + request.getPath() + "' expected");
}
if(localRequests.get(request.getPath()).isEmpty()) {
throw new IllegalStateException("No more local requests for '" + request.getPath() + "' expected");
}
final LocalRequestData requestData = localRequests.get(request.getPath()).remove(0);
for (Map.Entry<String, String> param : requestData.getParamsToCheck().entrySet()) {
Assert.assertEquals("Local request parameter different", param.getValue(),
request.getParam(param.getKey()));
}
return requestData;
}
示例3: makeAnswer
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
/**
*
* @param myModelView
* @return
*/
static Answer<Object> makeAnswer(final MyModelAndView myModelView) {
return new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final ModelAndView modelAndView = invocation.getArgument(0);
myModelView.model = modelAndView.getModel();
myModelView.viewName = modelAndView.getViewName();
// the return value is not of interest
return null;
}
};
}
示例4: answer
import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
arg = invocationOnMock.getArgument(0);
return null;
}