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