From a8c0df14ca2398e7b5cc40549775e352a143ff22 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 25 Nov 2022 09:15:28 -0500 Subject: [PATCH 1/2] Sort imports --- .../bidimap/AbstractDualBidiMap.java | 2 +- .../collections4/map/CompositeMap.java | 3 +-- .../multimap/AbstractMultiValuedMap.java | 2 +- .../AbstractMultiValuedMapDecorator.java | 2 +- .../collections4/set/CompositeSet.java | 2 +- .../trie/AbstractBitwiseTrie.java | 1 - .../collections4/AbstractObjectTest.java | 4 ++-- .../collections4/CollectionUtilsTest.java | 2 +- .../collections4/IterableUtilsTest.java | 2 +- .../collections4/IteratorUtilsTest.java | 21 +++++++++++----- .../commons/collections4/MapUtilsTest.java | 1 + .../collections4/PredicateUtilsTest.java | 4 ++-- .../collections4/bag/AbstractBagTest.java | 6 ++--- .../AbstractCountingBloomFilterTest.java | 2 +- .../AbstractIndexProducerTest.java | 1 + .../bloomfilter/EnhancedDoubleHasherTest.java | 1 + .../collections4/bloomfilter/ShapeTest.java | 5 ++-- .../PredicatedCollectionBuilderTest.java | 8 +++---- .../comparators/BooleanComparatorTest.java | 8 +++---- .../AbstractAnyAllOnePredicateTest.java | 6 ++--- .../functors/AbstractClosureTest.java | 4 ++-- .../AbstractCompositePredicateTest.java | 4 ++-- .../functors/AbstractMockPredicateTest.java | 9 +++---- .../functors/AllPredicateTest.java | 6 ++--- .../functors/CatchAndRethrowClosureTest.java | 8 +++---- .../functors/ComparatorPredicateTest.java | 3 ++- .../iterators/ArrayIteratorTest.java | 4 ++-- .../iterators/ArrayListIteratorTest.java | 6 ++--- .../iterators/FilterListIteratorTest.java | 8 +++---- .../iterators/IteratorEnumerationTest.java | 10 ++++---- .../iterators/ListIteratorWrapper2Test.java | 4 ++-- .../iterators/LoopingIteratorTest.java | 10 ++++---- .../iterators/LoopingListIteratorTest.java | 12 +++++----- .../iterators/NodeListIteratorTest.java | 4 +++- .../ObjectArrayListIteratorTest.java | 6 ++--- .../UnmodifiableListIteratorTest.java | 4 ++-- .../keyvalue/AbstractMapEntryTest.java | 10 ++++---- .../keyvalue/DefaultKeyValueTest.java | 11 ++++----- .../keyvalue/DefaultMapEntryTest.java | 4 ++-- .../collections4/keyvalue/MultiKeyTest.java | 24 +++++++++---------- .../keyvalue/TiedMapEntryTest.java | 4 ++-- .../keyvalue/UnmodifiableMapEntryTest.java | 8 +++---- .../collections4/list/Collections701Test.java | 2 +- .../collections4/list/GrowthListTest.java | 2 +- .../collections4/list/LazyListTest.java | 10 ++++---- .../collections4/list/SetUniqueListTest.java | 16 +++++++++---- .../collections4/map/CompositeMapTest.java | 4 ++-- .../collections4/map/EmptyMapMutator.java | 2 +- .../collections4/map/LazySortedMapTest.java | 2 +- .../multimap/ArrayListValuedHashMapTest.java | 6 ++--- .../UnmodifiableMultiValuedMapTest.java | 8 +++---- .../AbstractPropertiesFactoryTest.java | 6 ++--- .../properties/EmptyPropertiesTest.java | 1 + .../properties/PropertiesFactoryTest.java | 2 +- .../properties/SortedPropertiesTest.java | 2 +- .../sequence/SequencesComparatorTest.java | 6 ++--- .../set/TransformedNavigableSetTest.java | 2 +- .../set/TransformedSortedSetTest.java | 2 +- .../set/UnmodifiableNavigableSetTest.java | 4 ++-- 59 files changed, 172 insertions(+), 151 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java index 779c29186..0640925cc 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java @@ -19,8 +19,8 @@ package org.apache.commons.collections4.bidimap; import java.util.Collection; import java.util.Iterator; import java.util.Map; -import java.util.Set; import java.util.Objects; +import java.util.Set; import java.util.function.Predicate; import org.apache.commons.collections4.BidiMap; diff --git a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java index bf44c25a2..2f893979d 100644 --- a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java +++ b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java @@ -17,14 +17,13 @@ package org.apache.commons.collections4.map; import java.io.Serializable; - import java.util.Collection; import java.util.Map; import java.util.Set; -import org.apache.commons.collections4.set.CompositeSet; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.collection.CompositeCollection; +import org.apache.commons.collections4.set.CompositeSet; /** * Decorates a map of other maps to provide a single unified view. diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java index c02fb2f80..10f101d5f 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java @@ -26,8 +26,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Map; -import java.util.Objects; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import org.apache.commons.collections4.CollectionUtils; diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapDecorator.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapDecorator.java index a86a06d93..eda463ff8 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapDecorator.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapDecorator.java @@ -19,8 +19,8 @@ package org.apache.commons.collections4.multimap; import java.io.Serializable; import java.util.Collection; import java.util.Map; -import java.util.Objects; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import org.apache.commons.collections4.MapIterator; diff --git a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java index 1fa72dc8b..2d5cfee42 100644 --- a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java +++ b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java @@ -23,8 +23,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Set; import java.util.Objects; +import java.util.Set; import java.util.function.Predicate; import org.apache.commons.collections4.CollectionUtils; diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java index 999cfa507..11e5aa1a0 100644 --- a/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java @@ -20,7 +20,6 @@ import java.io.Serializable; import java.util.AbstractMap; import java.util.Map; import java.util.Objects; -import java.util.Map.Entry; import org.apache.commons.collections4.Trie; diff --git a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java index eebd01345..b71025fd0 100644 --- a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java +++ b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java @@ -16,8 +16,6 @@ */ package org.apache.commons.collections4; -import org.junit.jupiter.api.Test; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -30,6 +28,8 @@ import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; +import org.junit.jupiter.api.Test; + /** * Abstract test class for {@link java.lang.Object} methods and contracts. *

diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index 20af9a1e5..fb03cdf57 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -23,8 +23,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java index 01b9c9bac..657d0bf20 100644 --- a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java @@ -23,9 +23,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java index 2c7dbc347..01587f9f5 100644 --- a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java @@ -26,27 +26,36 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.Dictionary; +import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Vector; -import java.util.Dictionary; -import java.util.Enumeration; import java.util.Set; -import java.util.LinkedHashSet; +import java.util.Vector; -import org.apache.commons.collections4.iterators.*; +import org.apache.commons.collections4.iterators.ArrayIterator; +import org.apache.commons.collections4.iterators.EmptyIterator; +import org.apache.commons.collections4.iterators.EmptyListIterator; +import org.apache.commons.collections4.iterators.EmptyMapIterator; +import org.apache.commons.collections4.iterators.EmptyOrderedIterator; +import org.apache.commons.collections4.iterators.EmptyOrderedMapIterator; +import org.apache.commons.collections4.iterators.EnumerationIterator; +import org.apache.commons.collections4.iterators.NodeListIterator; +import org.apache.commons.collections4.iterators.ObjectArrayIterator; +import org.apache.commons.collections4.iterators.ZippingIterator; import org.apache.commons.collections4.map.EntrySetToMapIteratorAdapter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java index 9b4f0cecd..7e55b7a60 100644 --- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java @@ -43,6 +43,7 @@ import java.util.ResourceBundle; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; + import org.apache.commons.collections4.collection.TransformedCollectionTest; import org.apache.commons.collections4.keyvalue.DefaultKeyValue; import org.apache.commons.collections4.keyvalue.DefaultMapEntry; diff --git a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java index 0ceca827a..afbe01a6f 100644 --- a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java @@ -16,8 +16,8 @@ */ package org.apache.commons.collections4; -import static org.apache.commons.collections4.functors.NullPredicate.*; -import static org.apache.commons.collections4.functors.TruePredicate.*; +import static org.apache.commons.collections4.functors.NullPredicate.nullPredicate; +import static org.apache.commons.collections4.functors.TruePredicate.truePredicate; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; diff --git a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java index 62e6df003..0de6275f6 100644 --- a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java @@ -16,6 +16,9 @@ */ package org.apache.commons.collections4.bag; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; @@ -34,9 +37,6 @@ import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.set.AbstractSetTest; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Abstract test class for {@link org.apache.commons.collections4.Bag Bag} methods and contracts. *

diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCountingBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCountingBloomFilterTest.java index d2892f492..de424111f 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCountingBloomFilterTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCountingBloomFilterTest.java @@ -16,10 +16,10 @@ */ package org.apache.commons.collections4.bloomfilter; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexProducerTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexProducerTest.java index 38ce388bd..254644021 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexProducerTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexProducerTest.java @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.BitSet; import java.util.function.IntPredicate; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/EnhancedDoubleHasherTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/EnhancedDoubleHasherTest.java index d3528bf76..112b4def6 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/EnhancedDoubleHasherTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/EnhancedDoubleHasherTest.java @@ -18,6 +18,7 @@ package org.apache.commons.collections4.bloomfilter; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.jupiter.api.Test; /** diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/ShapeTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/ShapeTest.java index 63eb2f70b..53ea242ed 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/ShapeTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/ShapeTest.java @@ -16,13 +16,12 @@ */ package org.apache.commons.collections4.bloomfilter; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Arrays; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java index 82802f6ea..484189fd5 100644 --- a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java @@ -16,6 +16,10 @@ */ package org.apache.commons.collections4.collection; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -26,10 +30,6 @@ import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.Predicate; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** * Tests the PredicatedCollection.Builder class. * 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 863222b84..26fc124e7 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java @@ -16,6 +16,10 @@ */ package org.apache.commons.collections4.comparators; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -23,10 +27,6 @@ import java.util.List; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Tests for {@link BooleanComparator}. */ diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractAnyAllOnePredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractAnyAllOnePredicateTest.java index ea48d8559..4305b488d 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AbstractAnyAllOnePredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AbstractAnyAllOnePredicateTest.java @@ -16,15 +16,15 @@ */ package org.apache.commons.collections4.functors; -import org.apache.commons.collections4.Predicate; - import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.jupiter.api.Test; import java.util.Collections; +import org.apache.commons.collections4.Predicate; +import org.junit.jupiter.api.Test; + /** * Base class for tests of AnyPredicate, AllPredicate, and OnePredicate. * diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractClosureTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractClosureTest.java index 3a27c178e..3806b8192 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AbstractClosureTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AbstractClosureTest.java @@ -16,11 +16,11 @@ */ package org.apache.commons.collections4.functors; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.apache.commons.collections4.Closure; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertNotNull; - public abstract class AbstractClosureTest { @Test diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java index cf1fd6531..94083854e 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.collections4.functors; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -25,8 +27,6 @@ import org.apache.commons.collections4.Predicate; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Base class for tests of composite predicates. * diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java index 077461932..b16037bf5 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java @@ -16,15 +16,16 @@ */ package org.apache.commons.collections4.functors; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + import java.util.ArrayList; import java.util.List; -import static org.easymock.EasyMock.verify; -import static org.easymock.EasyMock.replay; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.AfterEach; import org.apache.commons.collections4.Predicate; import org.easymock.EasyMock; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; /** * Base class for tests of predicates which delegate to other predicates when evaluating an object. This class diff --git a/src/test/java/org/apache/commons/collections4/functors/AllPredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AllPredicateTest.java index d0d8dcefe..d3e697523 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AllPredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AllPredicateTest.java @@ -16,16 +16,16 @@ */ package org.apache.commons.collections4.functors; -import org.apache.commons.collections4.Predicate; - import static org.apache.commons.collections4.functors.AllPredicate.allPredicate; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.jupiter.api.Test; import java.util.Collection; import java.util.Collections; +import org.apache.commons.collections4.Predicate; +import org.junit.jupiter.api.Test; + /** * Tests the org.apache.commons.collections.functors.AllPredicate class. * diff --git a/src/test/java/org/apache/commons/collections4/functors/CatchAndRethrowClosureTest.java b/src/test/java/org/apache/commons/collections4/functors/CatchAndRethrowClosureTest.java index 11a771b71..20f86eb20 100644 --- a/src/test/java/org/apache/commons/collections4/functors/CatchAndRethrowClosureTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/CatchAndRethrowClosureTest.java @@ -16,6 +16,10 @@ */ package org.apache.commons.collections4.functors; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.DynamicTest.dynamicTest; + import java.io.IOException; import java.util.Arrays; import java.util.Collection; @@ -25,10 +29,6 @@ import org.apache.commons.collections4.FunctorException; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.DynamicTest.dynamicTest; - public class CatchAndRethrowClosureTest extends AbstractClosureTest { private static Closure generateIOExceptionClosure() { diff --git a/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java index e519dc13d..90cc57c04 100644 --- a/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java @@ -16,11 +16,12 @@ */ package org.apache.commons.collections4.functors; -import static org.apache.commons.collections4.functors.ComparatorPredicate.*; +import static org.apache.commons.collections4.functors.ComparatorPredicate.comparatorPredicate; import java.util.Comparator; import org.apache.commons.collections4.Predicate; +import org.apache.commons.collections4.functors.ComparatorPredicate.Criterion; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java index fe5930689..c5b494d78 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java @@ -16,13 +16,13 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.Iterator; import java.util.NoSuchElementException; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Tests the ArrayIterator to ensure that the next() method will actually * perform the iteration rather than the hasNext() method. diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java index 564324ac7..62a8ec6cf 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java @@ -16,14 +16,14 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ListIterator; import java.util.NoSuchElementException; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Test the ArrayListIterator class. */ diff --git a/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java index 56add988a..2d902c66f 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java @@ -16,6 +16,10 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -29,10 +33,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** * Tests the FilterListIterator class. * diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java index 1007d8160..5baf0a202 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java @@ -16,17 +16,17 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** * Tests the IteratorEnumeration. */ diff --git a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java index 4b7d84993..0b9484405 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java @@ -16,6 +16,8 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -25,8 +27,6 @@ import org.apache.commons.collections4.ResettableListIterator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Tests the ListIteratorWrapper to ensure that it behaves as expected when wrapping a ListIterator. */ diff --git a/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java index 97a092589..a6dce6fd6 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java @@ -16,6 +16,11 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -23,11 +28,6 @@ import java.util.NoSuchElementException; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** * Tests the LoopingIterator class. */ 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 969cdbd0e..1ccdb264f 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java @@ -16,6 +16,12 @@ */ 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; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -23,12 +29,6 @@ import java.util.NoSuchElementException; import org.junit.jupiter.api.Test; -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; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** * Tests the LoopingListIterator class. */ diff --git a/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java index 4f7277b6a..b8d808bbd 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/NodeListIteratorTest.java @@ -16,7 +16,9 @@ */ package org.apache.commons.collections4.iterators; -import static org.easymock.EasyMock.*; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Iterator; diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java index a60f99828..328811638 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java @@ -16,14 +16,14 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ListIterator; import java.util.NoSuchElementException; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Tests the ObjectArrayListIterator class. */ diff --git a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java index 42eb51bfb..9f32002b5 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.collections4.iterators; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -26,8 +28,6 @@ import org.apache.commons.collections4.Unmodifiable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Tests the UnmodifiableListIterator. */ diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java index 3dedf8625..e5b10bb0a 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java @@ -16,17 +16,17 @@ */ package org.apache.commons.collections4.keyvalue; -import java.util.HashMap; -import java.util.Map; - -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; + /** * Abstract tests that can be extended to test any Map.Entry implementation. * Subclasses must implement {@link #makeMapEntry(Object, Object)} to return diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java index d9e4a8c69..8b88b4b7e 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java @@ -16,17 +16,16 @@ */ package org.apache.commons.collections4.keyvalue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; - -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.HashMap; import java.util.Map; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; /** * Test the DefaultKeyValue class. diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java index b7365e8b0..9b1cc8e74 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java @@ -16,13 +16,13 @@ */ package org.apache.commons.collections4.keyvalue; +import static org.junit.jupiter.api.Assertions.assertSame; + import java.util.Map; import org.apache.commons.collections4.KeyValue; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertSame; - /** * Test the DefaultMapEntry class. * diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java index b23fc4bb1..85851af06 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java @@ -16,9 +16,15 @@ */ package org.apache.commons.collections4.keyvalue; -import org.junit.jupiter.api.DynamicTest; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestFactory; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.DynamicTest.dynamicTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -31,15 +37,9 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.DynamicTest.dynamicTest; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; /** * Unit tests for {@link org.apache.commons.collections4.keyvalue.MultiKey}. diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java index 14e7a74df..cd2419b1e 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java @@ -16,12 +16,12 @@ */ package org.apache.commons.collections4.keyvalue; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.HashMap; import java.util.Map; -import static org.junit.jupiter.api.Assertions.assertSame; +import org.junit.jupiter.api.Test; /** * Test the TiedMapEntry class. diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java index 1f4627ca2..66deec62a 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java @@ -16,16 +16,16 @@ */ package org.apache.commons.collections4.keyvalue; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Map; import org.apache.commons.collections4.KeyValue; import org.apache.commons.collections4.Unmodifiable; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** * Test the UnmodifiableMapEntry class. * diff --git a/src/test/java/org/apache/commons/collections4/list/Collections701Test.java b/src/test/java/org/apache/commons/collections4/list/Collections701Test.java index b45dfabe7..4f6b30d59 100644 --- a/src/test/java/org/apache/commons/collections4/list/Collections701Test.java +++ b/src/test/java/org/apache/commons/collections4/list/Collections701Test.java @@ -21,8 +21,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests for COLLECTIONS-701. diff --git a/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java b/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java index 6fe17230c..bf14a215c 100644 --- a/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java @@ -26,8 +26,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; /** * Extension of {@link AbstractListTest} for exercising the {@link GrowthList}. diff --git a/src/test/java/org/apache/commons/collections4/list/LazyListTest.java b/src/test/java/org/apache/commons/collections4/list/LazyListTest.java index 3e4cbe456..2c4679e6d 100644 --- a/src/test/java/org/apache/commons/collections4/list/LazyListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/LazyListTest.java @@ -16,16 +16,16 @@ */ package org.apache.commons.collections4.list; -import org.apache.commons.collections4.AbstractObjectTest; -import org.apache.commons.collections4.Factory; -import org.apache.commons.collections4.Transformer; -import org.junit.jupiter.api.Test; - import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.commons.collections4.AbstractObjectTest; +import org.apache.commons.collections4.Factory; +import org.apache.commons.collections4.Transformer; +import org.junit.jupiter.api.Test; + public class LazyListTest extends AbstractObjectTest { public LazyListTest() { diff --git a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java index b64e01d7f..8979b5b8e 100644 --- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java @@ -16,13 +16,21 @@ */ package org.apache.commons.collections4.list; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; +import java.util.TreeSet; + import org.apache.commons.collections4.set.UnmodifiableSet; import org.junit.jupiter.api.Test; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * JUnit tests. * diff --git a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java index c3a2b9073..be8d61ee2 100644 --- a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java @@ -18,9 +18,9 @@ package org.apache.commons.collections4.map; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.util.Map; -import java.util.HashMap; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java b/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java index e3002a316..57955ec51 100644 --- a/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java +++ b/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java @@ -16,8 +16,8 @@ */ package org.apache.commons.collections4.map; -import java.util.Map; import java.util.Collection; +import java.util.Map; /** * This class is used in TestCompositeMap. When testing serialization, 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 80469f5fd..9a13c5628 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,7 @@ */ package org.apache.commons.collections4.map; -import static org.apache.commons.collections4.map.LazySortedMap.*; +import static org.apache.commons.collections4.map.LazySortedMap.lazySortedMap; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java index 83853ff5f..5119380a9 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java @@ -16,12 +16,12 @@ */ package org.apache.commons.collections4.multimap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; -import java.util.HashMap; -import java.util.Arrays; -import java.util.ArrayList; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.ListValuedMap; diff --git a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java index 603835063..3238a9539 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java @@ -18,13 +18,13 @@ package org.apache.commons.collections4.multimap; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.util.Set; -import java.util.Map; -import java.util.Map.Entry; -import java.util.HashMap; import java.util.Arrays; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MapIterator; diff --git a/src/test/java/org/apache/commons/collections4/properties/AbstractPropertiesFactoryTest.java b/src/test/java/org/apache/commons/collections4/properties/AbstractPropertiesFactoryTest.java index 64a713a07..613b14694 100644 --- a/src/test/java/org/apache/commons/collections4/properties/AbstractPropertiesFactoryTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/AbstractPropertiesFactoryTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.collections4.properties; +import static org.junit.jupiter.params.provider.Arguments.arguments; + import java.io.BufferedReader; import java.io.FileInputStream; import java.nio.file.Files; @@ -24,15 +26,13 @@ import java.util.Properties; import java.util.stream.Stream; import org.apache.commons.collections4.BulkTest; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import static org.junit.jupiter.params.provider.Arguments.arguments; - public abstract class AbstractPropertiesFactoryTest { public static Stream getParameters() { diff --git a/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java b/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java index 243ab6009..d1d265a3b 100644 --- a/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java @@ -35,6 +35,7 @@ import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Properties; + import org.apache.commons.io.input.NullReader; import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java b/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java index a59e7fec0..c37990242 100644 --- a/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/PropertiesFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.commons.collections4.properties; import java.util.Properties; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class PropertiesFactoryTest extends AbstractPropertiesFactoryTest { diff --git a/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java b/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java index 38161bbbf..009e0b181 100644 --- a/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/SortedPropertiesTest.java @@ -20,8 +20,8 @@ import java.util.Enumeration; import java.util.Iterator; import java.util.Map; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class SortedPropertiesTest { diff --git a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java index 66d67cffe..9d2746776 100644 --- a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java @@ -16,6 +16,9 @@ */ package org.apache.commons.collections4.sequence; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -25,9 +28,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class SequencesComparatorTest { private List before; diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java index 6e82a6efb..1ef91f6bf 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java @@ -19,8 +19,8 @@ package org.apache.commons.collections4.set; import java.util.Arrays; import java.util.Collections; import java.util.NavigableSet; -import java.util.TreeSet; import java.util.Set; +import java.util.TreeSet; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Transformer; diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java index aa909a8c8..4530ba097 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java @@ -18,9 +18,9 @@ package org.apache.commons.collections4.set; import java.util.Arrays; import java.util.Collections; -import java.util.TreeSet; import java.util.Set; import java.util.SortedSet; +import java.util.TreeSet; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.Transformer; diff --git a/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java index d8748baa1..530d6d1f2 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.collections4.set; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -26,8 +28,6 @@ import java.util.TreeSet; import org.apache.commons.collections4.BulkTest; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertThrows; - /** * Extension of {@link AbstractNavigableSetTest} for exercising the * {@link UnmodifiableNavigableSet} implementation. From 6031f5395b8da5fbe1c566094a2bc528aff3d4c6 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 25 Nov 2022 09:19:47 -0500 Subject: [PATCH 2/2] Reuse constants --- .../org/apache/commons/collections4/CollectionUtilsTest.java | 3 ++- .../java/org/apache/commons/collections4/MapUtilsTest.java | 2 +- .../org/apache/commons/collections4/bag/AbstractBagTest.java | 3 ++- .../collections4/collection/AbstractCollectionTest.java | 3 ++- .../collections4/comparators/FixedOrderComparatorTest.java | 5 +++-- .../commons/collections4/iterators/FilterIteratorTest.java | 3 ++- .../commons/collections4/list/CursorableLinkedListTest.java | 5 +++-- .../commons/collections4/multiset/AbstractMultiSetTest.java | 3 ++- 8 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index fb03cdf57..de4480ec4 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -54,6 +54,7 @@ import org.apache.commons.collections4.collection.TransformedCollection; import org.apache.commons.collections4.collection.UnmodifiableCollection; import org.apache.commons.collections4.functors.DefaultEquator; import org.apache.commons.collections4.queue.CircularFifoQueue; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -1029,7 +1030,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void reverse() { CollectionUtils.reverseArray(new Object[] {}); - final Integer[] a = collectionA.toArray(new Integer[collectionA.size()]); + final Integer[] a = collectionA.toArray(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY); CollectionUtils.reverseArray(a); // assume our implementation is correct if it returns the same order as the Java function Collections.reverse(collectionA); diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java index 7e55b7a60..66b61c71d 100644 --- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java @@ -167,7 +167,7 @@ public class MapUtilsTest { () -> assertThrows(NullPointerException.class, () -> MapUtils.putAll(null, new Object[0])) ); - Map test = MapUtils.putAll(new HashMap(), new String[0]); + Map test = MapUtils.putAll(new HashMap(), org.apache.commons.lang3.ArrayUtils.EMPTY_STRING_ARRAY); assertEquals(0, test.size()); // sub array diff --git a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java index 0de6275f6..c3884c749 100644 --- a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java @@ -35,6 +35,7 @@ import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.set.AbstractSetTest; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; /** @@ -503,7 +504,7 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { bag.add((T) "B"); bag.add((T) "B"); bag.add((T) "C"); - final String[] array = bag.toArray(new String[0]); + final String[] array = bag.toArray(ArrayUtils.EMPTY_STRING_ARRAY); int a = 0, b = 0, c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; diff --git a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java index 05c539b57..166afbf0c 100644 --- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java @@ -39,6 +39,7 @@ import java.util.Objects; import java.util.function.Predicate; import org.apache.commons.collections4.AbstractObjectTest; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -1120,7 +1121,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { "toArray(null) should raise NPE"); verify(); - array = getCollection().toArray(new Object[0]); + array = getCollection().toArray(ArrayUtils.EMPTY_OBJECT_ARRAY); a = getCollection().toArray(); if ((getIterationBehaviour() & UNORDERED) != 0) { diff --git a/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java index 0f67861ee..9b23abec8 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java @@ -24,6 +24,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Random; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; /** @@ -170,7 +171,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { assertEquals(FixedOrderComparator.UnknownObjectBehavior.BEFORE, comparator.getUnknownObjectBehavior()); LinkedList keys = new LinkedList<>(Arrays.asList(topCities)); keys.addFirst("Minneapolis"); - assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator); + assertComparatorYieldsOrder(keys.toArray(ArrayUtils.EMPTY_STRING_ARRAY), comparator); assertEquals(-1, comparator.compare("Minneapolis", "New York")); assertEquals( 1, comparator.compare("New York", "Minneapolis")); @@ -180,7 +181,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { comparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.AFTER); keys = new LinkedList<>(Arrays.asList(topCities)); keys.add("Minneapolis"); - assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator); + assertComparatorYieldsOrder(keys.toArray(ArrayUtils.EMPTY_STRING_ARRAY), comparator); assertEquals( 1, comparator.compare("Minneapolis", "New York")); assertEquals(-1, comparator.compare("New York", "Minneapolis")); diff --git a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java index 1eb2412f7..ce670dd84 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java @@ -28,6 +28,7 @@ import java.util.NoSuchElementException; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.NotNullPredicate; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -105,7 +106,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { @Test public void testReturnValues() { - verifyElementsInPredicate(new String[0]); + verifyElementsInPredicate(ArrayUtils.EMPTY_STRING_ARRAY); verifyElementsInPredicate(new String[] { "a" }); verifyElementsInPredicate(new String[] { "b" }); verifyElementsInPredicate(new String[] { "c" }); 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 ab504182b..e81d37dba 100644 --- a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java @@ -29,6 +29,7 @@ import java.util.ListIterator; import java.util.NoSuchElementException; import org.apache.commons.collections4.BulkTest; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -1390,7 +1391,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { assertEquals("5", elts[4]); assertEquals(5, elts.length); - final String[] elts2 = list.toArray(new String[0]); + final String[] elts2 = list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); assertEquals("1", elts2[0]); assertEquals("2", elts2[1]); assertEquals("3", elts2[2]); @@ -1513,7 +1514,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { list.add(prefix + bulk + element); list.add(prefix + bulk + bulk + element); } - return list.toArray(new String[0]); + return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } @Override diff --git a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java index 1f41f14a2..6da6c0ffd 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java @@ -34,6 +34,7 @@ import org.apache.commons.collections4.BulkTest; import org.apache.commons.collections4.MultiSet; import org.apache.commons.collections4.collection.AbstractCollectionTest; import org.apache.commons.collections4.set.AbstractSetTest; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; /** @@ -517,7 +518,7 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest multiset.add((T) "B"); multiset.add((T) "B"); multiset.add((T) "C"); - final String[] array = multiset.toArray(new String[0]); + final String[] array = multiset.toArray(ArrayUtils.EMPTY_STRING_ARRAY); int a = 0, b = 0, c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0;