You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2021/04/28 11:24:06 UTC

[commons-text] branch master updated (ad44310 -> 396f277)

This is an automated email from the ASF dual-hosted git repository.

kinow pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git.


    from ad44310  Merge branch 'pr-229'
     new 75eea11  [TEXT-201] Simplify assertion
     new 832c5bd  [TEXT-201] Changelog
     new 396f277  Merge branch 'pr-224'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  1 +
 .../commons/text/ExtendedMessageFormatTest.java    | 29 +++++++++++-----------
 .../org/apache/commons/text/StrBuilderTest.java    | 13 +++++-----
 .../org/apache/commons/text/StrTokenizerTest.java  | 11 ++++----
 .../apache/commons/text/StringTokenizerTest.java   | 11 ++++----
 .../apache/commons/text/TextStringBuilderTest.java | 13 +++++-----
 .../commons/text/lookup/NullStringLookupTest.java  |  4 +--
 .../text/similarity/IntersectionResultTest.java    |  8 +++---
 8 files changed, 45 insertions(+), 45 deletions(-)

[commons-text] 01/03: [TEXT-201] Simplify assertion

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 75eea11fa7d2a8789c299bda8680e675ae3a2200
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Tue Apr 20 07:08:48 2021 +0200

    [TEXT-201] Simplify assertion
---
 .../commons/text/ExtendedMessageFormatTest.java    | 29 +++++++++++-----------
 .../org/apache/commons/text/StrBuilderTest.java    | 13 +++++-----
 .../org/apache/commons/text/StrTokenizerTest.java  | 11 ++++----
 .../apache/commons/text/StringTokenizerTest.java   | 11 ++++----
 .../apache/commons/text/TextStringBuilderTest.java | 13 +++++-----
 .../commons/text/lookup/NullStringLookupTest.java  |  4 +--
 .../text/similarity/IntersectionResultTest.java    |  8 +++---
 7 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
index c03703f..09b1365 100644
--- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
@@ -19,8 +19,7 @@ package org.apache.commons.text;
 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 import java.text.DateFormat;
 import java.text.FieldPosition;
