[ 
https://issues.apache.org/jira/browse/MPLUGIN-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17624403#comment-17624403
 ] 

ASF GitHub Bot commented on MPLUGIN-427:
----------------------------------------

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


##########
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:
   Maybe:
   ```
   assertThat(..). containsExactly( ... )
   ```
   





> report: Expose generics information of Collection and Map types
> ---------------------------------------------------------------
>
>                 Key: MPLUGIN-427
>                 URL: https://issues.apache.org/jira/browse/MPLUGIN-427
>             Project: Maven Plugin Tools
>          Issue Type: Improvement
>          Components: Plugin Plugin
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>
> Currently for mojo parameters of type Collection/Map the type of the items 
> are not exposed. For example in 
> https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#dependencySourceExcludes
>  the type of items in the {{java.util.List}} are not exposed.
> As this information is crucial it should be part of the report.
> The plugin descriptor is very vague about the {{type}} element of the 
> parameter: 
> https://maven.apache.org/ref/3.8.6/maven-plugin-api/plugin.html#parameter



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to