@ParameterizedTest @MethodSource("testClassProvider") @SuppressWarnings("unchecked") void testFirefoxOptions(Class<?> testClass) throws Exception { Parameter parameter = testClass .getMethod("webrtcTest", FirefoxDriver.class) .getParameters()[0]; Optional<Object> testInstance = Optional.of(testClass.newInstance()); FirefoxOptions firefoxOptions = (FirefoxOptions) annotationsReader .getOptions(parameter, testInstance); Map<String, Map<String, Boolean>> options = (Map<String, Map<String, Boolean>>) firefoxOptions .asMap().get(FIREFOX_OPTIONS); assertTrue(options.get("prefs") .get("media.navigator.permission.disabled")); assertTrue(options.get("prefs").get("media.navigator.streams.fake")); }
private static void extractParams(PrintWriter printer, Parameter[] parameters, StringBuilder params, StringBuilder paramsToLog) { for (Parameter param : parameters) { String sigFormatter; String paramFormatter; if (params.length() == 0) { sigFormatter = "\"%s\""; paramFormatter = "%s"; } else { sigFormatter = ", \"%s\""; paramFormatter = ", %s"; } printer.print(String.format(sigFormatter, param.getType().getName())); params.append(String.format(paramFormatter, param.getName())); if (param.getType().getName().startsWith("[")) { paramsToLog.append(asConcat(paramsToLog.length() == 0, String.format("\"%s\"", arrayTypeName(param.getType().getName())))); } else { paramsToLog.append(asConcat(paramsToLog.length() == 0, param.getName())); } } }
private static void generateUpdaterMethod(ClassWriter cw, String selfClassInternalName, String selfClassDescriptor, String updaterClassInternalName, String constDesc, Parameter[] parameters) { MethodVisitor mv; mv = cw.visitMethod(ACC_PUBLIC, "updater", "()Lio/primeval/reflex/arguments/ArgumentsUpdater;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitTypeInsn(NEW, updaterClassInternalName); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, selfClassInternalName, "parameters", "Ljava/util/List;"); for (int i = 0; i < parameters.length; i++) { Parameter parameter = parameters[i]; mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, selfClassInternalName, parameter.getName(), Type.getDescriptor(parameter.getType())); } mv.visitMethodInsn(INVOKESPECIAL, updaterClassInternalName, "<init>", constDesc, false); mv.visitInsn(ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", selfClassDescriptor, null, l0, l1, 0); mv.visitMaxs(-1, -1); mv.visitEnd(); }
/** * Create key for single method/constructor parameter. * * @param parameter * Parameter to build key for. * @return Created key. */ public static Key of(Parameter parameter) { Annotation[] annotations = parameter.getAnnotations(); if (!parameter.getType().isAssignableFrom(Supplier.class)) { return new Key(parameter.getParameterizedType(), false, parameter.getType(), findBindingAnnotation(annotations)); } Type type = parameter.getParameterizedType(); if (type instanceof ParameterizedType) { Type[] args = ((ParameterizedType) type).getActualTypeArguments(); if (args.length > 0 && args[0] instanceof Class) { return Key.of(args[0], true, annotations); } } throw new InjectorException("Unable to determine parameter type for " + parameter); }
public Optional<URL> getUrl(Parameter parameter, Optional<Object> testInstance) throws MalformedURLException, IllegalAccessException { Optional<URL> out = empty(); String urlValue = null; DriverUrl driverUrl = parameter.getAnnotation(DriverUrl.class); if (driverUrl != null) { // Search first DriverUrl annotation in parameter urlValue = driverUrl.value(); out = Optional.of(new URL(urlValue)); } else { // If not, search DriverUrl in any field Optional<Object> annotatedField = seekFieldAnnotatedWith( testInstance, DriverUrl.class); if (annotatedField.isPresent()) { urlValue = (String) annotatedField.get(); out = Optional.of(new URL(urlValue)); } } return out; }
private static Optional<JsonSchema> getRequestSchemma(Method m, Class<?> controller) { List<Parameter> p = ReflectionUtils.getParametersBody(m); Optional<JsonSchema> schemma = Optional.empty(); if (!p.isEmpty()) { Optional<Type> t = ReflectionUtils.getRealType(p.get(0).getParameterizedType(), controller); if (t.isPresent()) { Optional<Class<?>> c = ReflectionUtils.getClass(t.get()); if (c.isPresent()) { schemma = getSchemma(c.get()); } else { schemma = getSchemma(t.getClass()); } } else { schemma = getSchemma(ReflectionUtils.getClass(p.get(0).getParameterizedType())); } } return schemma; }
@Override protected void handleValidation(final Message message, final Object resourceInstance, final Method method, final List<Object> arguments) { super.handleValidation(message, resourceInstance, method, arguments); // Check each parameter final Set<ConstraintViolation<?>> validationErrors = new HashSet<>(); for (int index = 0; index < arguments.size(); index++) { final Parameter parameter = method.getParameters()[index]; if (hasToBeValidated(parameter)) { // This parameter is a not context, path or query parameter validate(arguments.get(index), method, parameter, index, validationErrors); } } // Check the veto if (!validationErrors.isEmpty()) { message.put(FaultListener.class.getName(), new NoOpFaultListener()); throw new ConstraintViolationException(validationErrors); } }
public static String formatBeanEndpointRoute(Method m) { String answer = m.getName(); Parameter[] params = m.getParameters(); java.util.List<String> paramList = new ArrayList<>(); if (params.length > 0) { paramList.add("${body}"); for (int i = 1; i < params.length; i++) { paramList.add("${header.param" + i + "}"); } } answer = answer + "(" + String.join(",", paramList) + ")"; return answer; }
private String methodToString(Method method) { String s = method.getName(); Parameter[] parameters = method.getParameters(); if (parameters.length == 0) { return s + "()"; } s += "("; for (int i = 0; i < parameters.length; i++) { s += "?"; if (i < parameters.length - 1) { s += ","; } } s += ")"; return s; }
/** * 方法的参数加载对象 可优化:Parameter包含类型和名称 * * @param parameterTypes * @param parameters * @return */ private Object[] loadParameterWithMethod(Class[] parameterTypes, Parameter[] parameters) { Object[] paramObjs = new Object[parameterCount]; // 厉害了,我的哥。 // 今天找了一整天,JDK/ASM都不行,Paranamer稳! Paranamer paranamer = new BytecodeReadingParanamer(); String[] parametersName = paranamer.lookupParameterNames(invokeMethod); int i = Constants.NUMBER.ZERO; for (Class<?> type : parameterTypes) { if (RequestContext.getInstance().isInContextObjs(type)) { paramObjs[i] = RequestContext.getInstance().searchObjByType(type); } else { TypeParser parser = TypeParser.newBuilder().build(); Object searchedObject = RequestContext.getInstance().searchObjByName(parametersName[i]); paramObjs[i] = parser.parseType(searchedObject.toString(), type); } i++; } // 通过类型加载 // searchAndBindByType(paramObjs, parameterTypes); // TODO 通过参数名加载 return paramObjs; }
public static Object[] getArgs(Signature signature) throws Exception { Method actionMethod = signature.getAction(); Request request = signature.request(); actionMethod.setAccessible(true); Parameter[] parameters = actionMethod.getParameters(); Object[] args = new Object[parameters.length]; String[] parameterNames = AsmKit.getMethodParamNames(actionMethod); for (int i = 0, len = parameters.length; i < len; i++) { Parameter parameter = parameters[i]; String paramName = parameterNames[i]; Class<?> argType = parameter.getType(); if (containsAnnotation(parameter)) { args[i] = getAnnotationParam(parameter, paramName, request); continue; } if (ReflectKit.isPrimitive(argType)) { args[i] = request.query(paramName); continue; } args[i] = getCustomType(parameter, signature); } return args; }
/** * Check given method has a valid signature for {@link OnShow} or {@link OnLeave} view method * @param viewClass View class * @param method Method to check * @param message Error message annotation description * @throws ViewConfigurationException Method is not valid */ private static void checkViewOnShowOrLeaveMethod(Class<?> viewClass, Method method, String message) throws ViewConfigurationException { if (method.getReturnType() != Void.class && method.getReturnType() != Void.TYPE) { throw new ViewConfigurationException("Invalid " + message + " method in view class " + viewClass.getName() + ": method must be a void return method"); } int params = method.getParameterCount(); if (params > 1) { throw new ViewConfigurationException("Invalid " + message + " method in view class " + viewClass.getName() + ": method must have no parameters or only one parameter of type ViewChangeEvent"); } if (params == 1) { Parameter param = method.getParameters()[0]; if (param.isVarArgs() || !(ViewChangeEvent.class.isAssignableFrom(param.getType()) || ViewNavigatorChangeEvent.class.isAssignableFrom(param.getType()))) { throw new ViewConfigurationException( "Invalid " + message + " method in view class " + viewClass.getName() + ": method must have no parameters or only one parameter of type ViewChangeEvent"); } } }
protected Object[] getArguments(Step step, StepImplementation implementation) { Method method = implementation.getMethod(); Parameter[] parameters = method.getParameters(); Object[] arguments = new Object[parameters.length]; if (parameters.length > 0) { String text = step.getText(); Pattern pattern = implementation.getPattern(); Matcher matcher = pattern.matcher(text); checkState(matcher.find(), "unable to locate substitution parameters for pattern %s with input %s", pattern.pattern(), text); int groupCount = matcher.groupCount(); ConversionService conversionService = SpringPreProcessor.getBean(ConversionService.class); for (int i = 0; i < groupCount; i++) { String parameterAsString = matcher.group(i + 1); Parameter parameter = parameters[i]; Class<?> parameterType = parameter.getType(); Object converted = conversionService.convert(parameterAsString, parameterType); arguments[i] = converted; } } return arguments; }
public static Pattern pathCompiler(String path, Method method) { Parameter[] parameters = method.getParameters(); for (Parameter parameter : parameters) { if (parameter.getAnnotations().length == 0) { continue; } Annotation annotation = parameter.getAnnotations()[0]; if (annotation instanceof PathVariable) { //如果是字符串 if (parameter.getType() == String.class) { path = path.replace("{" + parameter.getName() + "}", "[0-9\\d\\D]*"); } //如果是数字 else if (parameter.getType() == Integer.class || parameter.getType() == Long.class) { path = path.replace("{" + parameter.getName() + "}", "[0-9]*"); } } } return Pattern.compile(path); }
@Test public void passAnnotations() throws Exception { check(ImmutableValForPass.class.getAnnotation(A1.class)).notNull(); check(ImmutableValForPass.class.getAnnotation(A2.class)).notNull(); check(ImmutableValForPass.class.getAnnotation(B1.class)).isNull(); Parameter parameter = ImmutableValForPass.class.getConstructor(int.class).getParameters()[0]; check(parameter.getAnnotation(A1.class)).notNull(); check(parameter.getAnnotation(A2.class)).notNull(); }
public DockerDriverHandler(ExtensionContext context, Parameter parameter, Optional<Object> testInstance, AnnotationsReader annotationsReader) { this.context = context; this.parameter = parameter; this.testInstance = testInstance; this.annotationsReader = annotationsReader; this.dockerService = new DockerService(); this.containers = new LinkedHashMap<>(); this.selenoidConfig = new SelenoidConfig(); }
private Object getMock(Parameter parameter, ExtensionContext extensionContext) { Class<?> mockType = parameter.getType(); ExtensionContext.Store mocks = extensionContext.getStore(ExtensionContext.Namespace.create(MockitoExtension.class, mockType)); String mockName = getMockName(parameter); if (mockName != null) { return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName)); } else { return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType)); } }
static <T> boolean hasNamedParameterSupport(Class<T> classDefinition) { for (Constructor constructor : classDefinition.getConstructors()) { for (Parameter parameter : constructor.getParameters()) { return parameter.isNamePresent(); } } return true; }
private Object getMock(Parameter parameter, ExtensionContext extensionContext) { Class<?> mockType = parameter.getType(); Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType)); String mockName = getMockName(parameter); if (mockName != null) { return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName)); } else { return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType)); } }
private Object getMock(Parameter parameter, ExtensionContext extensionContext) { Class<?> mockType = parameter.getType(); Store mocks = extensionContext .getStore(Namespace.create(MockitoExtension.class, mockType)); String mockName = getMockName(parameter); if (mockName != null) { return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName)); } else { return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType)); } }
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { ChromeOptions chromeOptions = new ChromeOptions(); // @Arguments Arguments arguments = parameter.getAnnotation(Arguments.class); if (arguments != null) { stream(arguments.value()).forEach(chromeOptions::addArguments); } // @Extensions Extensions extensions = parameter.getAnnotation(Extensions.class); if (extensions != null) { for (String extension : extensions.value()) { chromeOptions.addExtensions(getExtension(extension)); } } // @Binary Binary binary = parameter.getAnnotation(Binary.class); if (binary != null) { chromeOptions.setBinary(binary.value()); } // @Options Object optionsFromAnnotatedField = annotationsReader .getOptionsFromAnnotatedField(testInstance, Options.class); if (optionsFromAnnotatedField != null) { chromeOptions = ((ChromeOptions) optionsFromAnnotatedField) .merge(chromeOptions); } return chromeOptions; }
/** * Find all handler mehtods of the resource. * * @param resourceInstance The instance. */ private void findResourceMethods(Object resourceInstance) { for (Method declaredMethod : resourceInstance.getClass().getDeclaredMethods()) { Path methodPath = declaredMethod.getAnnotation(Path.class); if (methodPath == null) { continue; } Consumes consumes = declaredMethod.getAnnotation(Consumes.class); Produces produces = declaredMethod.getAnnotation(Produces.class); HTTPMethod method = HTTPMethod.GET; if (declaredMethod.isAnnotationPresent(POST.class)) { method = HTTPMethod.POST; } else if (declaredMethod.isAnnotationPresent(DELETE.class)) { method = HTTPMethod.DELETE; } else if (declaredMethod.isAnnotationPresent(PUT.class)) { method = HTTPMethod.PUT; } else if (declaredMethod.isAnnotationPresent(PATCH.class)) { method = HTTPMethod.PATCH; } ResourceMethod resourceMethod = new ResourceMethod(methodPath.value(), method, consumes.value(), produces.value(), declaredMethod, resourceInstance); for (Parameter parameter : declaredMethod.getParameters()) { if (parameter.isAnnotationPresent(PostKey.class)) { resourceMethod.addPostParam(parameter.getAnnotation(PostKey.class).value()); } } this.resourceMethods.put(methodPath.value(), resourceMethod); } }
private String getMockName(Parameter parameter) { String explicitMockName = parameter.getAnnotation(Mock.class).name().trim(); if (!explicitMockName.isEmpty()) { return explicitMockName; } else if (parameter.isNamePresent()) { return parameter.getName(); } return null; }
public static DetailFieldStrategy getCreationStrategy(Parameter p, Class<?> parametrizedClass) { LOGGER.info("Seleccionando estrategia para para el parametro del request {} , con la clase parametrica {}", p, parametrizedClass); return DetailFieldCreatedStrategyFactory.getCreationStrategy(p.getParameterizedType(), Optional.ofNullable(parametrizedClass)); }
private void findPayloadParameter(){ if(this.method.getParameterCount() == 0){ throw new IllegalStateException("Service methods must have at least one receiving parameter"); } else if(this.method.getParameterCount() == 1){ this.payloadParameter = new MethodParameter(this.method, 0); } int payloadAnnotations = Flux.just(this.method.getParameters()) .filter(parameter -> parameter.getAnnotation(Payload.class) != null) .reduce(0, (a, parameter) -> { return a+1; }) .block(); if(payloadAnnotations > 1){ throw new IllegalStateException("Service methods can have at most one @Payload annotated parameters"); } for(int i=0; i<this.method.getParameters().length; i++){ Parameter p = this.method.getParameters()[i]; if(p.getAnnotation(Payload.class) != null){ this.payloadParameter = new MethodParameter(this.method, i); break; } } if(this.payloadParameter == null){ throw new IllegalStateException("Service methods annotated with more than one parameter must declare one @Payload parameter"); } resolvePayloadType(); }
private void init() { HttpMethod httpMethod = httpMethodFor(method); List<Parameter> parameterInfos = javaslang.collection.List.of(method.getParameters()); NoBody noBodyAnnotation = method.getAnnotation(NoBody.class); hasReturn = returnsVoid(method); if (parameterInfos.size() == 0) { return; } if (httpMethod == HttpMethod.GET) { hasBody = false; } else if (httpMethod == HttpMethod.POST || httpMethod == HttpMethod.DELETE || httpMethod == HttpMethod.PUT) { if (parameterInfos.size() > 0) { hasBody = true; } if (noBodyAnnotation != null) { hasBody = false; } } else { throw new RuntimeException("come back here : MethodToRestParameters.init()"); } if (hasBody) { // first parameter of the method will be assigned with the body content headerNames = parameterInfos.tail().map(p -> mapName(p)).toList(); } else { headerNames = parameterInfos.map(p -> mapName(p)).toList(); } }
private static String mapName(Parameter p){ String name; if(p.getClass().isAssignableFrom(Exchange.class)){ name = "exchange"; }else { name = p.getName(); } return name; }
public static byte[] generateMethodArgsUpdater(Class<?> classToProxy, Method method, int methodId) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); String classToProxyDescriptor = Type.getDescriptor(classToProxy); String classToProxyInternalName = Type.getInternalName(classToProxy); String suffix = SUFFIX_START + method.getName() + methodId; String selfClassInternalName = classToProxyInternalName + suffix; String selfClassDescriptor = BytecodeGenUtils.makeSuffixClassDescriptor(classToProxyDescriptor, suffix); String argsClassInternalName = classToProxyInternalName + MethodArgumentsGenerator.SUFFIX_START + method.getName() + methodId; String constDesc = Type.getMethodDescriptor(Type.VOID_TYPE, Stream.concat(Stream.of(List.class), Stream.of(method.getParameterTypes())).map(Type::getType) .toArray(Type[]::new)); cw.visit(52, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, selfClassInternalName, null, "java/lang/Object", new String[] { "io/primeval/reflex/arguments/ArgumentsUpdater" }); Parameter[] parameters = method.getParameters(); generateFields(method, cw, parameters); generateConstructor(method, cw, selfClassInternalName, selfClassDescriptor, constDesc, parameters); generateHashCodeMethod(cw, selfClassInternalName, selfClassDescriptor, parameters); generateEqualsMethod(cw, selfClassInternalName, selfClassDescriptor, parameters); generateToStringMethod(cw, selfClassInternalName, selfClassDescriptor, parameters); generateUpdateMethod(cw, selfClassInternalName, selfClassDescriptor, argsClassInternalName, constDesc, parameters); generateParametersGetter(cw, selfClassInternalName, selfClassDescriptor); generateArgumentSetters(cw, selfClassInternalName, selfClassDescriptor, parameters); generateArgumentGetters(cw, selfClassInternalName, selfClassDescriptor, parameters); cw.visitEnd(); return cw.toByteArray(); }
@Override public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { java.lang.reflect.Parameter parameter = parameterContext.getParameter(); Executable executable = parameter.getDeclaringExecutable(); return (executable instanceof Constructor && AnnotatedElementUtils.hasAnnotation(executable, Autowired.class)) || isAutowirable(parameter); }
@Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { Parameter parameter = parameterContext.getParameter(); Class<?> testClass = extensionContext.getTestClass().get(); ApplicationContext applicationContext = getApplicationContext(extensionContext); return resolveDependency(parameter, testClass, applicationContext); }
static Object resolveDependency(Parameter parameter, Class<?> containingClass, ApplicationContext applicationContext) { boolean required = findMergedAnnotation(parameter, Autowired.class).map(Autowired::required).orElse(true); MethodParameter methodParameter = SynthesizingMethodParameter.forParameter(parameter); DependencyDescriptor descriptor = new DependencyDescriptor(methodParameter, required); descriptor.setContainingClass(containingClass); return applicationContext.getAutowireCapableBeanFactory().resolveDependency(descriptor, null); }
private static Object getAnnotationParam(Parameter parameter, String paramName, Request request) throws Exception { Class<?> argType = parameter.getType(); Param param = parameter.getAnnotation(Param.class); if (null != param) { return getQueryParam( ParamStrut.builder().argType(argType).param(param).paramName(paramName).request(request).build()); } BodyParam bodyParam = parameter.getAnnotation(BodyParam.class); if (null != bodyParam) { return getBodyParam(ParamStrut.builder().argType(argType).request(request).build()); } PathParam pathParam = parameter.getAnnotation(PathParam.class); if (null != pathParam) { return getPathParam(ParamStrut.builder().argType(argType).pathParam(pathParam).paramName(paramName) .request(request).build()); } HeaderParam headerParam = parameter.getAnnotation(HeaderParam.class); if (null != headerParam) { return getHeader(ParamStrut.builder().argType(argType).headerParam(headerParam).paramName(paramName) .request(request).build()); } // cookie param CookieParam cookieParam = parameter.getAnnotation(CookieParam.class); if (null != cookieParam) { return getCookie(ParamStrut.builder().argType(argType).cookieParam(cookieParam).paramName(paramName) .request(request).build()); } // form multipart MultipartParam multipartParam = parameter.getAnnotation(MultipartParam.class); if (null != multipartParam && argType == FileItem.class) { String name = StringKit.isBlank(multipartParam.value()) ? paramName : multipartParam.value(); return request.fileItem(name).orElse(null); } return null; }
@Test public void shouldCreateKeyForSimpleParameter() throws Exception { Parameter parameter = getClass().getDeclaredMethod("method1", List.class).getParameters()[0]; Key key = Key.of(parameter); assertThat(key).isNotNull(); assertThat(key.toString()).isEqualTo("{java.util.List<java.lang.String>}"); }
public static Optional<Pair<Class<?>, String>> lookup(final Parameter param) { final Pair<Class<?>, String> pair = predefinedParameters.get(param.getType().getName()); if (pair != null) { return Optional.of(pair); } return Optional.empty(); }
void registerFunction(String name, Method method) { if (method.getReturnType().equals(Double.TYPE) || method.getReturnType().equals(Integer.TYPE) || method.getReturnType().equals(Long.TYPE)) { for (Parameter parameter : method.getParameters()) { if (!parameter.getType().equals(Double.TYPE)) { throw new IllegalArgumentException("All method parameters must be doubles"); } } method.setAccessible(true); functions.put(name, method); } else { throw new IllegalArgumentException("Method must return a number"); } }
private void processAnnotationOnMethod(Method method, MethodMetadata.Builder requestTemplateBuilder) { AnnotatedTypeMetadata methodMetadata = new StandardMethodMetadata(method); Parameter[] parameters = method.getParameters(); processRequestMappingAnnotation(methodMetadata, requestTemplateBuilder); for (int i = 0; i < parameters.length; i++) { Parameter parameter = parameters[i]; processAnnotationsOnParameter(requestTemplateBuilder, parameter, i); if (parameter.getAnnotations().length == 0) { requestTemplateBuilder.body(i, parameter.getParameterizedType()); } } }
/** * 判断参数是否是Context参数 * * @param parameter * 参数 * @return 如果返回true说明此参数是Context类型 */ private static boolean isContextParam(Parameter parameter) { Annotation[] annotations = parameter.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof Context) { return true; } } return false; }
public void run() throws NoSuchMethodException { final Class<?> cls = noName; System.err.println("Trying " + cls); final Method method = cls.getMethod("m", int.class, int.class); final Parameter[] params = method.getParameters(); System.err.println("Name " + params[0].getName()); System.err.println("Name " + params[1].getName()); }
static String parameterRefNameOrNull(final Parameter parameter) { final Spockito.Ref ref = parameter.getAnnotation(Spockito.Ref.class); if (ref == null) { return parameter.isNamePresent() ? parameter.getName() : null; } else { return ref.value(); } }