@@ -336,7 +335,7 @@ public class ExtendedMessageFormatTest {
                 new ExtendedMessageFormat("Unterminated format element at position ", map);
 
         assertEquals("Unterminated format element at position ", extendedMessageFormatTwo.toPattern());
-        assertFalse(extendedMessageFormat.equals(extendedMessageFormatTwo));
+        assertNotEquals(extendedMessageFormat, extendedMessageFormatTwo);
     }
 
     /**
@@ -365,35 +364,35 @@ public class ExtendedMessageFormatTest {
         ExtendedMessageFormat other;
 
         // Same object
-        assertTrue(emf.equals(emf), "same, equals()");
+        assertEquals(emf, emf, "same, equals()");
         assertEquals(emf.hashCode(), emf.hashCode(), "same, hashcode()");
 
-        assertFalse(emf.equals(null), "null, equals");
+        assertNotEquals(null, emf, "null, equals");
 
         // Equal Object
         other = new ExtendedMessageFormat(pattern, Locale.US, fmtRegistry);
-        assertTrue(emf.equals(other), "equal, equals()");
-        assertTrue(emf.hashCode() == other.hashCode(), "equal, hashcode()");
+        assertEquals(emf, other, "equal, equals()");
+        assertEquals(emf.hashCode(), other.hashCode(), "equal, hashcode()");
 
         // Different Class
         other = new OtherExtendedMessageFormat(pattern, Locale.US, fmtRegistry);
-        assertFalse(emf.equals(other), "class, equals()");
-        assertTrue(emf.hashCode() == other.hashCode(), "class, hashcode()"); // same hashcode
+        assertNotEquals(emf, other, "class, equals()");
+        assertEquals(emf.hashCode(), other.hashCode(), "class, hashcode()"); // same hashcode
 
         // Different pattern
         other = new ExtendedMessageFormat("X" + pattern, Locale.US, fmtRegistry);
-        assertFalse(emf.equals(other), "pattern, equals()");
-        assertFalse(emf.hashCode() == other.hashCode(), "pattern, hashcode()");
+        assertNotEquals(emf, other, "pattern, equals()");
+        assertNotEquals(emf.hashCode(), other.hashCode(), "pattern, hashcode()");
 
         // Different registry
         other = new ExtendedMessageFormat(pattern, Locale.US, otherRegistry);
-        assertFalse(emf.equals(other), "registry, equals()");
-        assertFalse(emf.hashCode() == other.hashCode(), "registry, hashcode()");
+        assertNotEquals(emf, other, "registry, equals()");
+        assertNotEquals(emf.hashCode(), other.hashCode(), "registry, hashcode()");
 
         // Different Locale
         other = new ExtendedMessageFormat(pattern, Locale.FRANCE, fmtRegistry);
-        assertFalse(emf.equals(other), "locale, equals()");
-        assertTrue(emf.hashCode() == other.hashCode(), "locale, hashcode()"); // same hashcode
+        assertNotEquals(emf, other, "locale, equals()");
+        assertEquals(emf.hashCode(), other.hashCode(), "locale, hashcode()"); // same hashcode
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java b/src/test/java/org/apache/commons/text/StrBuilderTest.java
index 0c1e8ae..eb07f59 100644
--- a/src/test/java/org/apache/commons/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java
@@ -22,6 +22,7 @@ import static org.assertj.core.api.Assertions.fail;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -813,22 +814,22 @@ public class StrBuilderTest {
         assertTrue(sb1.equals(sb2));
         assertTrue(sb1.equals(sb1));
         assertTrue(sb2.equals(sb2));
-        assertTrue(sb1.equals((Object) sb2));
+        assertEquals(sb1, (Object) sb2);
 
         sb1.append("abc");
         assertFalse(sb1.equals(sb2));
-        assertFalse(sb1.equals((Object) sb2));
+        assertNotEquals(sb1, (Object) sb2);
 
         sb2.append("ABC");
         assertFalse(sb1.equals(sb2));
-        assertFalse(sb1.equals((Object) sb2));
+        assertNotEquals(sb1, (Object) sb2);
 
         sb2.clear().append("abc");
         assertTrue(sb1.equals(sb2));
-        assertTrue(sb1.equals((Object) sb2));
+        assertEquals(sb1, (Object) sb2);
 
-        assertFalse(sb1.equals(Integer.valueOf(1)));
-        assertFalse(sb1.equals("abc"));
+        assertNotEquals(sb1, Integer.valueOf(1));
+        assertNotEquals("abc", sb1);
     }
 
     // -----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/text/StrTokenizerTest.java
index 9a2ba6a..e44b093 100644
--- a/src/test/java/org/apache/commons/text/StrTokenizerTest.java
+++ b/src/test/java/org/apache/commons/text/StrTokenizerTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.text;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -44,8 +45,8 @@ public class StrTokenizerTest {
     private static final String TSV_SIMPLE_FIXTURE = "A\tb\tc";
 
     private void checkClone(final StrTokenizer tokenizer) {
-        assertFalse(StrTokenizer.getCSVInstance() == tokenizer);
-        assertFalse(StrTokenizer.getTSVInstance() == tokenizer);
+        assertNotSame(StrTokenizer.getCSVInstance(), tokenizer);
+        assertNotSame(StrTokenizer.getTSVInstance(), tokenizer);
     }
 
     // -----------------------------------------------------------------------
@@ -182,10 +183,8 @@ public class StrTokenizerTest {
         }
 
         assertEquals(expected.length, tokens.length, Arrays.toString(tokens));
-        assertTrue(nextCount == expected.length,
-                "could not cycle through entire token list using the 'hasNext' and 'next' methods");
-        assertTrue(prevCount == expected.length,
-                "could not cycle through entire token list using the 'hasPrevious' and 'previous' methods");
+        assertEquals(nextCount, expected.length, "could not cycle through entire token list using the 'hasNext' and 'next' methods");
+        assertEquals(prevCount, expected.length, "could not cycle through entire token list using the 'hasPrevious' and 'previous' methods");
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/text/StringTokenizerTest.java b/src/test/java/org/apache/commons/text/StringTokenizerTest.java
index 829ec22..b0701c4 100644
--- a/src/test/java/org/apache/commons/text/StringTokenizerTest.java
+++ b/src/test/java/org/apache/commons/text/StringTokenizerTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.text;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -43,8 +44,8 @@ public class StringTokenizerTest {
     private static final String TSV_SIMPLE_FIXTURE = "A\tb\tc";
 
     private void checkClone(final StringTokenizer tokenizer) {
-        assertFalse(StringTokenizer.getCSVInstance() == tokenizer);
-        assertFalse(StringTokenizer.getTSVInstance() == tokenizer);
+        assertNotSame(StringTokenizer.getCSVInstance(), tokenizer);
+        assertNotSame(StringTokenizer.getTSVInstance(), tokenizer);
     }
 
     // -----------------------------------------------------------------------
@@ -181,10 +182,8 @@ public class StringTokenizerTest {
         }
 
         assertEquals(expected.length, tokens.length, Arrays.toString(tokens));
-        assertTrue(nextCount == expected.length,
-                "could not cycle through entire token list using the 'hasNext' and 'next' methods");
-        assertTrue(prevCount == expected.length,
-                "could not cycle through entire token list using the 'hasPrevious' and 'previous' methods");
+        assertEquals(nextCount, expected.length, "could not cycle through entire token list using the 'hasNext' and 'next' methods");
+        assertEquals(prevCount, expected.length, "could not cycle through entire token list using the 'hasPrevious' and 'previous' methods");
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
index 8bf73e1..b15acef 100644
--- a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
@@ -21,6 +21,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -904,22 +905,22 @@ public class TextStringBuilderTest {
         assertTrue(sb1.equals(sb2));
         assertTrue(sb1.equals(sb1));
         assertTrue(sb2.equals(sb2));
-        assertTrue(sb1.equals((Object) sb2));
+        assertEquals(sb1, (Object) sb2);
 
         sb1.append("abc");
         assertFalse(sb1.equals(sb2));
-        assertFalse(sb1.equals((Object) sb2));
+        assertNotEquals(sb1, (Object) sb2);
 
         sb2.append("ABC");
         assertFalse(sb1.equals(sb2));
-        assertFalse(sb1.equals((Object) sb2));
+        assertNotEquals(sb1, (Object) sb2);
 
         sb2.set("abc");
         assertTrue(sb1.equals(sb2));
-        assertTrue(sb1.equals((Object) sb2));
+        assertEquals(sb1, (Object) sb2);
 
-        assertFalse(sb1.equals(Integer.valueOf(1)));
-        assertFalse(sb1.equals("abc"));
+        assertNotEquals(sb1, Integer.valueOf(1));
+        assertNotEquals("abc", sb1);
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
index 1cb3677..917455b 100644
--- a/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
@@ -27,8 +27,8 @@ public class NullStringLookupTest {
 
     @Test
     public void test() {
-        Assertions.assertEquals(null, StringLookupFactory.INSTANCE_NULL.lookup("EverythingIsNull"));
-        Assertions.assertEquals(null, StringLookupFactory.INSTANCE_NULL.lookup(null));
+        Assertions.assertNull(StringLookupFactory.INSTANCE_NULL.lookup("EverythingIsNull"));
+        Assertions.assertNull(StringLookupFactory.INSTANCE_NULL.lookup(null));
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java b/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
index c0a0e4c..e79fb62 100644
--- a/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
@@ -93,14 +93,14 @@ public class IntersectionResultTest {
         };
 
         // Test a different instance with same values
-        Assertions.assertTrue(results[0].equals(new IntersectionResult(0, 0, 0)));
+        Assertions.assertEquals(results[0], new IntersectionResult(0, 0, 0));
 
         final Object something = new Object();
         for (int i = 0; i < results.length; i++) {
-            Assertions.assertFalse(results[i].equals(something));
-            Assertions.assertFalse(results[i].equals(null));
+            Assertions.assertNotEquals(results[i], something);
+            Assertions.assertNotEquals(null, results[i]);
             for (int j = 0; j < results.length; j++) {
-                Assertions.assertTrue(results[i].equals(results[j]) == (i == j));
+                Assertions.assertEquals(results[i].equals(results[j]), (i == j));
             }
         }
     }

[commons-text] 02/03: [TEXT-201] Changelog

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 832c5bd597b8ec65c8a0e3f6c47b181ac464d508
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Wed Apr 28 23:22:14 2021 +1200

    [TEXT-201] Changelog
---
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 51bbc4d..2a623ae 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -82,6 +82,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="TEXT-200" type="update" dev="kinow" due-to="Arturo Bernal">Simplify statements.</action>
     <action issue="TEXT-197" type="update" dev="kinow" due-to="Arturo Bernal">Replace statement lambda with expression lambda.</action>
     <action issue="TEXT-204" type="update" dev="kinow" due-to="Arturo Bernal">Use static class inner class in tests.</action>
+    <action issue="TEXT-201" type="update" dev="kinow" due-to="Arturo Bernal">Simplify assertion.</action>
   </release>
   <release version="1.9" date="2020-07-21" description="Release 1.9. Requires Java 8.">
     <action issue="TEXT-166" type="fix" dev="kinow" due-to="Mikko Maunu">Removed non-existing parameter from Javadocs and spelled out parameters in throws.</action>

[commons-text] 03/03: Merge branch 'pr-224'

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 396f277cde512c98340ac3dd9dba1501916e5654
Merge: ad44310 832c5bd
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Wed Apr 28 23:23:02 2021 +1200

    Merge branch 'pr-224'
    
    This closes #224

 src/changes/changes.xml                            |  1 +
 .../commons/text/ExtendedMessageFormatTest.java    | 29 +++++++++++-----------
 .../org/apache/commons/text/StrBuilderTest.java    | 13 +++++-----
 .../org/apache/commons/text/StrTokenizerTest.java  | 11 ++++----
 .../apache/commons/text/StringTokenizerTest.java   | 11 ++++----
 .../apache/commons/text/TextStringBuilderTest.java | 13 +++++-----
 .../commons/text/lookup/NullStringLookupTest.java  |  4 +--
 .../text/similarity/IntersectionResultTest.java    |  8 +++---
 8 files changed, 45 insertions(+), 45 deletions(-)