當前位置: 首頁>>代碼示例>>Java>>正文


Java InvocationOnMock.getArgumentAt方法代碼示例

本文整理匯總了Java中org.mockito.invocation.InvocationOnMock.getArgumentAt方法的典型用法代碼示例。如果您正苦於以下問題:Java InvocationOnMock.getArgumentAt方法的具體用法?Java InvocationOnMock.getArgumentAt怎麽用?Java InvocationOnMock.getArgumentAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mockito.invocation.InvocationOnMock的用法示例。


在下文中一共展示了InvocationOnMock.getArgumentAt方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: answer

import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
    String name = invocation.getArgumentAt(0, String.class);
    String value = invocation.getArgumentAt(1, String.class);
    apply(name, value);
    return null;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:8,代碼來源:MockRequestBuilder.java

示例2: validateCloseToDisk

import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
private void validateCloseToDisk(MemoryRun memoryRun, final int expectedRecordCount) throws Exception {
  // create a mock DiskRunManager and capture the spilled hyper batch
  DiskRunManager manager = Mockito.mock(DiskRunManager.class);
  Answer<Void> spillAnswer = new Answer<Void>() {
    @Override
    public Void answer(InvocationOnMock invocation) throws Throwable {
      VectorContainer hyperBatch = invocation.getArgumentAt(0, VectorContainer.class);
      validateHyperBatch(hyperBatch, expectedRecordCount);
      return null;
    }
  };

  Mockito.doAnswer(spillAnswer).when(manager).spill(Mockito.any(VectorContainer.class), Mockito.any(BufferAllocator.class));

  // closeToDisk expects the hyperBatch to be transferred to another allocator as it will be closing the memoryRun
  // so make sure we either transfer the batch or validate it in the answer above
  memoryRun.closeToDisk(manager);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:19,代碼來源:TestMemoryRun.java

示例3: answer

import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
    File file = invocationOnMock.getArgumentAt(0, File.class);
    MediaFile mediaFile = new MediaFile();
    mediaFile.setPath(file.getPath());
    return mediaFile;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:8,代碼來源:PlaylistServiceTestImport.java

示例4: answer

import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override
public HealthResponse answer(InvocationOnMock invocation) {
    URI uri = invocation.getArgumentAt(0, URI.class);
    List<String> pathSegments = UriComponentsBuilder.fromUri(uri).build().getPathSegments();
    String status = Iterables.getLast(pathSegments);
    if ("EXCEPTION".equals(status)) {
        throw new RestClientException("simulated exception");
    }
    return HealthResponse.builder().status(new Status(status)).build();
}
 
開發者ID:ePages-de,項目名稱:spring-boot-readiness,代碼行數:11,代碼來源:MockRestTemplateAnswer.java

示例5: answer

import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
  Object evalOn = invocation.getArgumentAt(0, Object.class);
  if (evalOn instanceof Portfolio) {
    Portfolio p = (Portfolio) evalOn;
    return p.indexKey;
  }
  return null;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:10,代碼來源:HashIndexSetJUnitTest.java

示例6: applyToCursorAnswer

import org.mockito.invocation.InvocationOnMock; //導入方法依賴的package包/類
/**
 * To emulate side effect of void method.
 * {@link CursorAwareDataTreeModification#applyToCursor(DataTreeModificationCursor)}
 *
 * @param invocation invocation
 * @return void - always null
 */
protected static final <T> Answer<T> applyToCursorAnswer(final InvocationOnMock invocation) {
    final DataTreeModificationCursor cursor =
            invocation.getArgumentAt(0, DataTreeModificationCursor.class);
    cursor.write(PATH_1.getLastPathArgument(), DATA_1);
    cursor.merge(PATH_2.getLastPathArgument(), DATA_2);
    cursor.delete(PATH_3.getLastPathArgument());
    return null;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:16,代碼來源:LocalProxyTransactionTest.java


注:本文中的org.mockito.invocation.InvocationOnMock.getArgumentAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。