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-collections.git
The following commit(s) were added to refs/heads/master by this push:
new c0fc3b72b Declutter unit test code
c0fc3b72b is described below
commit c0fc3b72b8e9267efc6380c9866215960a286a5b
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sun Mar 16 16:25:09 2025 -0400
Declutter unit test code
---
.../apache/commons/collections4/BagUtilsTest.java | 49 ++++-------
.../commons/collections4/ClosureUtilsTest.java | 54 +++++-------
.../commons/collections4/CollectionUtilsTest.java | 84 +++++++------------
.../commons/collections4/ComparatorUtilsTest.java | 19 ++---
.../commons/collections4/IterableUtilsTest.java | 35 ++++----
.../apache/commons/collections4/ListUtilsTest.java | 53 ++++--------
.../apache/commons/collections4/MapUtilsTest.java | 50 ++++-------
.../apache/commons/collections4/SetUtilsTest.java | 45 +++-------
.../commons/collections4/TransformerUtilsTest.java | 97 +++++++++-------------
.../comparators/BooleanComparatorTest.java | 13 ++-
.../collections4/iterators/ArrayIterator2Test.java | 23 +++--
.../collections4/iterators/IteratorChainTest.java | 7 +-
.../iterators/LazyIteratorChainTest.java | 7 +-
.../iterators/LoopingListIteratorTest.java | 7 +-
.../iterators/ReverseListIteratorTest.java | 19 ++---
.../list/CursorableLinkedListTest.java | 10 +--
.../collections4/list/UnmodifiableListTest.java | 33 +++-----
.../commons/collections4/map/DefaultedMapTest.java | 18 ++--
.../commons/collections4/map/LRUMapTest.java | 29 ++-----
.../collections4/map/LazySortedMapTest.java | 10 +--
.../collections4/map/ListOrderedMapTest.java | 10 +--
.../collections4/map/PassiveExpiringMapTest.java | 30 +++----
.../collections4/set/ListOrderedSetTest.java | 13 ++-
.../set/UnmodifiableSortedSetTest.java | 21 ++---
24 files changed, 252 insertions(+), 484 deletions(-)
diff --git a/src/test/java/org/apache/commons/collections4/BagUtilsTest.java
b/src/test/java/org/apache/commons/collections4/BagUtilsTest.java
index 7de5425c2..42f1cdbaf 100644
--- a/src/test/java/org/apache/commons/collections4/BagUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/BagUtilsTest.java
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -46,72 +46,55 @@ public class BagUtilsTest {
public void testPredicatedBag() {
final Bag<Object> bag = BagUtils.predicatedBag(new HashBag<>(),
truePredicate);
assertInstanceOf(PredicatedBag.class, bag, "Returned object should be
a PredicatedBag.");
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.predicatedBag(null, truePredicate),
- "Expecting NullPointerException for null bag."),
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.predicatedBag(new HashBag<>(), null),
- "Expecting NullPointerException for null predicate.")
- );
+ assertThrows(NullPointerException.class, () ->
BagUtils.predicatedBag(null, truePredicate), "Expecting NullPointerException
for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.predicatedBag(new HashBag<>(), null), "Expecting NullPointerException
for null predicate.");
}
@Test
public void testPredicatedSortedBag() {
final Bag<Object> bag = BagUtils.predicatedSortedBag(new TreeBag<>(),
truePredicate);
assertInstanceOf(PredicatedSortedBag.class, bag, "Returned object
should be a PredicatedSortedBag.");
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.predicatedSortedBag(null, truePredicate),
- "Expecting NullPointerException for null bag."),
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.predicatedSortedBag(new TreeBag<>(), null),
- "Expecting NullPointerException for null predicate.")
- );
+ assertThrows(NullPointerException.class, () ->
BagUtils.predicatedSortedBag(null, truePredicate), "Expecting
NullPointerException for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.predicatedSortedBag(new TreeBag<>(), null),
+ "Expecting NullPointerException for null predicate.");
}
@Test
public void testSynchronizedBag() {
final Bag<Object> bag = BagUtils.synchronizedBag(new HashBag<>());
assertInstanceOf(SynchronizedBag.class, bag, "Returned object should
be a SynchronizedBag.");
- assertThrows(NullPointerException.class, () ->
BagUtils.synchronizedBag(null),
- "Expecting NullPointerException for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.synchronizedBag(null), "Expecting NullPointerException for null bag.");
}
@Test
public void testSynchronizedSortedBag() {
final Bag<Object> bag = BagUtils.synchronizedSortedBag(new
TreeBag<>());
assertInstanceOf(SynchronizedSortedBag.class, bag, "Returned object
should be a SynchronizedSortedBag.");
- assertThrows(NullPointerException.class, () ->
BagUtils.synchronizedSortedBag(null),
- "Expecting NullPointerException for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.synchronizedSortedBag(null), "Expecting NullPointerException for null
bag.");
}
@Test
public void testTransformedBag() {
final Bag<Object> bag = BagUtils.transformingBag(new HashBag<>(),
nopTransformer);
assertInstanceOf(TransformedBag.class, bag, "Returned object should be
an TransformedBag.");
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.transformingBag(null, nopTransformer),
- "Expecting NullPointerException for null bag."),
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.transformingBag(new HashBag<>(), null),
- "Expecting NullPointerException for null transformer.")
- );
+ assertThrows(NullPointerException.class, () ->
BagUtils.transformingBag(null, nopTransformer), "Expecting NullPointerException
for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.transformingBag(new HashBag<>(), null), "Expecting
NullPointerException for null transformer.");
}
@Test
public void testTransformedSortedBag() {
final Bag<Object> bag = BagUtils.transformingSortedBag(new
TreeBag<>(), nopTransformer);
assertInstanceOf(TransformedSortedBag.class, bag, "Returned object
should be an TransformedSortedBag");
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.transformingSortedBag(null, nopTransformer),
- "Expecting NullPointerException for null bag."),
- () -> assertThrows(NullPointerException.class, () ->
BagUtils.transformingSortedBag(new TreeBag<>(), null),
- "Expecting NullPointerException for null transformer.")
- );
+ assertThrows(NullPointerException.class, () ->
BagUtils.transformingSortedBag(null, nopTransformer), "Expecting
NullPointerException for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.transformingSortedBag(new TreeBag<>(), null),
+ "Expecting NullPointerException for null transformer.");
}
@Test
public void testUnmodifiableBag() {
final Bag<Object> bag = BagUtils.unmodifiableBag(new HashBag<>());
assertInstanceOf(UnmodifiableBag.class, bag, "Returned object should
be an UnmodifiableBag.");
- assertThrows(NullPointerException.class, () ->
BagUtils.unmodifiableBag(null),
- "Expecting NullPointerException for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.unmodifiableBag(null), "Expecting NullPointerException for null bag.");
assertSame(bag, BagUtils.unmodifiableBag(bag), "UnmodifiableBag shall
not be decorated");
}
@@ -119,9 +102,7 @@ public class BagUtilsTest {
public void testUnmodifiableSortedBag() {
final SortedBag<Object> bag = BagUtils.unmodifiableSortedBag(new
TreeBag<>());
assertInstanceOf(UnmodifiableSortedBag.class, bag, "Returned object
should be an UnmodifiableSortedBag.");
- assertThrows(NullPointerException.class, () ->
BagUtils.unmodifiableSortedBag(null),
- "Expecting NullPointerException for null bag.");
+ assertThrows(NullPointerException.class, () ->
BagUtils.unmodifiableSortedBag(null), "Expecting NullPointerException for null
bag.");
assertSame(bag, BagUtils.unmodifiableSortedBag(bag),
"UnmodifiableSortedBag shall not be decorated");
}
-
}
diff --git
a/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java
b/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java
index e5822c805..c642d2053 100644
--- a/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
@@ -93,18 +92,15 @@ public class ClosureUtilsTest {
assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure());
assertSame(NOPClosure.INSTANCE,
ClosureUtils.<Object>chainedClosure(Collections.<Closure<Object>>emptyList()));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.chainedClosure(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.<Object>chainedClosure((Closure[]) null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.<Object>chainedClosure((Collection<Closure<Object>>) null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.<Object>chainedClosure(null, null)),
- () -> {
- final Collection<Closure<Object>> finalColl = new
ArrayList<>();
- finalColl.add(null);
- finalColl.add(null);
- assertThrows(NullPointerException.class, () ->
ClosureUtils.chainedClosure(finalColl));
- }
- );
+
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.chainedClosure(null, null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.<Object>chainedClosure((Closure[]) null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.<Object>chainedClosure((Collection<Closure<Object>>) null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.<Object>chainedClosure(null, null));
+ final Collection<Closure<Object>> finalColl = new ArrayList<>();
+ finalColl.add(null);
+ finalColl.add(null);
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.chainedClosure(finalColl));
}
@Test
@@ -124,10 +120,9 @@ public class ClosureUtilsTest {
public void testExceptionClosure() {
assertNotNull(ClosureUtils.exceptionClosure());
assertSame(ClosureUtils.exceptionClosure(),
ClosureUtils.exceptionClosure());
- assertAll(
- () -> assertThrows(FunctorException.class, () ->
ClosureUtils.exceptionClosure().execute(null)),
- () -> assertThrows(FunctorException.class, () ->
ClosureUtils.exceptionClosure().execute(cString))
- );
+
+ assertThrows(FunctorException.class, () ->
ClosureUtils.exceptionClosure().execute(null));
+ assertThrows(FunctorException.class, () ->
ClosureUtils.exceptionClosure().execute(cString));
}
@Test
@@ -268,15 +263,13 @@ public class ClosureUtilsTest {
map.clear();
map.put(null, null);
assertEquals(NOPClosure.INSTANCE, ClosureUtils.switchClosure(map));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.switchClosure(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.<String>switchClosure((Predicate<String>[]) null,
(Closure<String>[]) null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.<String>switchClosure((Map<Predicate<String>, Closure<String>>)
null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.<String>switchClosure(new Predicate[2], new Closure[2])),
- () -> assertThrows(IllegalArgumentException.class, () ->
ClosureUtils.<String>switchClosure(
- new Predicate[]{TruePredicate.<String>truePredicate()},
- new Closure[]{a, b}))
- );
+
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.switchClosure(null, null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.<String>switchClosure((Predicate<String>[]) null,
(Closure<String>[]) null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.<String>switchClosure((Map<Predicate<String>, Closure<String>>)
null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.<String>switchClosure(new Predicate[2], new Closure[2]));
+ assertThrows(IllegalArgumentException.class,
+ () -> ClosureUtils.<String>switchClosure(new Predicate[] {
TruePredicate.<String>truePredicate() }, new Closure[] { a, b }));
}
@Test
@@ -337,11 +330,10 @@ public class ClosureUtilsTest {
cmd = new MockClosure<>();
ClosureUtils.whileClosure(PredicateUtils.uniquePredicate(),
cmd).execute(null);
assertEquals(1, cmd.count);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.whileClosure(null, ClosureUtils.nopClosure())),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), null)),
- () -> assertThrows(NullPointerException.class, () ->
ClosureUtils.whileClosure(null, null))
- );
+
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.whileClosure(null, ClosureUtils.nopClosure()));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), null));
+ assertThrows(NullPointerException.class, () ->
ClosureUtils.whileClosure(null, null));
}
}
diff --git
a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
index ac9a83152..0aba6140a 100644
--- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -890,27 +889,17 @@ public class CollectionUtilsTest extends MockTestCase {
@Test
public void testExtractSingleton() {
- assertAll(
- () -> {
- final ArrayList<String> collNull = null;
- assertThrows(NullPointerException.class, () ->
CollectionUtils.extractSingleton(collNull),
- "expected NullPointerException from
extractSingleton(null)");
- },
- () -> {
- final ArrayList<String> collEmpty = new ArrayList<>();
- assertThrows(IllegalArgumentException.class, () ->
CollectionUtils.extractSingleton(collEmpty),
- "expected IllegalArgumentException from
extractSingleton(empty)");
- },
- () -> {
- final ArrayList<String> coll = new ArrayList<>();
- coll.add("foo");
- assertEquals("foo",
CollectionUtils.extractSingleton(coll));
- coll.add("bar");
-
- assertThrows(IllegalArgumentException.class, () ->
CollectionUtils.extractSingleton(coll),
- "expected IllegalArgumentException from
extractSingleton(size == 2)");
- }
- );
+ final ArrayList<String> collNull = null;
+ assertThrows(NullPointerException.class, () ->
CollectionUtils.extractSingleton(collNull), "expected NullPointerException from
extractSingleton(null)");
+ final ArrayList<String> collEmpty = new ArrayList<>();
+ assertThrows(IllegalArgumentException.class, () ->
CollectionUtils.extractSingleton(collEmpty),
+ "expected IllegalArgumentException from
extractSingleton(empty)");
+ final ArrayList<String> coll = new ArrayList<>();
+ coll.add("foo");
+ assertEquals("foo", CollectionUtils.extractSingleton(coll));
+ coll.add("bar");
+ assertThrows(IllegalArgumentException.class, () ->
CollectionUtils.extractSingleton(coll),
+ "expected IllegalArgumentException from extractSingleton(size
== 2)");
}
//Up to here
@@ -966,12 +955,12 @@ public class CollectionUtilsTest extends MockTestCase {
@Test
public void testGet() {
- assertEquals(2, CollectionUtils.get((Object) collectionA, 2));
- assertEquals(2, CollectionUtils.get((Object) collectionA.iterator(),
2));
+ assertEquals(2, CollectionUtils.get(collectionA, 2));
+ assertEquals(2, CollectionUtils.get(collectionA.iterator(), 2));
final Map<Integer, Integer> map =
CollectionUtils.getCardinalityMap(collectionA);
// Test assumes a defined iteration order so convert to a LinkedHashMap
final Map<Integer, Integer> linkedMap = new LinkedHashMap<>(map);
- assertEquals(linkedMap.entrySet().iterator().next(),
CollectionUtils.get((Object) linkedMap, 0));
+ assertEquals(linkedMap.entrySet().iterator().next(),
CollectionUtils.get(linkedMap, 0));
}
@Test
@@ -1017,19 +1006,13 @@ public class CollectionUtilsTest extends MockTestCase {
final Map<String, String> expected = new HashMap<>();
expected.put("zeroKey", "zero");
expected.put("oneKey", "one");
-
Map.Entry<String, String> entry = CollectionUtils.get(expected, 0);
assertTrue(entry.toString().equals("zeroKey=zero") ||
entry.toString().equals("oneKey=one"));
entry = CollectionUtils.get(expected, 1);
assertTrue(entry.toString().equals("zeroKey=zero") ||
entry.toString().equals("oneKey=one"));
-
// Map index out of range
- assertAll(
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, 2),
- "Expecting IndexOutOfBoundsException."),
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, -2),
- "Expecting IndexOutOfBoundsException.")
- );
+ assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, 2));
+ assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, -2));
}
@Test
@@ -1071,14 +1054,9 @@ public class CollectionUtilsTest extends MockTestCase {
final Map<String, String> expected = new LinkedHashMap<>();
expected.put("zeroKey", "zero");
expected.put("oneKey", "one");
-
// Map index out of range
- assertAll(
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, 2),
- "Expecting IndexOutOfBoundsException."),
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, -2),
- "Expecting IndexOutOfBoundsException.")
- );
+ assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, 2));
+ assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(expected, -2));
}
@Test
@@ -1138,20 +1116,20 @@ public class CollectionUtilsTest extends MockTestCase {
@Test
public void testGetIterator() {
final Iterator<Integer> it = collectionA.iterator();
- assertEquals(Integer.valueOf(2), CollectionUtils.get((Object) it, 2));
+ assertEquals(Integer.valueOf(2), CollectionUtils.get(it, 2));
assertTrue(it.hasNext());
- assertEquals(Integer.valueOf(4), CollectionUtils.get((Object) it, 6));
+ assertEquals(Integer.valueOf(4), CollectionUtils.get(it, 6));
assertFalse(it.hasNext());
}
@Test
public void testGetNegative() {
- assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get((Object) collectionA, -3));
+ assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(collectionA, -3));
}
@Test
public void testGetPositiveOutOfBounds() {
- assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get((Object) collectionA.iterator(), 30));
+ assertThrows(IndexOutOfBoundsException.class, () ->
CollectionUtils.get(collectionA.iterator(), 30));
}
@Test
@@ -1708,12 +1686,9 @@ public class CollectionUtilsTest extends MockTestCase {
assertTrue(remove.contains("AA"));
assertTrue(remove.contains("CX"));
assertTrue(remove.contains("XZ"));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
CollectionUtils.removeAll(null, null, DefaultEquator.defaultEquator()),
- "expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
CollectionUtils.removeAll(base, remove, null),
- "expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () ->
CollectionUtils.removeAll(null, null, DefaultEquator.defaultEquator()));
+ assertThrows(NullPointerException.class, () ->
CollectionUtils.removeAll(base, remove, null));
}
@Test
@@ -1904,12 +1879,9 @@ public class CollectionUtilsTest extends MockTestCase {
assertTrue(retain.contains("AA"));
assertTrue(retain.contains("CX"));
assertTrue(retain.contains("XZ"));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
CollectionUtils.retainAll(null, null, null),
- "expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
CollectionUtils.retainAll(base, retain, null),
- "expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () ->
CollectionUtils.retainAll(null, null, null));
+ assertThrows(NullPointerException.class, () ->
CollectionUtils.retainAll(base, retain, null));
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java
b/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java
index 8800b9ba0..e70b8149e 100644
--- a/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -63,12 +62,9 @@ public class ComparatorUtilsTest {
assertEquals(Integer.valueOf(1), ComparatorUtils.max(1, 10, reversed));
assertEquals(Integer.valueOf(-10), ComparatorUtils.max(10, -10,
reversed));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ComparatorUtils.max(1, null, null),
- "expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
ComparatorUtils.max(null, 10, null),
- "expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () -> ComparatorUtils.max(1,
null, null));
+ assertThrows(NullPointerException.class, () ->
ComparatorUtils.max(null, 10, null));
}
@Test
@@ -81,12 +77,9 @@ public class ComparatorUtilsTest {
assertEquals(Integer.valueOf(10), ComparatorUtils.min(1, 10,
reversed));
assertEquals(Integer.valueOf(10), ComparatorUtils.min(10, -10,
reversed));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ComparatorUtils.min(1, null, null),
- "expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
ComparatorUtils.min(null, 10, null),
- "expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () -> ComparatorUtils.min(1,
null, null));
+ assertThrows(NullPointerException.class, () ->
ComparatorUtils.min(null, 10, null));
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java
b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java
index ab8995b91..4fa4d8237 100644
--- a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -147,10 +146,8 @@ public class IterableUtilsTest {
public void testCountMatches() {
assertEquals(4, IterableUtils.countMatches(iterableB, EQUALS_TWO));
assertEquals(0, IterableUtils.countMatches(null, EQUALS_TWO));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
assertEquals(0, IterableUtils.countMatches(iterableA, null)),
- "predicate must not be null"),
- () -> assertThrows(NullPointerException.class, () ->
assertEquals(0, IterableUtils.countMatches(null, null)), "predicate must not be
null"));
+ assertThrows(NullPointerException.class, () -> assertEquals(0,
IterableUtils.countMatches(iterableA, null)), "predicate must not be null");
+ assertThrows(NullPointerException.class, () -> assertEquals(0,
IterableUtils.countMatches(null, null)), "predicate must not be null");
}
@Test
@@ -636,21 +633,19 @@ public class IterableUtilsTest {
return StringUtils.EMPTY;
}, StringUtils.EMPTY, "(", ")");
assertEquals("()", result);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), null, StringUtils.EMPTY, "(", ")"),
- "expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), input -> {
- fail("not supposed to reach here");
- return StringUtils.EMPTY;
- }, null, "(", ")"), "expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), input -> {
- fail("not supposed to reach here");
- return StringUtils.EMPTY;
- }, StringUtils.EMPTY, null, ")"), "expecting
NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), input -> {
- fail("not supposed to reach here");
- return StringUtils.EMPTY;
- }, StringUtils.EMPTY, "(", null), "expecting
NullPointerException"));
+ assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), null, StringUtils.EMPTY, "(", ")"));
+ assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), input -> {
+ fail("not supposed to reach here");
+ return StringUtils.EMPTY;
+ }, null, "(", ")"));
+ assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), input -> {
+ fail("not supposed to reach here");
+ return StringUtils.EMPTY;
+ }, StringUtils.EMPTY, null, ")"));
+ assertThrows(NullPointerException.class, () ->
IterableUtils.toString(new ArrayList<>(), input -> {
+ fail("not supposed to reach here");
+ return StringUtils.EMPTY;
+ }, StringUtils.EMPTY, "(", null));
}
}
diff --git a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
index 20d59cebb..d78a084c5 100644
--- a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -265,15 +264,9 @@ public class ListUtilsTest {
@Test
@SuppressWarnings("boxing") // OK in test code
public void testLongestCommonSubsequence() {
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence((List<?>) null, null),
- "failed to check for null argument"),
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence(Arrays.asList('A'), null),
- "failed to check for null argument"),
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence(null, Arrays.asList('A')),
- "failed to check for null argument")
- );
-
+ assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence((List<?>) null, null), "failed to check for
null argument");
+ assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence(Arrays.asList('A'), null), "failed to check
for null argument");
+ assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence(null, Arrays.asList('A')), "failed to check
for null argument");
@SuppressWarnings("unchecked")
List<Character> lcs =
ListUtils.longestCommonSubsequence(Collections.EMPTY_LIST,
Collections.EMPTY_LIST);
assertEquals(0, lcs.size());
@@ -299,15 +292,9 @@ public class ListUtilsTest {
@Test
public void testLongestCommonSubsequenceWithString() {
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence((String) null, null),
- "failed to check for null argument"),
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence("A", null),
- "failed to check for null argument"),
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence(null, "A"),
- "failed to check for null argument")
- );
-
+ assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence((String) null, null), "failed to check for
null argument");
+ assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence("A", null), "failed to check for null
argument");
+ assertThrows(NullPointerException.class, () ->
ListUtils.longestCommonSubsequence(null, "A"), "failed to check for null
argument");
String lcs = ListUtils.longestCommonSubsequence(StringUtils.EMPTY,
StringUtils.EMPTY);
assertEquals(0, lcs.length());
@@ -341,21 +328,12 @@ public class ListUtilsTest {
assertNotNull(partition);
assertEquals(3, partition.size());
assertEquals(1, partition.get(2).size());
- assertAll(
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
partition.get(-1),
- "Index -1 must not be negative"),
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
partition.get(3),
- "Index " + 3 + " must be less than size " +
partition.size())
- );
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.partition(null, 3),
- "failed to check for null argument"),
- () -> assertThrows(IllegalArgumentException.class, () ->
ListUtils.partition(strings, 0),
- "failed to check for size argument"),
- () -> assertThrows(IllegalArgumentException.class, () ->
ListUtils.partition(strings, -10),
- "failed to check for size argument")
- );
+ assertThrows(IndexOutOfBoundsException.class, () -> partition.get(-1),
"Index -1 must not be negative");
+ assertThrows(IndexOutOfBoundsException.class, () -> partition.get(3),
"Index " + 3 + " must be less than size " + partition.size());
+ assertThrows(NullPointerException.class, () ->
ListUtils.partition(null, 3), "failed to check for null argument");
+ assertThrows(IllegalArgumentException.class, () ->
ListUtils.partition(strings, 0), "failed to check for size argument");
+ assertThrows(IllegalArgumentException.class, () ->
ListUtils.partition(strings, -10), "failed to check for size argument");
final List<List<Integer>> partitionMax = ListUtils.partition(strings,
Integer.MAX_VALUE);
assertEquals(1, partitionMax.size());
assertEquals(strings.size(), partitionMax.get(0).size());
@@ -367,12 +345,9 @@ public class ListUtilsTest {
final Predicate<Object> predicate = String.class::isInstance;
final List<Object> list = ListUtils.predicatedList(new ArrayList<>(),
predicate);
assertInstanceOf(PredicatedList.class, list, "returned object should
be a PredicatedList");
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.predicatedList(new ArrayList<>(), null),
- "Expecting IllegalArgumentException for null
predicate."),
- () -> assertThrows(NullPointerException.class, () ->
ListUtils.predicatedList(null, predicate),
- "Expecting IllegalArgumentException for null list.")
- );
+ assertThrows(NullPointerException.class, () ->
ListUtils.predicatedList(new ArrayList<>(), null),
+ "Expecting IllegalArgumentException for null predicate.");
+ assertThrows(NullPointerException.class, () ->
ListUtils.predicatedList(null, predicate), "Expecting IllegalArgumentException
for null list.");
}
@Test
diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
index edb7d8dd7..16810fa33 100644
--- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -731,22 +730,16 @@ public class MapUtilsTest {
final Factory<Integer> factory =
FactoryUtils.constantFactory(Integer.valueOf(5));
Map<Object, Object> map = MapUtils.lazyMap(new HashMap<>(), factory);
assertInstanceOf(LazyMap.class, map);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
MapUtils.lazyMap(new HashMap<>(), (Factory<Object>) null),
- "Expecting NullPointerException for null factory"),
- () -> assertThrows(NullPointerException.class, () ->
MapUtils.lazyMap((Map<Object, Object>) null, factory),
- "Expecting NullPointerException for null map")
- );
-
+ assertThrows(NullPointerException.class, () -> MapUtils.lazyMap(new
HashMap<>(), (Factory<Object>) null),
+ "Expecting NullPointerException for null factory");
+ assertThrows(NullPointerException.class, () ->
MapUtils.lazyMap((Map<Object, Object>) null, factory), "Expecting
NullPointerException for null map");
final Transformer<Object, Integer> transformer =
TransformerUtils.asTransformer(factory);
map = MapUtils.lazyMap(new HashMap<>(), transformer);
assertInstanceOf(LazyMap.class, map);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
MapUtils.lazyMap(new HashMap<>(), (Transformer<Object, Object>) null),
- "Expecting NullPointerException for null transformer"),
- () -> assertThrows(NullPointerException.class, () ->
MapUtils.lazyMap((Map<Object, Object>) null, transformer),
- "Expecting NullPointerException for null map")
- );
+ assertThrows(NullPointerException.class, () -> MapUtils.lazyMap(new
HashMap<>(), (Transformer<Object, Object>) null),
+ "Expecting NullPointerException for null transformer");
+ assertThrows(NullPointerException.class, () ->
MapUtils.lazyMap((Map<Object, Object>) null, transformer),
+ "Expecting NullPointerException for null map");
}
@Test
@@ -877,11 +870,9 @@ public class MapUtilsTest {
@Test
public void testPutAll_Map_array() {
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
MapUtils.putAll(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
MapUtils.putAll(null, new Object[0]))
- );
+ assertThrows(NullPointerException.class, () -> MapUtils.putAll(null,
null));
+ assertThrows(NullPointerException.class, () -> MapUtils.putAll(null,
new Object[0]));
Map<String, String> test = MapUtils.putAll(new HashMap<>(),
org.apache.commons.lang3.ArrayUtils.EMPTY_STRING_ARRAY);
assertEquals(0, test.size());
@@ -898,24 +889,13 @@ public class MapUtilsTest {
assertTrue(test.containsKey("BLUE"));
assertEquals("#0000FF", test.get("BLUE"));
assertEquals(3, test.size());
- assertAll(
- () -> assertThrows(IllegalArgumentException.class, () ->
MapUtils.putAll(new HashMap<>(), new String[][]{
- {"RED", "#FF0000"},
- null,
- {"BLUE", "#0000FF"}
- })),
- () -> assertThrows(IllegalArgumentException.class, () ->
MapUtils.putAll(new HashMap<>(), new String[][]{
- {"RED", "#FF0000"},
- {"GREEN"},
- {"BLUE", "#0000FF"}
- })),
- () -> assertThrows(IllegalArgumentException.class, () ->
MapUtils.putAll(new HashMap<>(), new String[][]{
- {"RED", "#FF0000"},
- {},
- {"BLUE", "#0000FF"}
- }))
- );
+ assertThrows(IllegalArgumentException.class,
+ () -> MapUtils.putAll(new HashMap<>(), new String[][] { {
"RED", "#FF0000" }, null, { "BLUE", "#0000FF" } }));
+ assertThrows(IllegalArgumentException.class,
+ () -> MapUtils.putAll(new HashMap<>(), new String[][] { {
"RED", "#FF0000" }, { "GREEN" }, { "BLUE", "#0000FF" } }));
+ assertThrows(IllegalArgumentException.class,
+ () -> MapUtils.putAll(new HashMap<>(), new String[][] { {
"RED", "#FF0000" }, {}, { "BLUE", "#0000FF" } }));
// flat array
test = MapUtils.putAll(new HashMap<>(), new String[] {
"RED", "#FF0000",
diff --git a/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
b/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
index 7a1b8dd60..cb31c2d2b 100644
--- a/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -73,12 +72,9 @@ public class SetUtilsTest {
final Set<Integer> set2 = SetUtils.difference(setA,
SetUtils.<Integer>emptySet());
assertEquals(setA, set2);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.difference(setA, null),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.difference(null, setA),
- "Expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () ->
SetUtils.difference(setA, null));
+ assertThrows(NullPointerException.class, () ->
SetUtils.difference(null, setA));
}
@Test
@@ -95,12 +91,9 @@ public class SetUtilsTest {
final Set<Integer> set2 = SetUtils.disjunction(setA,
SetUtils.<Integer>emptySet());
assertEquals(setA, set2);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.disjunction(setA, null),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.disjunction(null, setA),
- "Expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () ->
SetUtils.disjunction(setA, null));
+ assertThrows(NullPointerException.class, () ->
SetUtils.disjunction(null, setA));
}
@Test
@@ -182,12 +175,9 @@ public class SetUtilsTest {
final Set<Integer> set2 = SetUtils.intersection(setA,
SetUtils.<Integer>emptySet());
assertEquals(SetUtils.<Integer>emptySet(), set2);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.intersection(setA, null),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.intersection(null, setA),
- "Expecting NullPointerException")
- );
+
+ assertThrows(NullPointerException.class, () ->
SetUtils.intersection(setA, null));
+ assertThrows(NullPointerException.class, () ->
SetUtils.intersection(null, setA));
}
@Test
@@ -212,12 +202,8 @@ public class SetUtilsTest {
final Predicate<Object> predicate = String.class::isInstance;
final Set<Object> set = SetUtils.predicatedSet(new HashSet<>(),
predicate);
assertInstanceOf(PredicatedSet.class, set, "returned object should be
a PredicatedSet");
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.predicatedSet(new HashSet<>(), null),
- "Expecting NullPointerException for null predicate."),
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.predicatedSet(null, predicate),
- "Expecting NullPointerException for null set.")
- );
+ assertThrows(NullPointerException.class, () ->
SetUtils.predicatedSet(new HashSet<>(), null), "Expecting NullPointerException
for null predicate.");
+ assertThrows(NullPointerException.class, () ->
SetUtils.predicatedSet(null, predicate), "Expecting NullPointerException for
null set.");
}
@Test
@@ -226,15 +212,10 @@ public class SetUtilsTest {
assertEquals(7, set.size());
assertTrue(set.containsAll(setA));
assertTrue(set.containsAll(setB));
-
final Set<Integer> set2 = SetUtils.union(setA,
SetUtils.<Integer>emptySet());
assertEquals(setA, set2);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.union(setA, null),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
SetUtils.union(null, setA),
- "Expecting NullPointerException")
- );
+ assertThrows(NullPointerException.class, () -> SetUtils.union(setA,
null));
+ assertThrows(NullPointerException.class, () -> SetUtils.union(null,
setA));
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java
b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java
index 7891f169e..75f38324d 100644
--- a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -66,21 +65,18 @@ public class TransformerUtilsTest {
coll.add(b);
coll.add(a);
assertEquals("A",
TransformerUtils.chainedTransformer(coll).transform(null));
-
assertSame(NOPTransformer.INSTANCE,
TransformerUtils.chainedTransformer());
assertSame(NOPTransformer.INSTANCE,
TransformerUtils.chainedTransformer(Collections.<Transformer<Object,
Object>>emptyList()));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer((Transformer[]) null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer((Collection<Transformer<Object, Object>>)
null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer(null, null)),
- () -> assertThrows(NullPointerException.class, () -> {
- final Collection<Transformer<Object, Object>> coll1 = new
ArrayList<>();
- coll1.add(null);
- coll1.add(null);
- TransformerUtils.chainedTransformer(coll1);
- })
- );
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer(null, null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer((Transformer[]) null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer((Collection<Transformer<Object, Object>>)
null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.chainedTransformer(null, null));
+ assertThrows(NullPointerException.class, () -> {
+ final Collection<Transformer<Object, Object>> coll1 = new
ArrayList<>();
+ coll1.add(null);
+ coll1.add(null);
+ TransformerUtils.chainedTransformer(coll1);
+ });
}
@Test
@@ -103,12 +99,10 @@ public class TransformerUtilsTest {
@Test
public void testExceptionTransformer() {
- assertAll(
- () -> assertNotNull(TransformerUtils.exceptionTransformer()),
- () -> assertSame(TransformerUtils.exceptionTransformer(),
TransformerUtils.exceptionTransformer()),
- () -> assertThrows(FunctorException.class, () ->
TransformerUtils.exceptionTransformer().transform(null)),
- () -> assertThrows(FunctorException.class, () ->
TransformerUtils.exceptionTransformer().transform(cString))
- );
+ assertNotNull(TransformerUtils.exceptionTransformer());
+ assertSame(TransformerUtils.exceptionTransformer(),
TransformerUtils.exceptionTransformer());
+ assertThrows(FunctorException.class, () ->
TransformerUtils.exceptionTransformer().transform(null));
+ assertThrows(FunctorException.class, () ->
TransformerUtils.exceptionTransformer().transform(cString));
}
@Test
@@ -149,21 +143,17 @@ public class TransformerUtilsTest {
final Predicate<String> equalsAPredicate =
EqualPredicate.equalPredicate("A");
assertEquals("C", TransformerUtils.ifTransformer(equalsAPredicate,
c).transform("A"));
assertEquals("B", TransformerUtils.ifTransformer(equalsAPredicate,
c).transform("B"));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(TruePredicate.truePredicate(), null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(null,
ConstantTransformer.constantTransformer("A"))),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(null, null, null))
- );
+
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(null, null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(TruePredicate.truePredicate(), null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(null,
ConstantTransformer.constantTransformer("A")));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.ifTransformer(null, null, null));
}
@Test
public void testInstantiateTransformerNull() {
- assertAll(
- () -> assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.instantiateTransformer(null, new Object[]{"str"})),
- () -> assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.instantiateTransformer(new Class[]{}, new Object[]{"str"}))
- );
-
+ assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.instantiateTransformer(null, new Object[] { "str" }));
+ assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.instantiateTransformer(new Class[] {}, new Object[] { "str"
}));
Transformer<Class<?>, Object> trans =
TransformerUtils.instantiateTransformer(new Class[] { Long.class }, new
Object[] { null });
final Transformer<Class<?>, Object> finalTrans = trans;
@@ -183,30 +173,23 @@ public class TransformerUtilsTest {
list.add(new Object());
assertEquals(1,
TransformerUtils.invokerTransformer("size").transform(list));
assertNull(TransformerUtils.invokerTransformer("size").transform(null));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.invokerTransformer(null)),
- () -> assertThrows(FunctorException.class, () ->
TransformerUtils.invokerTransformer("noSuchMethod").transform(new Object()))
- );
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.invokerTransformer(null));
+ assertThrows(FunctorException.class, () ->
TransformerUtils.invokerTransformer("noSuchMethod").transform(new Object()));
}
@Test
public void testInvokerTransformer2() {
final List<Object> list = new ArrayList<>();
- assertEquals(Boolean.FALSE,
TransformerUtils.invokerTransformer("contains",
- new Class[] { Object.class }, new Object[] { cString
}).transform(list));
+ assertEquals(Boolean.FALSE,
TransformerUtils.invokerTransformer("contains", new Class[] { Object.class },
new Object[] { cString }).transform(list));
list.add(cString);
- assertEquals(Boolean.TRUE,
TransformerUtils.invokerTransformer("contains",
- new Class[] { Object.class }, new Object[] { cString
}).transform(list));
- assertNull(TransformerUtils.invokerTransformer("contains",
- new Class[]{Object.class}, new
Object[]{cString}).transform(null));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.invokerTransformer(null, null, null)),
- () -> assertThrows(FunctorException.class, () ->
TransformerUtils.invokerTransformer("noSuchMethod", new Class[]{Object.class},
- new Object[]{cString}).transform(new Object())),
- () -> assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.invokerTransformer("badArgs", null, new Object[]{cString})),
- () -> assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.invokerTransformer("badArgs", new Class[]{Object.class},
null)),
- () -> assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.invokerTransformer("badArgs", new Class[]{}, new
Object[]{cString}))
- );
+ assertEquals(Boolean.TRUE,
TransformerUtils.invokerTransformer("contains", new Class[] { Object.class },
new Object[] { cString }).transform(list));
+ assertNull(TransformerUtils.invokerTransformer("contains", new Class[]
{ Object.class }, new Object[] { cString }).transform(null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.invokerTransformer(null, null, null));
+ assertThrows(FunctorException.class,
+ () -> TransformerUtils.invokerTransformer("noSuchMethod", new
Class[] { Object.class }, new Object[] { cString }).transform(new Object()));
+ assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.invokerTransformer("badArgs", null, new Object[] { cString }));
+ assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.invokerTransformer("badArgs", new Class[] { Object.class },
null));
+ assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.invokerTransformer("badArgs", new Class[] {}, new Object[] {
cString }));
}
@Test
@@ -339,15 +322,13 @@ public class TransformerUtilsTest {
map = new HashMap<>();
map.put(null, null);
assertEquals(ConstantTransformer.NULL_INSTANCE,
TransformerUtils.switchTransformer(map));
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(null, (Transformer[]) null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(null)),
- () -> assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(new Predicate[2], new Transformer[2])),
- () -> assertThrows(IllegalArgumentException.class, () ->
TransformerUtils.switchTransformer(
- new Predicate[]{TruePredicate.truePredicate()},
- new Transformer[]{a, b}))
- );
+
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(null, null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(null, (Transformer[]) null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(null));
+ assertThrows(NullPointerException.class, () ->
TransformerUtils.switchTransformer(new Predicate[2], new Transformer[2]));
+ assertThrows(IllegalArgumentException.class,
+ () -> TransformerUtils.switchTransformer(new Predicate[] {
TruePredicate.truePredicate() }, new Transformer[] { a, b }));
}
}
diff --git
a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java
b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java
index 63a721e10..cfb866403 100644
---
a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java
+++
b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.comparators;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -76,13 +75,11 @@ public class BooleanComparatorTest extends
AbstractComparatorTest<Boolean> {
protected void nullArgumentTests(final BooleanComparator comp) {
assertNotNull(comp);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
comp.compare(null, null), "Expected NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
comp.compare(Boolean.TRUE, null), "Expected NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
comp.compare(Boolean.FALSE, null), "Expected NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
comp.compare(null, Boolean.TRUE), "Expected NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
comp.compare(null, Boolean.FALSE), "Expected NullPointerException")
- );
+ assertThrows(NullPointerException.class, () -> comp.compare(null,
null));
+ assertThrows(NullPointerException.class, () ->
comp.compare(Boolean.TRUE, null));
+ assertThrows(NullPointerException.class, () ->
comp.compare(Boolean.FALSE, null));
+ assertThrows(NullPointerException.class, () -> comp.compare(null,
Boolean.TRUE));
+ assertThrows(NullPointerException.class, () -> comp.compare(null,
Boolean.FALSE));
}
protected void orderIndependentTests(final BooleanComparator comp) {
diff --git
a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
index 35ac4bacf..81be8ce85 100644
---
a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
+++
b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.iterators;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -81,18 +80,16 @@ public class ArrayIterator2Test<E> extends
AbstractIteratorTest<E> {
}
assertEquals(count, testArray.length - 2, "the count should be right
using ArrayIterator(Object,1," + (testArray.length - 1) + ") ");
- assertAll(
- () -> assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, -1),
- "new ArrayIterator(Object,-1) should throw an
ArrayIndexOutOfBoundsException"),
- () -> assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, testArray.length + 1),
- "new ArrayIterator(Object,length+1) should throw an
ArrayIndexOutOfBoundsException"),
- () -> assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, 0, -1),
- "new ArrayIterator(Object,0,-1) should throw an
ArrayIndexOutOfBoundsException"),
- () -> assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, 0, testArray.length + 1),
- "new ArrayIterator(Object,0,length+1) should throw an
ArrayIndexOutOfBoundsException"),
- () -> assertThrows(IllegalArgumentException.class, () ->
makeArrayIterator(testArray, testArray.length - 1, testArray.length - 2),
- "new ArrayIterator(Object,length-2,length-1) should
throw an IllegalArgumentException"));
-
+ assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, -1),
+ "new ArrayIterator(Object,-1) should throw an
ArrayIndexOutOfBoundsException");
+ assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, testArray.length + 1),
+ "new ArrayIterator(Object,length+1) should throw an
ArrayIndexOutOfBoundsException");
+ assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, 0, -1),
+ "new ArrayIterator(Object,0,-1) should throw an
ArrayIndexOutOfBoundsException");
+ assertThrows(ArrayIndexOutOfBoundsException.class, () ->
makeArrayIterator(testArray, 0, testArray.length + 1),
+ "new ArrayIterator(Object,0,length+1) should throw an
ArrayIndexOutOfBoundsException");
+ assertThrows(IllegalArgumentException.class, () ->
makeArrayIterator(testArray, testArray.length - 1, testArray.length - 2),
+ "new ArrayIterator(Object,length-2,length-1) should throw an
IllegalArgumentException");
iter = makeArrayIterator(testArray, 1, 1);
// MODIFIED: an iterator over a zero-length section of array
// should be perfectly legal behavior
diff --git
a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
index 414f40bb8..805f3cb67 100644
---
a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
+++
b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.iterators;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -108,10 +107,8 @@ public class IteratorChainTest extends
AbstractIteratorTest<String> {
public void testEmptyChain() {
final IteratorChain<Object> chain = new IteratorChain<>();
assertFalse(chain.hasNext());
- assertAll(
- () -> assertThrows(NoSuchElementException.class, () ->
chain.next()),
- () -> assertThrows(IllegalStateException.class, () ->
chain.remove())
- );
+ assertThrows(NoSuchElementException.class, () -> chain.next());
+ assertThrows(IllegalStateException.class, () -> chain.remove());
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java
b/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java
index 415cf437d..20b33663d 100644
---
a/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java
+++
b/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.iterators;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -90,10 +89,8 @@ public class LazyIteratorChainTest extends
AbstractIteratorTest<String> {
public void testEmptyChain() {
final LazyIteratorChain<String> chain = makeEmptyIterator();
assertFalse(chain.hasNext());
- assertAll(
- () -> assertThrows(NoSuchElementException.class, () ->
chain.next()),
- () -> assertThrows(IllegalStateException.class, () ->
chain.remove())
- );
+ assertThrows(NoSuchElementException.class, () -> chain.next());
+ assertThrows(IllegalStateException.class, () -> chain.remove());
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java
b/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java
index 9a2d8f026..c4bf3c870 100644
---
a/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java
+++
b/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.iterators;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -147,10 +146,8 @@ public class LoopingListIteratorTest {
final LoopingListIterator<Object> loop = new
LoopingListIterator<>(list);
assertFalse(loop.hasNext());
assertFalse(loop.hasPrevious());
- assertAll(
- () -> assertThrows(NoSuchElementException.class, () ->
loop.next()),
- () -> assertThrows(NoSuchElementException.class, () ->
loop.previous())
- );
+ assertThrows(NoSuchElementException.class, () -> loop.next());
+ assertThrows(NoSuchElementException.class, () -> loop.previous());
}
/**
diff --git
a/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java
b/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java
index a1a73265a..8aea641c0 100644
---
a/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java
+++
b/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.iterators;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -57,20 +56,14 @@ public class ReverseListIteratorTest<E> extends
AbstractListIteratorTest<E> {
@Override
public void testEmptyListIteratorIsIndeedEmpty() {
final ListIterator<E> it = makeEmptyIterator();
-
assertFalse(it.hasNext());
- assertEquals(-1, it.nextIndex()); // reversed index
+ assertEquals(-1, it.nextIndex()); // reversed index
assertFalse(it.hasPrevious());
- assertEquals(0, it.previousIndex()); // reversed index
-
- assertAll(
- // next() should throw a NoSuchElementException
- () -> assertThrows(NoSuchElementException.class, () ->
it.next(),
- "NoSuchElementException must be thrown from empty
ListIterator"),
- // previous() should throw a NoSuchElementException
- () -> assertThrows(NoSuchElementException.class, () ->
it.previous(),
- "NoSuchElementException must be thrown from empty
ListIterator")
- );
+ assertEquals(0, it.previousIndex()); // reversed index
+ // next() should throw a NoSuchElementException
+ assertThrows(NoSuchElementException.class, () -> it.next(),
"NoSuchElementException must be thrown from empty ListIterator");
+ // previous() should throw a NoSuchElementException
+ assertThrows(NoSuchElementException.class, () -> it.previous(),
"NoSuchElementException must be thrown from empty ListIterator");
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java
b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java
index 7740327f9..fa7484718 100644
---
a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java
+++
b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.list;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
@@ -536,12 +535,9 @@ public class CursorableLinkedListTest<E> extends
AbstractLinkedListTest<E> {
assertTrue(list.add((E) "B"));
assertEquals("A", list.get(0));
assertEquals("B", list.get(1));
- assertAll(
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
list.get(-1),
- "shouldn't get here"),
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
list.get(2),
- "shouldn't get here")
- );
+
+ assertThrows(IndexOutOfBoundsException.class, () -> list.get(-1));
+ assertThrows(IndexOutOfBoundsException.class, () -> list.get(2));
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java
b/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java
index 59360c162..04da400ad 100644
---
a/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java
+++
b/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.list;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -107,28 +106,16 @@ public class UnmodifiableListTest<E> extends
AbstractListTest<E> {
@SuppressWarnings("unchecked")
protected void verifyUnmodifiable(final List<E> list) {
- assertAll(
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.add(0, (E) Integer.valueOf(0)),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.add((E) Integer.valueOf(0)),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.addAll(0, array),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.addAll(array),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.clear(),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.remove(0),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.remove(Integer.valueOf(0)),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.removeAll(array),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.retainAll(array),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
list.set(0, (E) Integer.valueOf(0)),
- "Expecting UnsupportedOperationException.")
- );
+ assertThrows(UnsupportedOperationException.class, () -> list.add(0,
(E) Integer.valueOf(0)));
+ assertThrows(UnsupportedOperationException.class, () -> list.add((E)
Integer.valueOf(0)));
+ assertThrows(UnsupportedOperationException.class, () -> list.addAll(0,
array));
+ assertThrows(UnsupportedOperationException.class, () ->
list.addAll(array));
+ assertThrows(UnsupportedOperationException.class, () -> list.clear());
+ assertThrows(UnsupportedOperationException.class, () ->
list.remove(0));
+ assertThrows(UnsupportedOperationException.class, () ->
list.remove(Integer.valueOf(0)));
+ assertThrows(UnsupportedOperationException.class, () ->
list.removeAll(array));
+ assertThrows(UnsupportedOperationException.class, () ->
list.retainAll(array));
+ assertThrows(UnsupportedOperationException.class, () -> list.set(0,
(E) Integer.valueOf(0)));
}
// public void testCreate() throws Exception {
diff --git
a/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java
b/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java
index 53e7708f7..86599cd7b 100644
--- a/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.map;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -58,18 +57,11 @@ public class DefaultedMapTest<K, V> extends
AbstractIterableMapTest<K, V> {
@Test
public void testFactoryMethods() {
final HashMap<K, V> base = new HashMap<>();
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap(null, (V) "DEFAULT_VALUE"),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap((Map<K, V>) null, nullFactory),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap(base, (Factory<V>) null),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap((Map<K, V>) null, nullTransformer),
- "Expecting NullPointerException"),
- () -> assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap(base, (Transformer<K, V>) null),
- "Expecting NullPointerException")
- );
+ assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap(null, (V) "DEFAULT_VALUE"));
+ assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap((Map<K, V>) null, nullFactory));
+ assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap(base, (Factory<V>) null));
+ assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap((Map<K, V>) null, nullTransformer));
+ assertThrows(NullPointerException.class, () ->
DefaultedMap.defaultedMap(base, (Transformer<K, V>) null));
}
@Test
diff --git a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
index a5c1e4605..a438f49c0 100644
--- a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.map;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -303,20 +302,12 @@ public class LRUMapTest<K, V> extends
AbstractOrderedMapTest<K, V> {
@Test
public void testCtors() {
- assertAll(
- () -> assertThrows(IllegalArgumentException.class, () -> new
LRUMap<K, V>(0),
- "maxSize must be positive"),
- () -> assertThrows(IllegalArgumentException.class, () -> new
LRUMap<K, V>(-1, 12, 0.75f, false),
- "maxSize must be positive"),
- () -> assertThrows(IllegalArgumentException.class, () -> new
LRUMap<K, V>(10, -1),
- "initialSize must not be negative"),
- () -> assertThrows(IllegalArgumentException.class, () -> new
LRUMap<K, V>(10, 12),
- "initialSize must not be larger than maxSize"),
- () -> assertThrows(IllegalArgumentException.class, () -> new
LRUMap<K, V>(10, -1, 0.75f, false),
- "initialSize must not be negative"),
- () -> assertThrows(IllegalArgumentException.class, () -> new
LRUMap<K, V>(10, 12, 0.75f, false),
- "initialSize must not be larger than maxSize")
- );
+ assertThrows(IllegalArgumentException.class, () -> new LRUMap<K,
V>(0), "maxSize must be positive");
+ assertThrows(IllegalArgumentException.class, () -> new LRUMap<K,
V>(-1, 12, 0.75f, false), "maxSize must be positive");
+ assertThrows(IllegalArgumentException.class, () -> new LRUMap<K,
V>(10, -1), "initialSize must not be negative");
+ assertThrows(IllegalArgumentException.class, () -> new LRUMap<K,
V>(10, 12), "initialSize must not be larger than maxSize");
+ assertThrows(IllegalArgumentException.class, () -> new LRUMap<K,
V>(10, -1, 0.75f, false), "initialSize must not be negative");
+ assertThrows(IllegalArgumentException.class, () -> new LRUMap<K,
V>(10, 12, 0.75f, false), "initialSize must not be larger than maxSize");
}
@Test
@@ -419,19 +410,15 @@ public class LRUMapTest<K, V> extends
AbstractOrderedMapTest<K, V> {
final SingleHashCode one = new SingleHashCode("1");
final SingleHashCode two = new SingleHashCode("2");
final SingleHashCode three = new SingleHashCode("3");
-
final LRUMap<K, V> map = new LRUMap<>(3, 1.0f);
map.put((K) one, (V) "A");
map.put((K) two, (V) "B");
map.put((K) three, (V) "C");
-
assertEquals(one, map.getEntry(0).key);
assertEquals(two, map.getEntry(1).key);
assertEquals(three, map.getEntry(2).key);
- assertAll(
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
map.getEntry(-1)),
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
map.getEntry(3))
- );
+ assertThrows(IndexOutOfBoundsException.class, () -> map.getEntry(-1));
+ assertThrows(IndexOutOfBoundsException.class, () -> map.getEntry(3));
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java
b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java
index f60d106a6..d7e8dc6de 100644
--- a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.map;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -130,11 +129,10 @@ public class LazySortedMapTest<K, V> extends
AbstractSortedMapTest<K, V> {
final Transformer<Object, Integer> transformer =
TransformerUtils.asTransformer(oneFactory);
final SortedMap<Integer, Number> map = LazySortedMap.lazySortedMap(new
TreeMap<>(), transformer);
assertInstanceOf(LazySortedMap.class, map);
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
LazySortedMap.lazySortedMap(new TreeMap<>(), (Transformer<Integer, Number>)
null),
- "Expecting NullPointerException for null transformer"),
- () -> assertThrows(NullPointerException.class, () ->
LazySortedMap.lazySortedMap((SortedMap<Integer, Number>) null, transformer),
- "Expecting NullPointerException for null map"));
+ assertThrows(NullPointerException.class, () ->
LazySortedMap.lazySortedMap(new TreeMap<>(), (Transformer<Integer, Number>)
null),
+ "Expecting NullPointerException for null transformer");
+ assertThrows(NullPointerException.class, () ->
LazySortedMap.lazySortedMap((SortedMap<Integer, Number>) null, transformer),
+ "Expecting NullPointerException for null map");
}
// public void testCreate() throws Exception {
diff --git
a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java
b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java
index 5bc561f75..1f466dc38 100644
--- a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.map;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
@@ -248,12 +247,11 @@ public class ListOrderedMapTest<K, V> extends
AbstractOrderedMapTest<K, V> {
ListOrderedMap<K, V> lom = getMap();
final ListOrderedMap<K, V> finalLom = lom;
- assertAll(
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
finalLom.put(1, (K) "testInsert1", (V) "testInsert1v"),
- "should not be able to insert at pos 1 in empty Map"),
- () -> assertThrows(IndexOutOfBoundsException.class, () ->
finalLom.put(-1, (K) "testInsert-1", (V) "testInsert-1v"),
- "should not be able to insert at pos -1 in empty
Map"));
+ assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(1,
(K) "testInsert1", (V) "testInsert1v"),
+ "should not be able to insert at pos 1 in empty Map");
+ assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(-1,
(K) "testInsert-1", (V) "testInsert-1v"),
+ "should not be able to insert at pos -1 in empty Map");
// put where key doesn't exist
lom.put(0, (K) "testInsert1", (V) "testInsert1v");
assertEquals("testInsert1v", lom.getValue(0));
diff --git
a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
index 0737da6d2..bb7ae0065 100644
---
a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
+++
b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.map;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -108,23 +107,18 @@ public class PassiveExpiringMapTest<K, V> extends
AbstractMapTest<PassiveExpirin
@Test
public void testConstructors() {
- assertAll(
- () -> assertThrows(NullPointerException.class, () -> {
- final Map<String, String> map = null;
- new PassiveExpiringMap<>(map);
- },
- "constructor - exception should have been thrown."),
- () -> assertThrows(NullPointerException.class, () -> {
- final ExpirationPolicy<String, String> policy = null;
- new PassiveExpiringMap<>(policy);
- },
- "constructor - exception should have been thrown."),
- () -> assertThrows(NullPointerException.class, () -> {
- final TimeUnit unit = null;
- new PassiveExpiringMap<String, String>(10L, unit);
- },
- "constructor - exception should have been thrown.")
- );
+ assertThrows(NullPointerException.class, () -> {
+ final Map<String, String> map = null;
+ new PassiveExpiringMap<>(map);
+ });
+ assertThrows(NullPointerException.class, () -> {
+ final ExpirationPolicy<String, String> policy = null;
+ new PassiveExpiringMap<>(policy);
+ });
+ assertThrows(NullPointerException.class, () -> {
+ final TimeUnit unit = null;
+ new PassiveExpiringMap<String, String>(10L, unit);
+ });
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java
b/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java
index 457dc9082..3317daa7d 100644
--- a/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java
+++ b/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.set;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -95,13 +94,11 @@ public class ListOrderedSetTest<E>
@Test
public void testDecorator() {
- assertAll(
- () -> assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet((List<E>) null)),
- () -> assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet((Set<E>) null)),
- () -> assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet(null, null)),
- () -> assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet(new HashSet<>(), null)),
- () -> assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet(null, new ArrayList<>()))
- );
+ assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet((List<E>) null));
+ assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet((Set<E>) null));
+ assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet(null, null));
+ assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet(new HashSet<>(), null));
+ assertThrows(NullPointerException.class, () ->
ListOrderedSet.listOrderedSet(null, new ArrayList<>()));
}
@Test
diff --git
a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java
b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java
index 06f4ff5e4..5b54a9b08 100644
---
a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java
+++
b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.set;
-import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -104,20 +103,12 @@ public class UnmodifiableSortedSetTest<E> extends
AbstractSortedSetTest<E> {
*/
@SuppressWarnings("unchecked")
public void verifyUnmodifiable(final Set<E> set) {
- assertAll(
- () -> assertThrows(UnsupportedOperationException.class, () ->
set.add((E) "value"),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
set.addAll(new TreeSet<>()),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
set.clear(),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
set.remove("x"),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
set.removeAll(array),
- "Expecting UnsupportedOperationException."),
- () -> assertThrows(UnsupportedOperationException.class, () ->
set.retainAll(array),
- "Expecting UnsupportedOperationException.")
- );
+ assertThrows(UnsupportedOperationException.class, () -> set.add((E)
"value"));
+ assertThrows(UnsupportedOperationException.class, () -> set.addAll(new
TreeSet<>()));
+ assertThrows(UnsupportedOperationException.class, () -> set.clear());
+ assertThrows(UnsupportedOperationException.class, () ->
set.remove("x"));
+ assertThrows(UnsupportedOperationException.class, () ->
set.removeAll(array));
+ assertThrows(UnsupportedOperationException.class, () ->
set.retainAll(array));
}
// public void testCreate() throws Exception {