[MNG-7645] Implement some #toString() methods

* Implement Developer#toString()
* Implement IssueManagement#toString()
* Implement License#toString()
* Implement Build#toString()
* Implement Organization#toString()
* Implement MailingList#toString()
* Implement Scm#toString()

This closes #933
This commit is contained in:
Piotrek Żygieło 2022-12-20 22:26:50 +01:00 committed by Michael Osipov
parent 342c164366
commit 8833330b00
8 changed files with 258 additions and 0 deletions

View File

@ -661,6 +661,18 @@
]]>
</code>
</codeSegment>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
@Override
public String toString()
{
return "PluginContainer {}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
@ -684,6 +696,22 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "PluginConfiguration {" + super.toString() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class xdoc.anchorName="profile_build">
<name>BuildBase</name>
@ -758,6 +786,22 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "BuildBase {" + super.toString() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>Build</name>
@ -835,6 +879,22 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "Build {" + super.toString() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>CiManagement</name>
@ -1014,6 +1074,22 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "Contributor {name=" + getName() + ", email=" + getEmail() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>Dependency</name>
@ -1228,6 +1304,22 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "Developer {id=" + getId() + ", " + super.toString() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>Exclusion</name>
@ -1274,6 +1366,22 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "IssueManagement {system=" + getSystem() + ", url=" + getUrl() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>DistributionManagement</name>
@ -1395,6 +1503,22 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "License {name=" + getName() + ", url=" + getUrl() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>MailingList</name>
@ -1470,6 +1594,22 @@
<comment>We could probably have a specific element for a dev mailing list for things like CI,
and maybe even a specific element for the user and scm mailing lists. Then leave the more
lose structure for any other type of mailing list.</comment>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "MailingList {name=" + getName() + ", archive=" + getArchive() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>Organization</name>
@ -1489,6 +1629,22 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "Organization {name=" + getName() + ", url=" + getUrl() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>PatternSet</name>
@ -1771,6 +1927,20 @@
]]>
</code>
</codeSegment>
<codeSegment>
<version>4.0.0+</version>
<code>
<![CDATA[
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "Scm {connection=" + getConnection() + "}";
}
]]>
</code>
</codeSegment>
</codeSegments>
</class>
<class>

View File

@ -53,4 +53,12 @@ public class BuildTest {
public void testToStringNullSafe() {
assertNotNull(new Build().toString());
}
public void testToStringNotNonsense() {
Build build = new Build();
String s = build.toString();
assert "Build {BuildBase {PluginConfiguration {PluginContainer {}}}}".equals(s) : s;
}
}

View File

@ -53,4 +53,15 @@ public class DeveloperTest {
public void testToStringNullSafe() {
assertNotNull(new Developer().toString());
}
public void testToStringNotNonsense() {
Developer dev = new Developer();
dev.setName("Maven Tester");
dev.setEmail("tester@acme.localdomain");
dev.setId("20220118");
String s = dev.toString();
assert "Developer {id=20220118, Contributor {name=Maven Tester, email=tester@acme.localdomain}}".equals(s) : s;
}
}

View File

@ -53,4 +53,14 @@ public class IssueManagementTest {
public void testToStringNullSafe() {
assertNotNull(new IssueManagement().toString());
}
public void testToStringNotNonsense() {
IssueManagement im = new IssueManagement();
im.setSystem("Velociraptor");
im.setUrl("https://velo.localdomain");
String s = im.toString();
assert "IssueManagement {system=Velociraptor, url=https://velo.localdomain}".equals(s) : s;
}
}

View File

@ -53,4 +53,14 @@ public class LicenseTest {
public void testToStringNullSafe() {
assertNotNull(new License().toString());
}
public void testToStringNotNonsense() {
License license = new License();
license.setName("Unlicense");
license.setUrl("http://lic.localdomain");
String s = license.toString();
assert "License {name=Unlicense, url=http://lic.localdomain}".equals(s) : s;
}
}

View File

@ -18,6 +18,7 @@
*/
package org.apache.maven.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -53,4 +54,13 @@ public class MailingListTest {
public void testToStringNullSafe() {
assertNotNull(new MailingList().toString());
}
public void testToStringNotNonsense() {
MailingList list = new MailingList();
list.setName("modello-dev");
String s = list.toString();
assertEquals("MailingList {name=modello-dev, archive=null}", s);
}
}

View File

@ -18,6 +18,7 @@
*/
package org.apache.maven.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -53,4 +54,32 @@ public class OrganizationTest {
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("Organization {name=Testing Maven Unit, url=https://maven.localdomain}", org.toString());
}
public void testToStringNotNonsense10() {
Organization org = new Organization();
org.setName("Testing Maven Unit");
assertEquals("Organization {name=Testing Maven Unit, url=null}", org.toString());
}
public void testToStringNotNonsense01() {
Organization org = new Organization();
org.setUrl("https://maven.localdomain");
assertEquals("Organization {name=null, url=https://maven.localdomain}", org.toString());
}
public void testToStringNotNonsense00() {
Organization org = new Organization();
assertEquals("Organization {name=null, url=null}", org.toString());
}
}

View File

@ -18,6 +18,7 @@
*/
package org.apache.maven.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -53,4 +54,13 @@ public class ScmTest {
public void testToStringNullSafe() {
assertNotNull(new Scm().toString());
}
public void testToStringNotNonsense() {
Scm scm = new Scm();
scm.setConnection("scm:git:git://git.localdomain/model");
String s = scm.toString();
assertEquals("Scm {connection=scm:git:git://git.localdomain/model}", s);
}
}