This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new 386c1e2 Simplify lambdas. 386c1e2 is described below commit 386c1e2f37f77aedbfb624800bab51319bf3a9fd Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jun 13 10:55:46 2020 -0400 Simplify lambdas. --- .../java/org/apache/commons/lang3/StreamsTest.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/StreamsTest.java b/src/test/java/org/apache/commons/lang3/StreamsTest.java index 3e17ed1..a0b79f6 100644 --- a/src/test/java/org/apache/commons/lang3/StreamsTest.java +++ b/src/test/java/org/apache/commons/lang3/StreamsTest.java @@ -46,7 +46,7 @@ class StreamsTest { @Test void testSimpleStreamMap() { final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6"); - final List<Integer> output = Functions.stream(input).map(s -> Integer.valueOf(s)).collect(Collectors.toList()); + final List<Integer> output = Functions.stream(input).map(Integer::valueOf).collect(Collectors.toList()); assertEquals(6, output.size()); for (int i = 0; i < 6; i++) { assertEquals(i+1, output.get(i).intValue()); @@ -56,7 +56,7 @@ class StreamsTest { @Test void testSimpleStreamMapFailing() { final List<String> input = Arrays.asList("1", "2", "3", "4 ", "5", "6"); - final Executable testMethod = () -> Functions.stream(input).map(s -> Integer.valueOf(s)).collect(Collectors.toList()); + final Executable testMethod = () -> Functions.stream(input).map(Integer::valueOf).collect(Collectors.toList()); final NumberFormatException thrown = assertThrows(NumberFormatException.class, testMethod); assertEquals("For input string: \"4 \"", thrown.getMessage()); } @@ -130,10 +130,8 @@ class StreamsTest { void testSimpleStreamFilter() { final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6"); final List<Integer> output = Functions.stream(input) - .map(s -> Integer.valueOf(s)) - .filter(i -> { - return i.intValue() %2 == 0; - }) + .map(Integer::valueOf) + .filter(i -> (i.intValue() %2 == 0)) .collect(Collectors.toList()); assertEvenNumbers(output); } @@ -160,7 +158,7 @@ class StreamsTest { Stream<DynamicTest> simpleStreamFilterFailing() { final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6"); final List<Integer> output = Functions.stream(input) - .map(s -> Integer.valueOf(s)) + .map(Integer::valueOf) .filter(asIntPredicate(null)) .collect(Collectors.toList()); assertEvenNumbers(output); @@ -170,7 +168,7 @@ class StreamsTest { dynamicTest("IllegalArgumentException", () -> { final IllegalArgumentException iae = new IllegalArgumentException("Invalid argument: " + 5); final Executable testMethod = () -> Functions.stream(input) - .map(s -> Integer.valueOf(s)) + .map(Integer::valueOf) .filter(asIntPredicate(iae)) .collect(Collectors.toList()); final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, testMethod); @@ -180,7 +178,7 @@ class StreamsTest { dynamicTest("OutOfMemoryError", () -> { final OutOfMemoryError oome = new OutOfMemoryError(); final Executable testMethod = () -> Functions.stream(input) - .map(s -> Integer.valueOf(s)) + .map(Integer::valueOf) .filter(asIntPredicate(oome)) .collect(Collectors.toList()); final OutOfMemoryError thrown = assertThrows(OutOfMemoryError.class, testMethod); @@ -190,7 +188,7 @@ class StreamsTest { dynamicTest("SAXException", () -> { final SAXException se = new SAXException(); final Executable testMethod = () -> Functions.stream(input) - .map(s -> Integer.valueOf(s)) + .map(Integer::valueOf) .filter(asIntPredicate(se)) .collect(Collectors.toList()); final UndeclaredThrowableException thrown = assertThrows(UndeclaredThrowableException.class, testMethod);