aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/apache/commons/lang3
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2020-06-13 10:55:46 -0400
committerGary Gregory <garydgregory@gmail.com>2020-06-13 10:55:46 -0400
commit386c1e2f37f77aedbfb624800bab51319bf3a9fd (patch)
tree6a74c1e31f4627e43882c6d0faefe36a45bab1f1 /src/test/java/org/apache/commons/lang3
parent2f7a3a811805375d37415e12f6435d04be694ea2 (diff)
downloadapache-commons-lang-386c1e2f37f77aedbfb624800bab51319bf3a9fd.tar.gz
Simplify lambdas.
Diffstat (limited to 'src/test/java/org/apache/commons/lang3')
-rw-r--r--src/test/java/org/apache/commons/lang3/StreamsTest.java18
1 files 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 3e17ed1bd..a0b79f60c 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);