You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/10/26 12:35:39 UTC

[GitHub] [maven-plugin-tools] kwin commented on a diff in pull request #159: [MPLUGIN-427] Expose generics information of parameter types in report

kwin commented on code in PR #159:
URL: https://github.com/apache/maven-plugin-tools/pull/159#discussion_r1005619793


##########
maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScannerTest.java:
##########
@@ -76,4 +80,48 @@ void scanDeprecatedMojoAnnotatins() throws ExtractionException, IOException
             .isEqualTo( "property.anotherNotDeprecated" );
     }
 
+    @Test
+    void scanParametersWithGenerics() throws ExtractionException, IOException
+    {
+        File directoryToScan = new File( ParametersWithGenericsMojo.class.getResource( "" ).getFile() );
+
+        scanner.enableLogging( mock( Logger.class ) );
+        Map<String, MojoAnnotatedClass> result = scanner.scanDirectory(
+            directoryToScan, Collections.singletonList( "ParametersWithGenericsMojo**.class" ), null, false );
+
+        assertThat( result ).hasSize( 2 ); // mojo and nested class
+
+        MojoAnnotatedClass annotatedClass = result.get( ParametersWithGenericsMojo.class.getName() );
+        assertThat( annotatedClass.getClassName() ).isEqualTo( ParametersWithGenericsMojo.class.getName() );
+
+        ParameterAnnotationContent parameter = annotatedClass.getParameters().get( "string" );
+        assertNotNull( parameter );
+        assertEquals( "java.lang.String", parameter.getClassName() );
+        assertThat( parameter.getTypeParameters() ).isEmpty();
+
+        parameter = annotatedClass.getParameters().get( "stringBooleanMap" );
+        assertNotNull( parameter );
+        assertEquals( "java.util.Map", parameter.getClassName() );
+        assertThat( parameter.getTypeParameters() ).contains( "java.lang.String", "java.lang.Boolean" );

Review Comment:
   Done in https://github.com/apache/maven-plugin-tools/pull/159/commits/4816ac73c9f622a7122c56ee6b478c39b6bc7211. I am so used to using Hamcrest, where `contains` has other semantics.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org