/** * Build a {@code ResolvableMethod} from the provided filters which must * resolve to a unique, single method. * <p>See additional resolveXxx shortcut methods going directly to * {@link Method} or return type parameter. * @throws IllegalStateException for no match or multiple matches */ public ResolvableMethod build() { Set<Method> methods = MethodIntrospector.selectMethods(this.objectClass, this::isMatch); Assert.state(!methods.isEmpty(), () -> "No matching method: " + this); Assert.state(methods.size() == 1, () -> "Multiple matching methods: " + this + formatMethods(methods)); return new ResolvableMethod(methods.iterator().next()); }
public ResolvableMethod mockCall(Consumer<T> invoker) { MethodInvocationInterceptor interceptor = new MethodInvocationInterceptor(); T proxy = initProxy(this.objectClass, interceptor); invoker.accept(proxy); Method method = interceptor.getInvokedMethod(); return new ResolvableMethod(method); }