本文整理汇总了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;
}