aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2020-06-11 09:55:02 -0400
committerGary Gregory <garydgregory@gmail.com>2020-06-11 09:55:02 -0400
commit8f7eb6ce207f354c83157b95bdf9848d59944650 (patch)
tree35cf8766b84900a0539519f65310bf2009bb562c /src/test/java
parente968ad5a3f42f9eb7b3bd9ed95f827918d884e77 (diff)
downloadapache-commons-lang-8f7eb6ce207f354c83157b95bdf9848d59944650.tar.gz
Simplify lambads.
Fix Javadoc.
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/apache/commons/lang3/FunctionsTest.java4
-rw-r--r--src/test/java/org/apache/commons/lang3/LocksTest.java6
-rw-r--r--src/test/java/org/apache/commons/lang3/StreamsTest.java22
3 files changed, 16 insertions, 16 deletions
diff --git a/src/test/java/org/apache/commons/lang3/FunctionsTest.java b/src/test/java/org/apache/commons/lang3/FunctionsTest.java
index 50c3e1847..4180829f4 100644
--- a/src/test/java/org/apache/commons/lang3/FunctionsTest.java
+++ b/src/test/java/org/apache/commons/lang3/FunctionsTest.java
@@ -178,7 +178,7 @@ class FunctionsTest {
@Test
void testAsCallable() {
FailureOnOddInvocations.invocation = 0;
- final FailableCallable<FailureOnOddInvocations, SomeException> failableCallable = () -> new FailureOnOddInvocations();
+ final FailableCallable<FailureOnOddInvocations, SomeException> failableCallable = FailureOnOddInvocations::new;
final Callable<FailureOnOddInvocations> callable = Functions.asCallable(failableCallable);
final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> callable.call());
final Throwable cause = e.getCause();
@@ -221,7 +221,7 @@ class FunctionsTest {
void testAsConsumer() {
final IllegalStateException ise = new IllegalStateException();
final Testable testable = new Testable(ise);
- final Consumer<Testable> consumer = Functions.asConsumer(t -> t.test());
+ final Consumer<Testable> consumer = Functions.asConsumer(Testable::test);
Throwable e = assertThrows(IllegalStateException.class, () -> consumer.accept(testable));
assertSame(ise, e);
diff --git a/src/test/java/org/apache/commons/lang3/LocksTest.java b/src/test/java/org/apache/commons/lang3/LocksTest.java
index 5b0801395..18a81d9db 100644
--- a/src/test/java/org/apache/commons/lang3/LocksTest.java
+++ b/src/test/java/org/apache/commons/lang3/LocksTest.java
@@ -33,7 +33,7 @@ class LocksTest {
/** If our threads are running concurrently, then we expect to be faster
* than running one after the other.
*/
- runTest(DELAY, false, (l) -> assertTrue(l < NUMBER_OF_THREADS*DELAY));
+ runTest(DELAY, false, l -> assertTrue(l < NUMBER_OF_THREADS*DELAY));
}
void testWriteLock() throws Exception {
@@ -41,7 +41,7 @@ class LocksTest {
/** If our threads are running concurrently, then we expect to be no faster
* than running one after the other.
*/
- runTest(DELAY, true, (l) -> assertTrue(l >= NUMBER_OF_THREADS*DELAY));
+ runTest(DELAY, true, l -> assertTrue(l >= NUMBER_OF_THREADS*DELAY));
}
private void runTest(long delay, boolean exclusiveLock, LongConsumer runTimeCheck) throws InterruptedException {
@@ -52,7 +52,7 @@ class LocksTest {
final long startTime = System.currentTimeMillis();
for (int i = 0; i < booleanValues.length; i++) {
final int index = i;
- final FailableConsumer<boolean[], ?> consumer = (b) -> {
+ final FailableConsumer<boolean[], ?> consumer = b -> {
b[index] = false;
Thread.sleep(delay);
b[index] = true;
diff --git a/src/test/java/org/apache/commons/lang3/StreamsTest.java b/src/test/java/org/apache/commons/lang3/StreamsTest.java
index a5985aad3..3e17ed1bd 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(s -> Integer.valueOf(s)).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(s -> Integer.valueOf(s)).collect(Collectors.toList());
final NumberFormatException thrown = assertThrows(NumberFormatException.class, testMethod);
assertEquals("For input string: \"4 \"", thrown.getMessage());
}
@@ -65,7 +65,7 @@ class StreamsTest {
void testSimpleStreamForEach() {
final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6");
final List<Integer> output = new ArrayList<>();
- Functions.stream(input).forEach((s) -> output.add(Integer.valueOf(s)));
+ Functions.stream(input).forEach(s -> output.add(Integer.valueOf(s)));
assertEquals(6, output.size());
for (int i = 0; i < 6; i++) {
assertEquals(i+1, output.get(i).intValue());
@@ -83,7 +83,7 @@ class StreamsTest {
}
protected <T extends Throwable> FailableConsumer<String, T> asIntConsumer(final T pThrowable) {
- return (s) -> {
+ return s -> {
final Integer i = Integer.valueOf(s);
if (i.intValue() == 4) {
throw pThrowable;
@@ -130,8 +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) -> {
+ .map(s -> Integer.valueOf(s))
+ .filter(i -> {
return i.intValue() %2 == 0;
})
.collect(Collectors.toList());
@@ -146,7 +146,7 @@ class StreamsTest {
}
protected <T extends Throwable> FailablePredicate<Integer, T> asIntPredicate(final T pThrowable) {
- return (i) -> {
+ return i -> {
if (i.intValue() == 5) {
if (pThrowable != null) {
throw pThrowable;
@@ -160,7 +160,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(s -> Integer.valueOf(s))
.filter(asIntPredicate(null))
.collect(Collectors.toList());
assertEvenNumbers(output);
@@ -170,7 +170,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(s -> Integer.valueOf(s))
.filter(asIntPredicate(iae))
.collect(Collectors.toList());
final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, testMethod);
@@ -180,7 +180,7 @@ class StreamsTest {
dynamicTest("OutOfMemoryError", () -> {
final OutOfMemoryError oome = new OutOfMemoryError();
final Executable testMethod = () -> Functions.stream(input)
- .map((s) -> Integer.valueOf(s))
+ .map(s -> Integer.valueOf(s))
.filter(asIntPredicate(oome))
.collect(Collectors.toList());
final OutOfMemoryError thrown = assertThrows(OutOfMemoryError.class, testMethod);
@@ -190,7 +190,7 @@ class StreamsTest {
dynamicTest("SAXException", () -> {
final SAXException se = new SAXException();
final Executable testMethod = () -> Functions.stream(input)
- .map((s) -> Integer.valueOf(s))
+ .map(s -> Integer.valueOf(s))
.filter(asIntPredicate(se))
.collect(Collectors.toList());
final UndeclaredThrowableException thrown = assertThrows(UndeclaredThrowableException.class, testMethod);