[TEXT-197] Replace statement lambda with expression lambda
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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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 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 @@
@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 @@
@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 @@
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 @@
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 @@
@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 @@
@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 @@
@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 @@
@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 @@
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 @@
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 @@
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 @@
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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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"));
}
}