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 2021/10/07 18:26:33 UTC

[GitHub] [maven] arturobernalg opened a new pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

arturobernalg opened a new pull request #568:
URL: https://github.com/apache/maven/pull/568


   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
    - [X ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed 
          for the change (usually before you start working on it).  Trivial changes like typos do not 
          require a JIRA issue.  Your pull request should address just this issue, without 
          pulling in other changes.
    - [X ] Each commit in the pull request should have a meaningful subject line and body.
    - [ X] Format the pull request title like `[MNG-XXX] - Fixes bug in ApproximateQuantiles`,
          where you replace `MNG-XXX` with the appropriate JIRA issue. Best practice
          is to use the JIRA issue title in the pull request title and in the first line of the 
          commit message.
    - [ X] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ X] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will 
          be performed on your pull request automatically.
    - [ X] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under 
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ X] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


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



[GitHub] [maven] arturobernalg edited a comment on pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
arturobernalg edited a comment on pull request #568:
URL: https://github.com/apache/maven/pull/568#issuecomment-939299903


   > I not marked every occurrence ... I'm lazy .. please search for `.equals(`
   > By the way good work 👏
   
   HI @slachiewicz 
   I gonna close this PR and  open a new one (https://github.com/apache/maven/pull/576), it's more easy start from scratch that make revert ;)
   TY 


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



[GitHub] [maven] slawekjaranowski commented on a change in pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on a change in pull request #568:
URL: https://github.com/apache/maven/pull/568#discussion_r724460160



##########
File path: maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
##########
@@ -753,6 +754,7 @@ public void testCache()
         restrictions = version.getRestrictions();
         assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
 
-        assertFalse( spec.equals( version ), "check !VersionRange.createFromVersionSpec(x).equals(VersionRange.createFromVersion(x))" );
+        assertNotEquals( spec, version,
+                "check !VersionRange.createFromVersionSpec(x).equals(VersionRange.createFromVersion(x))" );

Review comment:
       `equals` test

##########
File path: maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
##########
@@ -71,15 +71,14 @@ public void testDependencyManagement()
         assertNotNull( set, "No artifacts" );
         assertTrue( set.size() > 0, "No Artifacts" );
         Iterator iter = set.iterator();
-        assertTrue( set.size() == 4, "Set size should be 4, is " + set.size() );
+        assertEquals( 4, set.size(), "Set size should be 4, is " + set.size() );
 
         while ( iter.hasNext() )
         {
             Artifact artifact = (Artifact) iter.next();
             System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
               + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
-            assertTrue( artifact.getVersion().equals( "1.0" ),
-                        "Incorrect version for " + artifact.getDependencyConflictId() );
+            assertEquals( "1.0", artifact.getVersion(), "Incorrect version for " + artifact.getDependencyConflictId() );

Review comment:
       equals test

##########
File path: maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
##########
@@ -70,19 +71,18 @@ public void testDependencyManagement()
         Set set = project1.getArtifacts();
         assertNotNull( set, "No artifacts" );
         assertTrue( set.size() > 0, "No Artifacts" );
-        assertTrue( set.size() == 3, "Set size should be 3, is " + set.size() );
+        assertEquals( 3, set.size(), "Set size should be 3, is " + set.size() );
 
         for ( Object aSet : set )
         {
             Artifact artifact = (Artifact) aSet;
-            assertFalse( artifact.getArtifactId().equals( "t07-d" ) );
+            assertNotEquals( "t07-d", artifact.getArtifactId() );

Review comment:
       equals test

##########
File path: maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
##########
@@ -47,12 +48,12 @@ public void testEquals()
 
         OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) );
 
-        assertFalse( filter1.equals( null ) );
-        assertTrue( filter1.equals( filter1 ) );
+        assertNotEquals( null, filter1 );
+        assertEquals( filter1, filter1 );
         assertEquals( filter1.hashCode(), filter1.hashCode() );
 
-        assertFalse( filter1.equals( filter2 ) );
-        assertFalse( filter2.equals( filter1 ) );
+        assertNotEquals( filter1, filter2 );
+        assertNotEquals( filter2, filter1 );

Review comment:
       equals test

##########
File path: maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
##########
@@ -189,20 +190,20 @@ public void testHashCode()
     {
         ArtifactVersion v1 = newArtifactVersion( "1" );
         ArtifactVersion v2 = newArtifactVersion( "1.0" );
-        assertEquals( true, v1.equals( v2 ) );
+        assertTrue( v1.equals( v2 ) );
         assertEquals( v1.hashCode(), v2.hashCode() );
     }
 
     @Test
     public void testEqualsNullSafe()
     {
-        assertFalse( newArtifactVersion( "1" ).equals( null ) );
+        assertNotEquals( null, newArtifactVersion( "1" ) );
     }
 
     @Test
     public void testEqualsTypeSafe()
     {
-        assertFalse( newArtifactVersion( "1" ).equals( "non-an-artifact-version-instance" ) );
+        assertNotEquals( "non-an-artifact-version-instance", newArtifactVersion( "1" ) );

Review comment:
       the same show what we want to test

##########
File path: maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
##########
@@ -189,20 +190,20 @@ public void testHashCode()
     {
         ArtifactVersion v1 = newArtifactVersion( "1" );
         ArtifactVersion v2 = newArtifactVersion( "1.0" );
-        assertEquals( true, v1.equals( v2 ) );
+        assertTrue( v1.equals( v2 ) );
         assertEquals( v1.hashCode(), v2.hashCode() );
     }
 
     @Test
     public void testEqualsNullSafe()
     {
-        assertFalse( newArtifactVersion( "1" ).equals( null ) );
+        assertNotEquals( null, newArtifactVersion( "1" ) );

Review comment:
       in this case `assertFalse` is more readable, we want to test `equals`
   original assertions show what we want to do in new `equals` method is called somewhere in `assertNotEquals`

##########
File path: maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
##########
@@ -76,8 +76,7 @@ public void testDependencyManagement()
             System.out.println(
                 "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: "
                     + artifact.getScope() );
-            assertTrue( artifact.getVersion().equals( "1.0" ),
-                        "Incorrect version for " + artifact.getDependencyConflictId() );
+            assertEquals( "1.0", artifact.getVersion(), "Incorrect version for " + artifact.getDependencyConflictId() );

Review comment:
       equals test

##########
File path: maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
##########
@@ -47,12 +48,12 @@ public void testEquals()
 
         OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) );
 
-        assertFalse( filter1.equals( null ) );
-        assertTrue( filter1.equals( filter1 ) );
+        assertNotEquals( null, filter1 );
+        assertEquals( filter1, filter1 );

Review comment:
       equals test




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



[GitHub] [maven] arturobernalg commented on pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
arturobernalg commented on pull request #568:
URL: https://github.com/apache/maven/pull/568#issuecomment-938748794


   > in this case of testing `equals` methods assertTrue/assertFalse is more readable, we want to test equals
   > 
   > original assertions show what we want to do, when using assetions `assertEquals` `equals` method is called somewhere in somehow in assertEquals
   
   HI @slachiewicz  although I´m 100% agree with you I´ve reverted the marked changes
   TY


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



[GitHub] [maven] slawekjaranowski commented on pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on pull request #568:
URL: https://github.com/apache/maven/pull/568#issuecomment-938941294


   I not marked every occurrence ... I'm lazy .. please search for `.equals(`
   By the way good work 👏 


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



[GitHub] [maven] arturobernalg closed pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
arturobernalg closed pull request #568:
URL: https://github.com/apache/maven/pull/568


   


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



[GitHub] [maven] arturobernalg commented on pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
arturobernalg commented on pull request #568:
URL: https://github.com/apache/maven/pull/568#issuecomment-939299903


   > I not marked every occurrence ... I'm lazy .. please search for `.equals(`
   > By the way good work 👏
   
   HI @slachiewicz 
   I gonna close this PR and  open a new one, it's more easy start from scratch that make revert ;)
   TY 


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



[GitHub] [maven] slawekjaranowski commented on a change in pull request #568: MNG-7287 - Simplify assertion with simpler and equivalent calls.

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on a change in pull request #568:
URL: https://github.com/apache/maven/pull/568#discussion_r724460160



##########
File path: maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
##########
@@ -753,6 +754,7 @@ public void testCache()
         restrictions = version.getRestrictions();
         assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
 
-        assertFalse( spec.equals( version ), "check !VersionRange.createFromVersionSpec(x).equals(VersionRange.createFromVersion(x))" );
+        assertNotEquals( spec, version,
+                "check !VersionRange.createFromVersionSpec(x).equals(VersionRange.createFromVersion(x))" );

Review comment:
       `equals` test

##########
File path: maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
##########
@@ -71,15 +71,14 @@ public void testDependencyManagement()
         assertNotNull( set, "No artifacts" );
         assertTrue( set.size() > 0, "No Artifacts" );
         Iterator iter = set.iterator();
-        assertTrue( set.size() == 4, "Set size should be 4, is " + set.size() );
+        assertEquals( 4, set.size(), "Set size should be 4, is " + set.size() );
 
         while ( iter.hasNext() )
         {
             Artifact artifact = (Artifact) iter.next();
             System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
               + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
-            assertTrue( artifact.getVersion().equals( "1.0" ),
-                        "Incorrect version for " + artifact.getDependencyConflictId() );
+            assertEquals( "1.0", artifact.getVersion(), "Incorrect version for " + artifact.getDependencyConflictId() );

Review comment:
       equals test

##########
File path: maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
##########
@@ -70,19 +71,18 @@ public void testDependencyManagement()
         Set set = project1.getArtifacts();
         assertNotNull( set, "No artifacts" );
         assertTrue( set.size() > 0, "No Artifacts" );
-        assertTrue( set.size() == 3, "Set size should be 3, is " + set.size() );
+        assertEquals( 3, set.size(), "Set size should be 3, is " + set.size() );
 
         for ( Object aSet : set )
         {
             Artifact artifact = (Artifact) aSet;
-            assertFalse( artifact.getArtifactId().equals( "t07-d" ) );
+            assertNotEquals( "t07-d", artifact.getArtifactId() );

Review comment:
       equals test

##########
File path: maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
##########
@@ -47,12 +48,12 @@ public void testEquals()
 
         OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) );
 
-        assertFalse( filter1.equals( null ) );
-        assertTrue( filter1.equals( filter1 ) );
+        assertNotEquals( null, filter1 );
+        assertEquals( filter1, filter1 );
         assertEquals( filter1.hashCode(), filter1.hashCode() );
 
-        assertFalse( filter1.equals( filter2 ) );
-        assertFalse( filter2.equals( filter1 ) );
+        assertNotEquals( filter1, filter2 );
+        assertNotEquals( filter2, filter1 );

Review comment:
       equals test

##########
File path: maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
##########
@@ -189,20 +190,20 @@ public void testHashCode()
     {
         ArtifactVersion v1 = newArtifactVersion( "1" );
         ArtifactVersion v2 = newArtifactVersion( "1.0" );
-        assertEquals( true, v1.equals( v2 ) );
+        assertTrue( v1.equals( v2 ) );
         assertEquals( v1.hashCode(), v2.hashCode() );
     }
 
     @Test
     public void testEqualsNullSafe()
     {
-        assertFalse( newArtifactVersion( "1" ).equals( null ) );
+        assertNotEquals( null, newArtifactVersion( "1" ) );
     }
 
     @Test
     public void testEqualsTypeSafe()
     {
-        assertFalse( newArtifactVersion( "1" ).equals( "non-an-artifact-version-instance" ) );
+        assertNotEquals( "non-an-artifact-version-instance", newArtifactVersion( "1" ) );

Review comment:
       the same show what we want to test

##########
File path: maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
##########
@@ -189,20 +190,20 @@ public void testHashCode()
     {
         ArtifactVersion v1 = newArtifactVersion( "1" );
         ArtifactVersion v2 = newArtifactVersion( "1.0" );
-        assertEquals( true, v1.equals( v2 ) );
+        assertTrue( v1.equals( v2 ) );
         assertEquals( v1.hashCode(), v2.hashCode() );
     }
 
     @Test
     public void testEqualsNullSafe()
     {
-        assertFalse( newArtifactVersion( "1" ).equals( null ) );
+        assertNotEquals( null, newArtifactVersion( "1" ) );

Review comment:
       in this case `assertFalse` is more readable, we want to test `equals`
   original assertions show what we want to do in new `equals` method is called somewhere in `assertNotEquals`

##########
File path: maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
##########
@@ -76,8 +76,7 @@ public void testDependencyManagement()
             System.out.println(
                 "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: "
                     + artifact.getScope() );
-            assertTrue( artifact.getVersion().equals( "1.0" ),
-                        "Incorrect version for " + artifact.getDependencyConflictId() );
+            assertEquals( "1.0", artifact.getVersion(), "Incorrect version for " + artifact.getDependencyConflictId() );

Review comment:
       equals test

##########
File path: maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
##########
@@ -47,12 +48,12 @@ public void testEquals()
 
         OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) );
 
-        assertFalse( filter1.equals( null ) );
-        assertTrue( filter1.equals( filter1 ) );
+        assertNotEquals( null, filter1 );
+        assertEquals( filter1, filter1 );

Review comment:
       equals test




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