當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。