本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}