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/12/15 18:17:37 UTC

[GitHub] [maven] gnodet commented on a diff in pull request #914: Generate or implement some `toString`s

gnodet commented on code in PR #914:
URL: https://github.com/apache/maven/pull/914#discussion_r1049989101


##########
maven-model/src/test/java/org/apache/maven/model/BuildTest.java:
##########
@@ -53,4 +53,12 @@ public void testToStringNullSafe()
         assertNotNull( new Build().toString() );
     }
 
+    public void testToStringNotNonsense()
+    {
+        Build build = new Build();
+
+        String s = build.toString();
+
+        assert "Build(super=BuildBase(super=PluginConfiguration(super=PluginContainer())))".equals( s ) : s;

Review Comment:
   That's a very verbose and not really useful `toString()` ...



##########
maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java:
##########
@@ -53,4 +53,36 @@ public void testToStringNullSafe()
         assertNotNull( new Organization().toString() );
     }
 
+
+    public void testToStringNotNonsense11()
+    {
+        Organization org = new Organization();
+        org.setName( "Testing Maven Unit" );
+        org.setUrl( "https://maven.localdomain" );
+
+        assertEquals( "name = 'Testing Maven Unit'\nurl = 'https://maven.localdomain'", org.toString() );

Review Comment:
   That looks wrong.  The `toString()` result should at least have the simple class name in it.
   Same for `MailingList`, `Scm` and others...



##########
maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java:
##########
@@ -53,4 +53,36 @@ public void testToStringNullSafe()
         assertNotNull( new Organization().toString() );
     }
 
+
+    public void testToStringNotNonsense11()
+    {
+        Organization org = new Organization();
+        org.setName( "Testing Maven Unit" );
+        org.setUrl( "https://maven.localdomain" );
+
+        assertEquals( "name = 'Testing Maven Unit'\nurl = 'https://maven.localdomain'", org.toString() );
+    }
+
+    public void testToStringNotNonsense10()
+    {
+        Organization org = new Organization();
+        org.setName( "Testing Maven Unit" );
+
+        assertEquals( "name = 'Testing Maven Unit'\nurl = 'null'", org.toString() );

Review Comment:
   The `'null'` definitely looks wrong.  If quotes are added when there is a string, it should be `url = null` when the url is actually `null` (with no quotes).



-- 
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