@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 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); } }
@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, @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); } }
@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, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { throw new UnsupportedOperationException("Please use RLiveObjectService instance for this type of functions"); } }
@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 AbstractAssert<?, ?> assertion, @SuperCall Callable<Object> proxy) throws Exception { try { Object result = proxy.call(); if (result != assertion && result instanceof AbstractAssert) { return asAssumption((AbstractAssert<?, ?>) result).withAssertionState(assertion); } return result; } catch (AssertionError e) { throw assumptionNotMet(e); } } }
@RuntimeType public Object invoke(@Origin Method method, @AllArguments @RuntimeType Object[] args) throws Throwable { Class<?> returnType = method.getReturnType(); Object result = doInvoke(method.getName(), args, returnType, false); InvokeFutureContext.set((InvokeFuture<?>) result); return Reflects.getTypeDefaultValue(returnType); } }
@RuntimeType public Object invoke(@Origin Method method, @AllArguments @RuntimeType Object[] args) throws Throwable { Class<?> returnType = method.getReturnType(); Object result = doInvoke(method.getName(), args, returnType, false); InvokeFutureContext.set((InvokeFuture<?>) result); return Reflects.getTypeDefaultValue(returnType); } }
/** * 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 AbstractAssert<?, ?> intercept(@FieldValue(FIELD_NAME) ProxifyMethodChangingTheObjectUnderTest dispatcher, @SuperCall Callable<AbstractAssert<?, ?>> assertionMethod, @This AbstractAssert<?, ?> currentAssertInstance) throws Exception { Object result = assertionMethod.call(); return dispatcher.createAssertProxy(result).withAssertionState(currentAssertInstance); }
@RuntimeType public static AbstractAssert<?, ?> intercept(@FieldValue(FIELD_NAME) ProxifyMethodChangingTheObjectUnderTest dispatcher, @SuperCall Callable<AbstractAssert<?, ?>> assertionMethod, @This AbstractAssert<?, ?> currentAssertInstance) throws Exception { Object result = assertionMethod.call(); return dispatcher.createAssertProxy(result).withAssertionState(currentAssertInstance); }
@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) ); }
@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 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 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; }