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 eae283d5aad5b6a0b128f9ab1fb03119e8ec4703 Author: Arturo Bernal <[email protected]> AuthorDate: Sun Apr 18 12:49:00 2021 +0200 [TEXT-198] Replace lambda with method reference --- src/test/java/org/apache/commons/text/StrTokenizerTest.java | 8 ++++---- .../text/StringSubstitutorWithInterpolatorStringLookupTest.java | 2 +- src/test/java/org/apache/commons/text/StringTokenizerTest.java | 8 ++++---- .../java/org/apache/commons/text/lookup/BiStringLookupTest.java | 8 +------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/apache/commons/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/text/StrTokenizerTest.java index 0e94078..9a2ba6a 100644 --- a/src/test/java/org/apache/commons/text/StrTokenizerTest.java +++ b/src/test/java/org/apache/commons/text/StrTokenizerTest.java @@ -724,7 +724,7 @@ public class StrTokenizerTest { assertFalse(tokenizer.hasPrevious()); assertNull(tokenizer.nextToken()); assertEquals(0, tokenizer.size()); - assertThrows(NoSuchElementException.class, () -> tokenizer.next()); + assertThrows(NoSuchElementException.class, tokenizer::next); } @Test @@ -744,11 +744,11 @@ public class StrTokenizerTest { public void testIteration() { final StrTokenizer tkn = new StrTokenizer("a b c"); assertFalse(tkn.hasPrevious()); - assertThrows(NoSuchElementException.class, () -> tkn.previous()); + assertThrows(NoSuchElementException.class, tkn::previous); assertTrue(tkn.hasNext()); assertEquals("a", tkn.next()); - assertThrows(UnsupportedOperationException.class, () -> tkn.remove()); + assertThrows(UnsupportedOperationException.class, tkn::remove); assertThrows(UnsupportedOperationException.class, () -> tkn.set("x")); assertThrows(UnsupportedOperationException.class, () -> tkn.add("y")); assertTrue(tkn.hasPrevious()); @@ -762,7 +762,7 @@ public class StrTokenizerTest { assertTrue(tkn.hasPrevious()); assertFalse(tkn.hasNext()); - assertThrows(NoSuchElementException.class, () -> tkn.next()); + assertThrows(NoSuchElementException.class, tkn::next); assertTrue(tkn.hasPrevious()); assertFalse(tkn.hasNext()); } diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java index 1d6a16f..996a8de 100644 --- a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java +++ b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java @@ -41,7 +41,7 @@ public class StringSubstitutorWithInterpolatorStringLookupTest { final String value = "value"; final Map<String, String> map = new HashMap<>(); map.put(key, value); - final StringLookup mapStringLookup = StringLookupFactory.INSTANCE.functionStringLookup(k -> map.get(k)); + final StringLookup mapStringLookup = StringLookupFactory.INSTANCE.functionStringLookup(map::get); final Map<String, StringLookup> stringLookupMap = new HashMap<>(); stringLookupMap.put("customLookup", mapStringLookup); final StringSubstitutor strSubst = new StringSubstitutor( diff --git a/src/test/java/org/apache/commons/text/StringTokenizerTest.java b/src/test/java/org/apache/commons/text/StringTokenizerTest.java index 7d1b85d..829ec22 100644 --- a/src/test/java/org/apache/commons/text/StringTokenizerTest.java +++ b/src/test/java/org/apache/commons/text/StringTokenizerTest.java @@ -729,7 +729,7 @@ public class StringTokenizerTest { assertFalse(tokenizer.hasPrevious()); assertNull(tokenizer.nextToken()); assertEquals(0, tokenizer.size()); - assertThrows(NoSuchElementException.class, () -> tokenizer.next()); + assertThrows(NoSuchElementException.class, tokenizer::next); } @Test @@ -749,11 +749,11 @@ public class StringTokenizerTest { public void testIteration() { final StringTokenizer tkn = new StringTokenizer("a b c"); assertFalse(tkn.hasPrevious()); - assertThrows(NoSuchElementException.class, () -> tkn.previous()); + assertThrows(NoSuchElementException.class, tkn::previous); assertTrue(tkn.hasNext()); assertEquals("a", tkn.next()); - assertThrows(UnsupportedOperationException.class, () -> tkn.remove()); + assertThrows(UnsupportedOperationException.class, tkn::remove); assertThrows(UnsupportedOperationException.class, () -> tkn.set("x")); assertThrows(UnsupportedOperationException.class, () -> tkn.add("y")); assertTrue(tkn.hasPrevious()); @@ -767,7 +767,7 @@ public class StringTokenizerTest { assertTrue(tkn.hasPrevious()); assertFalse(tkn.hasNext()); - assertThrows(NoSuchElementException.class, () -> tkn.next()); + assertThrows(NoSuchElementException.class, tkn::next); assertTrue(tkn.hasPrevious()); assertFalse(tkn.hasNext()); } diff --git a/src/test/java/org/apache/commons/text/lookup/BiStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/BiStringLookupTest.java index 6220fe1..8d54dd5 100644 --- a/src/test/java/org/apache/commons/text/lookup/BiStringLookupTest.java +++ b/src/test/java/org/apache/commons/text/lookup/BiStringLookupTest.java @@ -27,13 +27,7 @@ public class BiStringLookupTest { @Test public void testDefaultMethod() { - Assertions.assertEquals("a", new BiStringLookup<Object>() { - - @Override - public String lookup(final String key) { - return key; - } - }.lookup("a", "b")); + Assertions.assertEquals("a", ((BiStringLookup<Object>) key -> key).lookup("a", "b")); } }
