当前位置: 首页>>代码示例>>Java>>正文


Java InvocationOnMock.getArgument方法代码示例

本文整理汇总了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());
}
 
开发者ID:gladed,项目名称:kotlin-late,代码行数:19,代码来源:LateTest.java

示例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;
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:21,代码来源:MockRequest.java

示例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;
        }
    };
}
 
开发者ID:ChresSSB,项目名称:Webcheckers,代码行数:18,代码来源:MyModelAndView.java

示例4: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
  arg = invocationOnMock.getArgument(0);
  return null;
}
 
开发者ID:openknowledge,项目名称:reactive-jax-rs,代码行数:5,代码来源:AnswerArg1.java


注:本文中的org.mockito.invocation.InvocationOnMock.getArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。