Refine search
/** * Intercepts a method call to a proxy. * * @param instance The proxied instance. * @param method The invoked method. * @param arguments The intercepted method arguments. * * @return The method's return value. * * @throws Throwable If the intercepted method raises an exception. */ @RuntimeType Object intercept(@This Object instance, @Origin Method method, @AllArguments Object[] arguments) throws Throwable; }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { throw new UnsupportedOperationException("Please use RLiveObjectService instance for this type of functions"); } }
public static void intercept(@This SebElement element, @Origin(cache = true) Method method, @AllArguments Object[] arguments) throws Exception { if (!method.isAnnotationPresent(DisableLazyInit.class)) { element.init(); } }
@RuntimeType public static Object intercept(@SuperCall Callable<?> callable, @AllArguments Object... args) throws Exception {
throw new IllegalStateException("Expected an array type for all argument annotation on " + source); boolean includeThis = !source.isStatic() && annotation.loadSilent().includeSelf(); List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>(source.getParameters().size() + (includeThis ? 1 : 0)); int offset = source.isStatic() || includeThis ? 0 : 1; if (stackManipulation.isValid()) { stackManipulations.add(stackManipulation); } else if (annotation.loadSilent().value().isStrict()) { return MethodDelegationBinder.ParameterBinding.Illegal.INSTANCE;
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { throw new UnsupportedOperationException("Please use RLiveObjectService instance for this type of functions"); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @This Object me, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { if (args.length >= 1 && String.class.isAssignableFrom(args[0].getClass())) { String name = ((String) args[0]).substring(0, 1).toUpperCase() + ((String) args[0]).substring(1); if ("get".equals(method.getName()) && args.length == 1) { try { return me.getClass().getMethod("get" + name).invoke(me); } catch (NoSuchMethodException noSuchMethodException) { throw new NoSuchFieldException((String) args[0]); } } else if ("set".equals(method.getName()) && args.length == 2) { Method m = ClassUtils.searchForMethod(me.getClass(), "set" + name, new Class[]{args[1].getClass()}); if (m != null) { return m.invoke(me, args[1]); } else { throw new NoSuchFieldException((String) args[0]); } } } throw new NoSuchMethodException(method.getName() + " has wrong signature"); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { Class<?>[] cls = new Class[args.length]; for (int i = 0; i < args.length; i++) { cls[i] = args[i].getClass(); } return ClassUtils.searchForMethod(RMap.class, method.getName(), cls).invoke(map, args); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @This Object me, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { if (args.length >= 1 && String.class.isAssignableFrom(args[0].getClass())) { String name = ((String) args[0]).substring(0, 1).toUpperCase() + ((String) args[0]).substring(1); if ("get".equals(method.getName()) && args.length == 1) { try { return me.getClass().getMethod("get" + name).invoke(me); } catch (NoSuchMethodException noSuchMethodException) { throw new NoSuchFieldException((String) args[0]); } } else if ("set".equals(method.getName()) && args.length == 2) { Method m = ClassUtils.searchForMethod(me.getClass(), "set" + name, new Class[]{args[1].getClass()}); if (m != null) { return m.invoke(me, args[1]); } else { throw new NoSuchFieldException((String) args[0]); } } } throw new NoSuchMethodException(method.getName() + " has wrong signature"); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { Class<?>[] cls = new Class[args.length]; for (int i = 0; i < args.length; i++) { cls[i] = args[i].getClass(); } return ClassUtils.searchForMethod(RExpirable.class, method.getName(), cls).invoke(map, args); } }
@SuppressWarnings("unused") @RuntimeType public static Object interceptAbstract(@This Object mock, @FieldValue("mockitoInterceptor") MockMethodInterceptor interceptor, @StubValue Object stubValue, @Origin Method invokedMethod, @AllArguments Object[] arguments) throws Throwable { if (interceptor == null) { return stubValue; } return interceptor.doIntercept( mock, invokedMethod, arguments, RealMethod.IsIllegal.INSTANCE ); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { Class<?>[] cls = new Class[args.length]; for (int i = 0; i < args.length; i++) { cls[i] = args[i].getClass(); } return ClassUtils.searchForMethod(RExpirable.class, method.getName(), cls).invoke(map, args); } }
@SuppressWarnings("unused") @RuntimeType @BindingPriority(BindingPriority.DEFAULT * 2) public static Object interceptSuperCallable(@This Object mock, @FieldValue("mockitoInterceptor") MockMethodInterceptor interceptor, @Origin Method invokedMethod, @AllArguments Object[] arguments, @SuperCall(serializableProxy = true) Callable<?> superCall) throws Throwable { if (interceptor == null) { return superCall.call(); } return interceptor.doIntercept( mock, invokedMethod, arguments, new RealMethod.FromCallable(superCall) ); }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { Class<?>[] cls = new Class[args.length]; for (int i = 0; i < args.length; i++) { cls[i] = args[i].getClass(); } return ClassUtils.searchForMethod(RMap.class, method.getName(), cls).invoke(map, args); } }
@RuntimeType public static Object interceptAbstract(@FieldValue("$spock_interceptor") IProxyBasedMockInterceptor proxyBasedMockInterceptor, @This Object self, @AllArguments Object[] arguments, @Origin Method method, @StubValue Object stubValue) throws Exception { Object returnValue; if (proxyBasedMockInterceptor == null) { returnValue = null; // Call before interceptor was set (constructor). } else { returnValue = proxyBasedMockInterceptor.intercept(self, method, arguments, new ByteBuddyMethodInvoker(null)); } return returnValue == null ? stubValue : returnValue; }
@RuntimeType public static Object interceptExecutionDetails(@Origin Method method, @AllArguments Object[] args) { lastMethod.set(method); lastArgs.set(args); return TypeUtils.getDefaultValue(method.getReturnType()); } }
@RuntimeType public static Object intercept( @This final Object instance, @Origin final Method method, @AllArguments final Object[] arguments, @StubValue final Object stubValue, @FieldValue(INTERCEPTOR_FIELD_NAME) Interceptor interceptor
@RuntimeType public Object invoke(@Origin Method method, @AllArguments @RuntimeType Object[] args) throws Throwable { return doInvoke(method.getName(), args, method.getReturnType(), true); } }
@RuntimeType public static Object interceptNonAbstract(@FieldValue("$spock_interceptor") IProxyBasedMockInterceptor proxyBasedMockInterceptor, @Morph ByteBuddyInvoker invoker, @This Object self, @AllArguments Object[] arguments, @Origin Method method, @StubValue Object stubValue) throws Exception { Object returnValue; if (proxyBasedMockInterceptor == null) { returnValue = invoker.call(arguments); // Call before interceptor was set (constructor). } else { returnValue = proxyBasedMockInterceptor.intercept(self, method, arguments, new ByteBuddyMethodInvoker(invoker)); } return returnValue == null ? stubValue : returnValue; }
@RuntimeType public Object invoke(@Origin Method method, @AllArguments @RuntimeType Object[] args) throws Throwable { return doInvoke(method.getName(), args, method.getReturnType(), true); } }