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/19 22:37:13 UTC
[commons-text] branch master updated (25b847a -> ee5e4a8)
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 25b847a Merge branch 'pr-222'
new 4132527 [TEXT-197] Replace statement lambda with expression lambda
new 3a55506 [TEXT-197] Changelog
new ee5e4a8 Merge branch 'pr-219'
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 +
.../apache/commons/text/AlphabetConverterTest.java | 16 ++++------------
.../commons/text/ExtendedMessageFormatTest.java | 20 +++++---------------
.../apache/commons/text/FormattableUtilsTest.java | 4 +---
.../commons/text/RandomStringGeneratorTest.java | 12 +++---------
.../java/org/apache/commons/text/StrBuilderTest.java | 4 +---
.../apache/commons/text/TextStringBuilderTest.java | 4 +---
.../java/org/apache/commons/text/WordUtilsTest.java | 8 ++------
.../commons/text/lookup/FileStringLookupTest.java | 12 +++---------
.../text/lookup/JavaPlatformStringLookupTest.java | 4 +---
.../text/lookup/ResourceBundleStringLookupTest.java | 8 ++------
.../commons/text/lookup/ScriptStringLookupTest.java | 16 ++++------------
.../text/lookup/UrlDecoderStringLookupTest.java | 4 +---
.../text/lookup/UrlEncoderStringLookupTest.java | 4 +---
.../commons/text/lookup/UrlStringLookupTest.java | 16 ++++------------
.../commons/text/similarity/FuzzyScoreTest.java | 16 ++++------------
.../commons/text/similarity/HammingDistanceTest.java | 8 ++------
.../text/similarity/IntersectionResultTest.java | 20 +++++---------------
.../text/similarity/IntersectionSimilarityTest.java | 16 ++++------------
.../commons/text/similarity/JaccardDistanceTest.java | 12 +++---------
.../text/similarity/JaccardSimilarityTest.java | 12 +++---------
.../text/similarity/JaroWinklerDistanceTest.java | 12 +++---------
.../text/similarity/JaroWinklerSimilarityTest.java | 12 +++---------
23 files changed, 61 insertions(+), 180 deletions(-)
[commons-text] 01/03: [TEXT-197] Replace statement lambda with
expression lambda
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 41325273c5cf72fa09b51153ef9468fc7024306b
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Sun Apr 18 12:45:39 2021 +0200
[TEXT-197] Replace statement lambda with expression lambda
---
.../apache/commons/text/AlphabetConverterTest.java | 16 ++++------------
.../commons/text/ExtendedMessageFormatTest.java | 20 +++++---------------
.../apache/commons/text/FormattableUtilsTest.java | 4 +---
.../commons/text/RandomStringGeneratorTest.java | 12 +++---------
.../java/org/apache/commons/text/StrBuilderTest.java | 4 +---
.../apache/commons/text/TextStringBuilderTest.java | 4 +---
.../java/org/apache/commons/text/WordUtilsTest.java | 8 ++------
.../commons/text/lookup/FileStringLookupTest.java | 12 +++---------
.../text/lookup/JavaPlatformStringLookupTest.java | 4 +---
.../text/lookup/ResourceBundleStringLookupTest.java | 8 ++------
.../commons/text/lookup/ScriptStringLookupTest.java | 16 ++++------------
.../text/lookup/UrlDecoderStringLookupTest.java | 4 +---
.../text/lookup/UrlEncoderStringLookupTest.java | 4 +---
.../commons/text/lookup/UrlStringLookupTest.java | 16 ++++------------
.../commons/text/similarity/FuzzyScoreTest.java | 16 ++++------------
.../commons/text/similarity/HammingDistanceTest.java | 8 ++------
.../text/similarity/IntersectionResultTest.java | 20 +++++---------------
.../text/similarity/IntersectionSimilarityTest.java | 16 ++++------------
.../commons/text/similarity/JaccardDistanceTest.java | 12 +++---------
.../text/similarity/JaccardSimilarityTest.java | 12 +++---------
.../text/similarity/JaroWinklerDistanceTest.java | 12 +++---------
.../text/similarity/JaroWinklerSimilarityTest.java | 12 +++---------
22 files changed, 60 insertions(+), 180 deletions(-)
diff --git a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
index bb703a4..6308837 100644
--- a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
+++ b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
@@ -87,9 +87,7 @@ public class AlphabetConverterTest {
@Test
public void encodeFailureTest() {
- assertThatThrownBy(() -> {
- test(BINARY, NUMBERS, ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, "3");
- }).isInstanceOf(UnsupportedEncodingException.class).hasMessage("Couldn't find encoding for '3' in 3");
+ assertThatThrownBy(() -> test(BINARY, NUMBERS, ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, "3")).isInstanceOf(UnsupportedEncodingException.class).hasMessage("Couldn't find encoding for '3' in 3");
}
@Test
@@ -120,25 +118,19 @@ public class AlphabetConverterTest {
@Test
public void missingDoNotEncodeLettersFromEncodingTest() {
- assertThatThrownBy(() -> {
- AlphabetConverter.createConverterFromChars(ENGLISH_AND_NUMBERS, LOWER_CASE_ENGLISH, NUMBERS);
- }).isInstanceOf(IllegalArgumentException.class).hasMessage(
+ assertThatThrownBy(() -> AlphabetConverter.createConverterFromChars(ENGLISH_AND_NUMBERS, LOWER_CASE_ENGLISH, NUMBERS)).isInstanceOf(IllegalArgumentException.class).hasMessage(
"Can not use 'do not encode' list because encoding alphabet does not contain '0'");
}
@Test
public void missingDoNotEncodeLettersFromOriginalTest() {
- assertThatThrownBy(() -> {
- AlphabetConverter.createConverterFromChars(LOWER_CASE_ENGLISH, ENGLISH_AND_NUMBERS, NUMBERS);
- }).isInstanceOf(IllegalArgumentException.class).hasMessage(
+ assertThatThrownBy(() -> AlphabetConverter.createConverterFromChars(LOWER_CASE_ENGLISH, ENGLISH_AND_NUMBERS, NUMBERS)).isInstanceOf(IllegalArgumentException.class).hasMessage(
"Can not use 'do not encode' list because original alphabet does not contain '0'");
}
@Test
public void noEncodingLettersTest() {
- assertThatThrownBy(() -> {
- AlphabetConverter.createConverterFromChars(ENGLISH_AND_NUMBERS, NUMBERS, NUMBERS);
- }).isInstanceOf(IllegalArgumentException.class).hasMessage(
+ assertThatThrownBy(() -> AlphabetConverter.createConverterFromChars(ENGLISH_AND_NUMBERS, NUMBERS, NUMBERS)).isInstanceOf(IllegalArgumentException.class).hasMessage(
"Must have at least two encoding characters (excluding those in the 'do not encode' list), but has 0");
}
diff --git a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
index 9d1dd8a..c03703f 100644
--- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
@@ -482,39 +482,29 @@ public class ExtendedMessageFormatTest {
@Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionFive() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new ExtendedMessageFormat("j/[_D9{0,\"&'+0o", new HashMap<String, FormatFactory>());
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new ExtendedMessageFormat("j/[_D9{0,\"&'+0o", new HashMap<String, FormatFactory>()));
}
@Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionFour() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new ExtendedMessageFormat("RD,nXhM{}{", new HashMap<String, FormatFactory>());
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new ExtendedMessageFormat("RD,nXhM{}{", new HashMap<String, FormatFactory>()));
}
@Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionOne() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new ExtendedMessageFormat("agdXdkR;T1{9 ^,LzXf?", new HashMap<String, FormatFactory>());
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new ExtendedMessageFormat("agdXdkR;T1{9 ^,LzXf?", new HashMap<String, FormatFactory>()));
}
@Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionThree() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new ExtendedMessageFormat("9jLh_D9{ ", new HashMap<String, FormatFactory>());
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new ExtendedMessageFormat("9jLh_D9{ ", new HashMap<String, FormatFactory>()));
}
// ------------------------ Test Formats ------------------------
@Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionTwo() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new ExtendedMessageFormat("a5XdkR;T1{9 ,LzXf?", new HashMap<String, FormatFactory>());
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new ExtendedMessageFormat("a5XdkR;T1{9 ,LzXf?", new HashMap<String, FormatFactory>()));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/FormattableUtilsTest.java b/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
index 2bcfdb8..4dda6e6 100644
--- a/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
@@ -157,9 +157,7 @@ public class FormattableUtilsTest {
@Test
public void testIllegalEllipsis() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- FormattableUtils.append("foo", createFormatter(), 0, -1, 1, "xx");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> FormattableUtils.append("foo", createFormatter(), 0, -1, 1, "xx"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
index 3cffedf..d3c8b2b 100644
--- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
+++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
@@ -38,23 +38,17 @@ public class RandomStringGeneratorTest {
@Test
public void testBadMaximumCodePoint() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new RandomStringGenerator.Builder().withinRange(0, Character.MAX_CODE_POINT + 1);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new RandomStringGenerator.Builder().withinRange(0, Character.MAX_CODE_POINT + 1));
}
@Test
public void testBadMinAndMax() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new RandomStringGenerator.Builder().withinRange(2, 1);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new RandomStringGenerator.Builder().withinRange(2, 1));
}
@Test
public void testBadMinimumCodePoint() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new RandomStringGenerator.Builder().withinRange(-1, 1);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new RandomStringGenerator.Builder().withinRange(-1, 1));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java b/src/test/java/org/apache/commons/text/StrBuilderTest.java
index 471d3e3..0c1e8ae 100644
--- a/src/test/java/org/apache/commons/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java
@@ -692,9 +692,7 @@ public class StrBuilderTest {
@Test
public void testDeleteCharAtWithNegative() {
- assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> {
- new StrBuilder().deleteCharAt((-1258));
- });
+ assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> new StrBuilder().deleteCharAt((-1258)));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
index cde1467..8bf73e1 100644
--- a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
@@ -712,9 +712,7 @@ public class TextStringBuilderTest {
@Test
public void testDeleteCharAtWithNegative() {
- assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> {
- new TextStringBuilder().deleteCharAt((-1258));
- });
+ assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> new TextStringBuilder().deleteCharAt((-1258)));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/WordUtilsTest.java b/src/test/java/org/apache/commons/text/WordUtilsTest.java
index 23014fc..aeab223 100644
--- a/src/test/java/org/apache/commons/text/WordUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/WordUtilsTest.java
@@ -33,9 +33,7 @@ public class WordUtilsTest {
@Test
public void testAbbreviateForLowerThanMinusOneValues() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- assertThat(WordUtils.abbreviate("01 23 45 67 89", 9, -10, null)).isEqualTo("01 23 45 67");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> assertThat(WordUtils.abbreviate("01 23 45 67 89", 9, -10, null)).isEqualTo("01 23 45 67"));
}
// -----------------------------------------------------------------------
@@ -84,9 +82,7 @@ public class WordUtilsTest {
@Test
public void testAbbreviateUpperLessThanLowerValues() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- assertThat(WordUtils.abbreviate("0123456789", 5, 2, "")).isEqualTo("01234");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> assertThat(WordUtils.abbreviate("0123456789", 5, 2, "")).isEqualTo("01234"));
}
// -----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java
index 611781d..6958a25 100644
--- a/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java
@@ -33,23 +33,17 @@ public class FileStringLookupTest {
@Test
public void testBadCharsetName() {
- assertThrows(IllegalArgumentException.class, () -> {
- FileStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:src/test/resources/document.properties");
- });
+ assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:src/test/resources/document.properties"));
}
@Test
public void testBadDocumentPath() {
- assertThrows(IllegalArgumentException.class, () -> {
- FileStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:src/test/resources/DOCUMENT_NOT_FOUND.TXT");
- });
+ assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:src/test/resources/DOCUMENT_NOT_FOUND.TXT"));
}
@Test
public void testMissingFilePart() {
- assertThrows(IllegalArgumentException.class, () -> {
- FileStringLookup.INSTANCE.lookup(StandardCharsets.UTF_8.name());
- });
+ assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.lookup(StandardCharsets.UTF_8.name()));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java
index 704bf70..37782af 100644
--- a/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java
@@ -31,9 +31,7 @@ public class JavaPlatformStringLookupTest {
@Test
public void testBadKey() {
- assertThrows(IllegalArgumentException.class, () -> {
- JavaPlatformStringLookup.INSTANCE.lookup("BADKEY");
- });
+ assertThrows(IllegalArgumentException.class, () -> JavaPlatformStringLookup.INSTANCE.lookup("BADKEY"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
index 536a1fe..44b4af0 100644
--- a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
@@ -67,16 +67,12 @@ public class ResourceBundleStringLookupTest {
public void testExceptionGettingString() {
final ResourceBundleStringLookup mockLookup = spy(ResourceBundleStringLookup.class);
when(mockLookup.getString(TEST_RESOURCE_BUNDLE, KEY)).thenThrow(ClassCastException.class);
- assertThrows(IllegalArgumentException.class, () -> {
- mockLookup.lookup(AbstractStringLookup.toLookupKey(TEST_RESOURCE_BUNDLE, KEY));
- });
+ assertThrows(IllegalArgumentException.class, () -> mockLookup.lookup(AbstractStringLookup.toLookupKey(TEST_RESOURCE_BUNDLE, KEY)));
}
@Test
public void testMissingKeyInSpec() {
- assertThrows(IllegalArgumentException.class, () -> {
- ResourceBundleStringLookup.INSTANCE.lookup(TEST_RESOURCE_BUNDLE + ":");
- });
+ assertThrows(IllegalArgumentException.class, () -> ResourceBundleStringLookup.INSTANCE.lookup(TEST_RESOURCE_BUNDLE + ":"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java
index 88f9c40..4685346 100644
--- a/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java
@@ -33,23 +33,17 @@ public class ScriptStringLookupTest {
@Test
public void testBadEngineName() {
- assertThrows(IllegalArgumentException.class, () -> {
- ScriptStringLookup.INSTANCE.lookup("BAD_ENGINE_NAME:\"Hello World!\"");
- });
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup("BAD_ENGINE_NAME:\"Hello World!\""));
}
@Test
public void testBadScript() {
- assertThrows(IllegalArgumentException.class, () -> {
- ScriptStringLookup.INSTANCE.lookup(JS_NAME + ":X");
- });
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup(JS_NAME + ":X"));
}
@Test
public void testNoScript() {
- assertThrows(IllegalArgumentException.class, () -> {
- ScriptStringLookup.INSTANCE.lookup("ENGINE_NAME:");
- });
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup("ENGINE_NAME:"));
}
@Test
@@ -69,9 +63,7 @@ public class ScriptStringLookupTest {
@Test
public void testScriptMissingColon() {
- assertThrows(IllegalArgumentException.class, () -> {
- ScriptStringLookup.INSTANCE.lookup("JavaScript=\"test\"");
- });
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup("JavaScript=\"test\""));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java
index 34d8b47..56488ba 100644
--- a/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java
@@ -44,9 +44,7 @@ public class UrlDecoderStringLookupTest {
final UrlDecoderStringLookup mockLookup = spy(UrlDecoderStringLookup.class);
when(mockLookup.decode(DATA, StandardCharsets.UTF_8.displayName()))
.thenThrow(UnsupportedEncodingException.class);
- assertThrows(IllegalArgumentException.class, () -> {
- mockLookup.lookup(DATA);
- });
+ assertThrows(IllegalArgumentException.class, () -> mockLookup.lookup(DATA));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java
index d0e66d1..8cfe95f 100644
--- a/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java
@@ -44,9 +44,7 @@ public class UrlEncoderStringLookupTest {
final UrlEncoderStringLookup mockLookup = spy(UrlEncoderStringLookup.class);
when(mockLookup.encode(DATA, StandardCharsets.UTF_8.displayName()))
.thenThrow(UnsupportedEncodingException.class);
- assertThrows(IllegalArgumentException.class, () -> {
- mockLookup.lookup(DATA);
- });
+ assertThrows(IllegalArgumentException.class, () -> mockLookup.lookup(DATA));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java
index ced97c3..ed01805 100644
--- a/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java
@@ -35,23 +35,17 @@ public class UrlStringLookupTest {
@Test
public void testBadCharsetName() {
- assertThrows(IllegalArgumentException.class, () -> {
- UrlStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:BAD_URL");
- });
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:BAD_URL"));
}
@Test
public void testBadEncoding() {
- assertThrows(IllegalArgumentException.class, () -> {
- UrlStringLookup.INSTANCE.lookup("FOO:https://www.google.com");
- });
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("FOO:https://www.google.com"));
}
@Test
public void testBadUrl() {
- assertThrows(IllegalArgumentException.class, () -> {
- UrlStringLookup.INSTANCE.lookup("UTF-8:BAD_URL");
- });
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("UTF-8:BAD_URL"));
}
@Test
@@ -72,9 +66,7 @@ public class UrlStringLookupTest {
@Test
public void testMissingUrl() {
- assertThrows(IllegalArgumentException.class, () -> {
- UrlStringLookup.INSTANCE.lookup("UTF-8");
- });
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("UTF-8"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java b/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
index 53042eb..20e98eb 100644
--- a/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
@@ -43,30 +43,22 @@ public class FuzzyScoreTest {
@Test
public void testGetFuzzyScore_StringNullLocale() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- ENGLISH_SCORE.fuzzyScore("not null", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> ENGLISH_SCORE.fuzzyScore("not null", null));
}
@Test
public void testGetFuzzyScore_NullStringLocale() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- ENGLISH_SCORE.fuzzyScore(null, "not null");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> ENGLISH_SCORE.fuzzyScore(null, "not null"));
}
@Test
public void testGetFuzzyScore_NullNullLocale() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- ENGLISH_SCORE.fuzzyScore(null, null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> ENGLISH_SCORE.fuzzyScore(null, null));
}
@Test
public void testMissingLocale() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new FuzzyScore((Locale) null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new FuzzyScore((Locale) null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
index edad76a..ba996c3 100644
--- a/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
@@ -48,16 +48,12 @@ public class HammingDistanceTest {
@Test
public void testHammingDistance_nullLeftValue() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- distance.apply(null, "");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> distance.apply(null, ""));
}
@Test
public void testHammingDistance_nullRightValue() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- distance.apply("", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> distance.apply("", null));
}
}
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 7489f5e..c0a0e4c 100644
--- a/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/IntersectionResultTest.java
@@ -39,9 +39,7 @@ public class IntersectionResultTest {
final int sizeA = -1;
final int sizeB = 0;
final int intersection = 0;
- Assertions.assertThrows(IllegalArgumentException.class, () -> {
- new IntersectionResult(sizeA, sizeB, intersection);
- });
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
}
@Test
@@ -49,9 +47,7 @@ public class IntersectionResultTest {
final int sizeA = 0;
final int sizeB = -1;
final int intersection = 0;
- Assertions.assertThrows(IllegalArgumentException.class, () -> {
- new IntersectionResult(sizeA, sizeB, intersection);
- });
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
}
@Test
@@ -59,9 +55,7 @@ public class IntersectionResultTest {
final int sizeA = 0;
final int sizeB = 0;
final int intersection = -1;
- Assertions.assertThrows(IllegalArgumentException.class, () -> {
- new IntersectionResult(sizeA, sizeB, intersection);
- });
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
}
@Test
@@ -69,12 +63,8 @@ public class IntersectionResultTest {
final int sizeA = 1;
final int sizeB = 2;
final int intersection = Math.max(sizeA, sizeB) + 1;
- Assertions.assertThrows(IllegalArgumentException.class, () -> {
- new IntersectionResult(sizeA, sizeB, intersection);
- });
- Assertions.assertThrows(IllegalArgumentException.class, () -> {
- new IntersectionResult(sizeB, sizeA, intersection);
- });
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeA, sizeB, intersection));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new IntersectionResult(sizeB, sizeA, intersection));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/similarity/IntersectionSimilarityTest.java b/src/test/java/org/apache/commons/text/similarity/IntersectionSimilarityTest.java
index 5906da6..cdb7c9b 100644
--- a/src/test/java/org/apache/commons/text/similarity/IntersectionSimilarityTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/IntersectionSimilarityTest.java
@@ -312,29 +312,21 @@ public class IntersectionSimilarityTest {
@Test
public void testConstructorWithNullConverterThrows() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new IntersectionSimilarity<>(null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new IntersectionSimilarity<>(null));
}
@Test
public void testApplyNullNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new IntersectionSimilarity<>(cs -> new HashSet<>(Collections.singletonList(cs))).apply(null, null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new IntersectionSimilarity<>(cs -> new HashSet<>(Collections.singletonList(cs))).apply(null, null));
}
@Test
public void testApplyStringNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new IntersectionSimilarity<>(cs -> new HashSet<>(Collections.singletonList(cs))).apply("left", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new IntersectionSimilarity<>(cs -> new HashSet<>(Collections.singletonList(cs))).apply("left", null));
}
@Test
public void testApplyNullString() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- new IntersectionSimilarity<>(cs -> new HashSet<>(Collections.singletonList(cs))).apply(null, "right");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> new IntersectionSimilarity<>(cs -> new HashSet<>(Collections.singletonList(cs))).apply(null, "right"));
}
}
diff --git a/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
index 7b43665..80171b8 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
@@ -56,22 +56,16 @@ public class JaccardDistanceTest {
@Test
public void testGettingJaccardDistanceNullNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- classBeingTested.apply(null, null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> classBeingTested.apply(null, null));
}
@Test
public void testGettingJaccardDistanceStringNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- classBeingTested.apply(" ", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> classBeingTested.apply(" ", null));
}
@Test
public void testGettingJaccardDistanceNullString() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- classBeingTested.apply(null, "right");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> classBeingTested.apply(null, "right"));
}
}
diff --git a/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java b/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
index 827a35f..727376b 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
@@ -56,22 +56,16 @@ public class JaccardSimilarityTest {
@Test
public void testGettingJaccardSimilarityNullNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- classBeingTested.apply(null, null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> classBeingTested.apply(null, null));
}
@Test
public void testGettingJaccardSimilarityStringNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- classBeingTested.apply(" ", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> classBeingTested.apply(" ", null));
}
@Test
public void testGettingJaccardSimilarityNullString() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- classBeingTested.apply(null, "right");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> classBeingTested.apply(null, "right"));
}
}
diff --git a/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
index 8212b18..bf31354 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
@@ -56,23 +56,17 @@ public class JaroWinklerDistanceTest {
@Test
public void testGetJaroWinklerDistance_NullNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- distance.apply(null, null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> distance.apply(null, null));
}
@Test
public void testGetJaroWinklerDistance_StringNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- distance.apply(" ", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> distance.apply(" ", null));
}
@Test
public void testGetJaroWinklerDistance_NullString() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- distance.apply(null, "clear");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> distance.apply(null, "clear"));
}
}
diff --git a/src/test/java/org/apache/commons/text/similarity/JaroWinklerSimilarityTest.java b/src/test/java/org/apache/commons/text/similarity/JaroWinklerSimilarityTest.java
index e2c77d4..4fb50e9 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaroWinklerSimilarityTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaroWinklerSimilarityTest.java
@@ -82,23 +82,17 @@ public class JaroWinklerSimilarityTest {
@Test
public void testGetJaroWinklerSimilarity_NullNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- similarity.apply(null, null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> similarity.apply(null, null));
}
@Test
public void testGetJaroWinklerSimilarity_StringNull() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- similarity.apply(" ", null);
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> similarity.apply(" ", null));
}
@Test
public void testGetJaroWinklerSimilarity_NullString() {
- assertThatIllegalArgumentException().isThrownBy(() -> {
- similarity.apply(null, "clear");
- });
+ assertThatIllegalArgumentException().isThrownBy(() -> similarity.apply(null, "clear"));
}
}
[commons-text] 03/03: Merge branch 'pr-219'
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 ee5e4a838e6708598eabe0c073df13c964af500f
Merge: 25b847a 3a55506
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Tue Apr 20 10:35:26 2021 +1200
Merge branch 'pr-219'
This closes #219
src/changes/changes.xml | 1 +
.../apache/commons/text/AlphabetConverterTest.java | 16 ++++------------
.../commons/text/ExtendedMessageFormatTest.java | 20 +++++---------------
.../apache/commons/text/FormattableUtilsTest.java | 4 +---
.../commons/text/RandomStringGeneratorTest.java | 12 +++---------
.../java/org/apache/commons/text/StrBuilderTest.java | 4 +---
.../apache/commons/text/TextStringBuilderTest.java | 4 +---
.../java/org/apache/commons/text/WordUtilsTest.java | 8 ++------
.../commons/text/lookup/FileStringLookupTest.java | 12 +++---------
.../text/lookup/JavaPlatformStringLookupTest.java | 4 +---
.../text/lookup/ResourceBundleStringLookupTest.java | 8 ++------
.../commons/text/lookup/ScriptStringLookupTest.java | 16 ++++------------
.../text/lookup/UrlDecoderStringLookupTest.java | 4 +---
.../text/lookup/UrlEncoderStringLookupTest.java | 4 +---
.../commons/text/lookup/UrlStringLookupTest.java | 16 ++++------------
.../commons/text/similarity/FuzzyScoreTest.java | 16 ++++------------
.../commons/text/similarity/HammingDistanceTest.java | 8 ++------
.../text/similarity/IntersectionResultTest.java | 20 +++++---------------
.../text/similarity/IntersectionSimilarityTest.java | 16 ++++------------
.../commons/text/similarity/JaccardDistanceTest.java | 12 +++---------
.../text/similarity/JaccardSimilarityTest.java | 12 +++---------
.../text/similarity/JaroWinklerDistanceTest.java | 12 +++---------
.../text/similarity/JaroWinklerSimilarityTest.java | 12 +++---------
23 files changed, 61 insertions(+), 180 deletions(-)
[commons-text] 02/03: [TEXT-197] 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 3a555065f73c5c3484cc7ebc88e92eb8318b8103
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Tue Apr 20 10:35:18 2021 +1200
[TEXT-197] Changelog
---
src/changes/changes.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c3c89f7..e59bda1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -80,6 +80,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="TEXT-199" type="update" dev="kinow" due-to="Arturo Bernal">Remove redundant local variable.</action>
<action issue="TEXT-198" type="update" dev="kinow" due-to="Arturo Bernal">Replace lambda with method reference.</action>
<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>
</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>