From 5a580fb9cbb669f87f124c455e56194b8f83da49 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 1 Sep 2021 11:04:21 -0400 Subject: [PATCH] Use final, valueOf(), lambdas. --- .../java/org/apache/commons/lang3/ArrayUtilsSetTest.java | 6 +++--- .../lang3/concurrent/UncheckedExecutionExceptionTest.java | 2 +- .../lang3/concurrent/UncheckedTimeoutExceptionTest.java | 2 +- .../commons/lang3/exception/UncheckedExceptionTest.java | 2 +- .../lang3/exception/UncheckedInterruptedExceptionTest.java | 2 +- .../apache/commons/lang3/function/BooleanConsumerTest.java | 7 ++----- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsSetTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsSetTest.java index 41b1b9b3c..e2cdd41f5 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsSetTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsSetTest.java @@ -36,7 +36,7 @@ public class ArrayUtilsSetTest { assertArrayEquals(null, ArrayUtils.setAll(null, nullIntFunction)); assertArrayEquals(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, ArrayUtils.setAll(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, nullIntFunction)); assertArrayEquals(ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.setAll(ArrayUtils.EMPTY_OBJECT_ARRAY, nullIntFunction)); - Integer[] array = new Integer[10]; + final Integer[] array = new Integer[10]; final Integer[] array2 = ArrayUtils.setAll(array, Integer::valueOf); assertSame(array, array2); for (int i = 0; i < array.length; i++) { @@ -51,10 +51,10 @@ public class ArrayUtilsSetTest { assertArrayEquals(null, ArrayUtils.setAll(null, nullSupplier)); assertArrayEquals(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, ArrayUtils.setAll(ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY, nullSupplier)); assertArrayEquals(ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.setAll(ArrayUtils.EMPTY_OBJECT_ARRAY, nullSupplier)); - String[] array = new String[10]; + final String[] array = new String[10]; final String[] array2 = ArrayUtils.setAll(array, () -> StringUtils.EMPTY); assertSame(array, array2); - for (String s : array) { + for (final String s : array) { assertEquals(StringUtils.EMPTY, s); } } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/UncheckedExecutionExceptionTest.java b/src/test/java/org/apache/commons/lang3/concurrent/UncheckedExecutionExceptionTest.java index 3763deb23..00f104c58 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/UncheckedExecutionExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/UncheckedExecutionExceptionTest.java @@ -27,7 +27,7 @@ public class UncheckedExecutionExceptionTest { @Test public void testConstructWithCause() { - Exception e = new Exception(); + final Exception e = new Exception(); assertSame(e, new UncheckedExecutionException(e).getCause()); } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/UncheckedTimeoutExceptionTest.java b/src/test/java/org/apache/commons/lang3/concurrent/UncheckedTimeoutExceptionTest.java index a3ac73336..960ff0249 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/UncheckedTimeoutExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/UncheckedTimeoutExceptionTest.java @@ -27,7 +27,7 @@ public class UncheckedTimeoutExceptionTest { @Test public void testConstructWithCause() { - Exception e = new Exception(); + final Exception e = new Exception(); assertSame(e, new UncheckedTimeoutException(e).getCause()); } diff --git a/src/test/java/org/apache/commons/lang3/exception/UncheckedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/UncheckedExceptionTest.java index 5b0053166..fd5c2dc4c 100644 --- a/src/test/java/org/apache/commons/lang3/exception/UncheckedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/UncheckedExceptionTest.java @@ -27,7 +27,7 @@ public class UncheckedExceptionTest { @Test public void testConstructWithCause() { - Exception e = new Exception(); + final Exception e = new Exception(); assertSame(e, new UncheckedException(e).getCause()); } diff --git a/src/test/java/org/apache/commons/lang3/exception/UncheckedInterruptedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/UncheckedInterruptedExceptionTest.java index 17243cc0a..e0cb1622e 100644 --- a/src/test/java/org/apache/commons/lang3/exception/UncheckedInterruptedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/UncheckedInterruptedExceptionTest.java @@ -27,7 +27,7 @@ public class UncheckedInterruptedExceptionTest { @Test public void testConstructWithCause() { - Exception e = new Exception(); + final Exception e = new Exception(); assertSame(e, new UncheckedInterruptedException(e).getCause()); } diff --git a/src/test/java/org/apache/commons/lang3/function/BooleanConsumerTest.java b/src/test/java/org/apache/commons/lang3/function/BooleanConsumerTest.java index 247a07b02..626dcb31e 100644 --- a/src/test/java/org/apache/commons/lang3/function/BooleanConsumerTest.java +++ b/src/test/java/org/apache/commons/lang3/function/BooleanConsumerTest.java @@ -66,11 +66,8 @@ public class BooleanConsumerTest { assertFalse(aBool2.get()); // Check order - final BooleanConsumer bad = new BooleanConsumer() { - @Override - public void accept(boolean value) { - throw new IllegalStateException(); - } + final BooleanConsumer bad = value -> { + throw new IllegalStateException(); }; final BooleanConsumer badComposite = bad.andThen(aBool2::lazySet);