From 007cddb6f916e811ce4819a42ad57befdf30cadd Mon Sep 17 00:00:00 2001 From: jdyjjj <1410234026@qq.com> Date: Thu, 21 Apr 2022 09:23:05 +0800 Subject: [PATCH 1/2] Fix #877 parameterVariableElement() in ParameterSpecTest failed --- .../squareup/javapoet/ParameterSpecTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/squareup/javapoet/ParameterSpecTest.java b/src/test/java/com/squareup/javapoet/ParameterSpecTest.java index 561eebfda..47af216cd 100644 --- a/src/test/java/com/squareup/javapoet/ParameterSpecTest.java +++ b/src/test/java/com/squareup/javapoet/ParameterSpecTest.java @@ -17,6 +17,7 @@ import com.google.testing.compile.CompilationRule; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.annotation.Nullable; import javax.lang.model.element.ExecutableElement; @@ -111,16 +112,26 @@ public void foo(@Nullable final String bar) { } } + + private ExecutableElement findFirstExecutable(Collection elements, String name) { + for (ExecutableElement executableElement : elements) { + if (executableElement.getSimpleName().toString().equals(name)) { + return executableElement; + } + } + + throw new IllegalArgumentException(name + " not found in " + elements); + } + @Test public void parameterVariableElement() { TypeElement classElement = getElement(VariableElementParameterClass.class); List methods = methodsIn(elements.getAllMembers(classElement)); - ExecutableElement element = findFirst(methods, "foo"); + ExecutableElement element = findFirstExecutable(methods, "foo"); VariableElement parameterElement = element.getParameters().get(0); assertThat(ParameterSpec.get(parameterElement).toString()) - .isEqualTo("java.lang.String arg0"); + .isEqualTo("java.lang.String bar"); } - @Test public void addNonFinalModifier() { List modifiers = new ArrayList<>(); modifiers.add(Modifier.FINAL); From c3c9557f78e46c2bd34a9fca0a5c6b0f894751fa Mon Sep 17 00:00:00 2001 From: jdyjjj <1410234026@qq.com> Date: Tue, 17 May 2022 16:59:29 +0800 Subject: [PATCH 2/2] Update pom.xml --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index ff3d422e5..0276b51e9 100644 --- a/pom.xml +++ b/pom.xml @@ -153,6 +153,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + true + +