下面列出了org.mockito.invocation.Invocation#getArguments ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static Object[] getInvocationArguments(Invocation invocation, InvocationArgumentsAdapter... argumentAdapters) {
Object[] arguments = invocation.getArguments();
for (InvocationArgumentsAdapter adapter : argumentAdapters) {
arguments = adapter.adaptArguments(arguments);
}
return arguments;
}
private static Object[] getInvocationArguments(Invocation invocation, InvocationArgumentsAdapter... argumentAdapters) {
Object[] arguments = invocation.getArguments();
for (InvocationArgumentsAdapter adapter : argumentAdapters) {
arguments = adapter.adaptArguments(arguments);
}
return arguments;
}
private static Object[] getInvocationArguments(Invocation invocation, InvocationArgumentsAdapter... argumentAdapters) {
Object[] arguments = invocation.getArguments();
for (InvocationArgumentsAdapter adapter : argumentAdapters) {
arguments = adapter.adaptArguments(arguments);
}
return arguments;
}
private void validateMatchers(Invocation invocation, List<LocalizedMatcher> lastMatchers) {
if (!lastMatchers.isEmpty()) {
int recordedMatchersSize = lastMatchers.size();
int expectedMatchersSize = invocation.getArguments().length;
if (expectedMatchersSize != recordedMatchersSize) {
new Reporter().invalidUseOfMatchers(expectedMatchersSize, lastMatchers);
}
}
}
@Override
public void verify(final VerificationData data) {
List<Invocation> actualInvocations =
InvocationsFinder.findInvocations(data.getAllInvocations(), data.getTarget());
if (actualInvocations.size() != 1) {
throw new MockitoException("This verifier can only be used with 1 invocation, got "
+ actualInvocations.size());
}
Invocation invocation = actualInvocations.get(0);
arguments = invocation.getArguments();
invocation.markVerified();
}
public boolean argumentsMatch(InvocationMatcher invocationMatcher, Invocation actual) {
Object[] actualArgs = actual.getArguments();
return argumentsMatch(invocationMatcher, actualArgs) || varArgsMatch(invocationMatcher, actual);
}