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 5588a9b Clean up tests. 5588a9b is described below commit 5588a9bdeebd5a8a3f4010eaab8a6a4484d6b71f Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Mar 4 08:56:42 2022 -0500 Clean up tests. - Simple syntax for array creation. - Use better Collection APIs. - Make test fixture a static class. - Use number cache when possible. --- .../commons/collections4/ClosureUtilsTest.java | 2 +- .../commons/collections4/CollectionUtilsTest.java | 8 ++++---- .../commons/collections4/FactoryUtilsTest.java | 2 +- .../commons/collections4/PredicateUtilsTest.java | 2 +- .../commons/collections4/TransformerUtilsTest.java | 2 +- .../collections4/bag/TransformedBagTest.java | 4 ++-- .../collections4/bag/TransformedSortedBagTest.java | 4 ++-- .../collections4/bidimap/AbstractBidiMapTest.java | 2 +- .../collection/AbstractCollectionTest.java | 2 +- .../comparators/FixedOrderComparatorTest.java | 2 +- .../functors/ComparatorPredicateTest.java | 2 +- .../iterators/ArrayListIteratorTest.java | 4 ++-- .../iterators/ObjectArrayListIteratorTest.java | 4 ++-- .../collections4/keyvalue/MultiKeyTest.java | 6 +++--- .../list/CursorableLinkedListTest.java | 2 +- .../collections4/list/SetUniqueListTest.java | 24 +++++++++++----------- .../collections4/list/TransformedListTest.java | 2 +- .../commons/collections4/map/AbstractMapTest.java | 6 +++--- .../collections4/map/LazySortedMapTest.java | 2 +- .../commons/collections4/map/MultiKeyMapTest.java | 4 ++-- .../collections4/map/PassiveExpiringMapTest.java | 4 ++-- .../commons/collections4/map/ReferenceMapTest.java | 4 ++-- .../collections4/map/TransformedMapTest.java | 2 +- .../collections4/map/TransformedSortedMapTest.java | 2 +- .../multimap/AbstractMultiValuedMapTest.java | 4 ++-- .../multimap/TransformedMultiValuedMapTest.java | 4 ++-- .../properties/EmptyPropertiesTest.java | 4 ++-- .../collections4/queue/TransformedQueueTest.java | 4 ++-- .../sequence/SequencesComparatorTest.java | 6 +++--- .../set/TransformedNavigableSetTest.java | 2 +- .../collections4/set/TransformedSetTest.java | 2 +- .../collections4/set/TransformedSortedSetTest.java | 2 +- .../splitmap/TransformedSplitMapTest.java | 4 ++-- .../collections4/trie/PatriciaTrieTest.java | 24 +++++++++++----------- 34 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java b/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java index eef6e9e..906023d 100644 --- a/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java @@ -413,7 +413,7 @@ public class ClosureUtilsTest { */ @Test public void testSingletonPatternInSerialization() { - final Object[] singletons = new Object[] { + final Object[] singletons = { ExceptionClosure.INSTANCE, NOPClosure.INSTANCE, }; diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index 4ce267c..6ad9370 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -2022,7 +2022,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSize_Array() { - final Object[] objectArray = new Object[0]; + final Object[] objectArray = {}; assertEquals(0, CollectionUtils.size(objectArray)); final String[] stringArray = new String[3]; @@ -2083,7 +2083,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSize_PrimitiveArray() { - final int[] intArray = new int[0]; + final int[] intArray = {}; assertEquals(0, CollectionUtils.size(intArray)); final double[] doubleArray = new double[3]; @@ -2096,7 +2096,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSizeIsEmpty_Array() { - final Object[] objectArray = new Object[0]; + final Object[] objectArray = {}; assertTrue(CollectionUtils.sizeIsEmpty(objectArray)); final String[] stringArray = new String[3]; @@ -2162,7 +2162,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSizeIsEmpty_PrimitiveArray() { - final int[] intArray = new int[0]; + final int[] intArray = {}; assertTrue(CollectionUtils.sizeIsEmpty(intArray)); final double[] doubleArray = new double[3]; diff --git a/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java b/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java index 0e4c85a..45150fa 100644 --- a/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java @@ -240,7 +240,7 @@ public class FactoryUtilsTest { */ @Test public void testSingletonPatternInSerialization() { - final Object[] singletons = new Object[] { + final Object[] singletons = { ExceptionFactory.INSTANCE, }; diff --git a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java index bd30e56..3d7387f 100644 --- a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java @@ -672,7 +672,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { */ @Test public void testSingletonPatternInSerialization() { - final Object[] singletons = new Object[] { + final Object[] singletons = { ExceptionPredicate.INSTANCE, FalsePredicate.INSTANCE, NotNullPredicate.INSTANCE, diff --git a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java index 3bac7fd..6613543 100644 --- a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java @@ -419,7 +419,7 @@ public class TransformerUtilsTest { */ @Test public void testSingletonPatternInSerialization() { - final Object[] singletons = new Object[] { + final Object[] singletons = { ExceptionTransformer.INSTANCE, NOPTransformer.INSTANCE, StringValueTransformer.stringValueTransformer(), diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java index ae325fb..d5faf86 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java @@ -53,7 +53,7 @@ public class TransformedBagTest<T> extends AbstractBagTest<T> { final Bag<T> bag = TransformedBag.transformingBag(new HashBag<T>(), (Transformer<T, T>) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertTrue(bag.isEmpty()); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; for (int i = 0; i < els.length; i++) { bag.add((T) els[i]); assertEquals(i + 1, bag.size()); @@ -68,7 +68,7 @@ public class TransformedBagTest<T> extends AbstractBagTest<T> { @SuppressWarnings("unchecked") public void testTransformedBag_decorateTransform() { final Bag<T> originalBag = new HashBag<>(); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalBag.add((T) el); } diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java index e175cee..e1f0769 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java @@ -50,7 +50,7 @@ public class TransformedSortedBagTest<T> extends AbstractSortedBagTest<T> { public void testTransformedBag() { final SortedBag<T> bag = TransformedSortedBag.transformingSortedBag(new TreeBag<T>(), (Transformer<T, T>) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, bag.size()); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; for (int i = 0; i < els.length; i++) { bag.add((T) els[i]); assertEquals(i + 1, bag.size()); @@ -63,7 +63,7 @@ public class TransformedSortedBagTest<T> extends AbstractSortedBagTest<T> { public void testTransformedBag_decorateTransform() { final TreeBag<T> originalBag = new TreeBag<>(); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalBag.add((T) el); } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java index 8a01b65..6ec599b 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java @@ -278,7 +278,7 @@ public abstract class AbstractBidiMapTest<K, V> extends AbstractIterableMapTest< } private void removeByKeySet(final BidiMap<?, ?> map, final Object key, final Object value) { - map.keySet().remove(key); + map.remove(key); assertFalse("Key was not removed.", map.containsKey(key)); assertFalse("Value was not removed.", map.containsValue(value)); 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 5098330..60d6370 100644 --- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java @@ -1093,7 +1093,7 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest { */ public void testCollectionToArray2() { resetEmpty(); - Object[] a = new Object[] { new Object(), null, null }; + Object[] a = { new Object(), null, null }; Object[] array = getCollection().toArray(a); assertEquals("Given array shouldn't shrink", array, a); assertNull("Last element should be set to null", a[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 06fc352..837bf2e 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java @@ -34,7 +34,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest<String> { /** * Top cities of the world, by population including metro areas. */ - private static final String topCities[] = new String[] { + private static final String topCities[] = { "Tokyo", "Mexico City", "Mumbai", 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 afda1fc..e29a52b 100644 --- a/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/ComparatorPredicateTest.java @@ -25,7 +25,7 @@ import org.junit.Test; public class ComparatorPredicateTest extends AbstractPredicateTest { - private class TestComparator<T extends Comparable<T>> implements Comparator<T> { + private static class TestComparator<T extends Comparable<T>> implements Comparator<T> { @Override public int compare(final T first, final T second) { return first.compareTo(second); 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 5ba352b..f045fb5 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java @@ -87,9 +87,9 @@ public class ArrayListIteratorTest<E> extends ArrayIteratorTest<E> { */ @SuppressWarnings("unchecked") public void testListIteratorSet() { - final String[] testData = new String[] { "a", "b", "c" }; + final String[] testData = { "a", "b", "c" }; - final String[] result = new String[] { "0", "1", "2" }; + final String[] result = { "0", "1", "2" }; ListIterator<E> iter = makeArrayListIterator(testData); int x = 0; 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 2875db0..1d6ed7e 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java @@ -84,9 +84,9 @@ public class ObjectArrayListIteratorTest<E> extends ObjectArrayIteratorTest<E> { */ @SuppressWarnings("unchecked") public void testListIteratorSet() { - final String[] testData = new String[] { "a", "b", "c" }; + final String[] testData = { "a", "b", "c" }; - final String[] result = new String[] { "0", "1", "2" }; + final String[] result = { "0", "1", "2" }; ListIterator<E> iter = makeArrayListIterator((E[]) testData); int x = 0; 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 05db8fc..83b07b2 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java @@ -120,7 +120,7 @@ public class MultiKeyTest { @Test public void testConstructorsByArray() throws Exception { MultiKey<Integer> mk; - Integer[] keys = new Integer[] { THREE, FOUR, ONE, TWO }; + Integer[] keys = { THREE, FOUR, ONE, TWO }; mk = new MultiKey<>(keys); assertArrayEquals(new Object[]{THREE, FOUR, ONE, TWO}, mk.getKeys()); keys[3] = FIVE; // no effect @@ -246,7 +246,7 @@ public class MultiKeyTest { @Test public void testGetKeysArrayConstructorCloned() { - final Integer[] keys = new Integer[] { ONE, TWO }; + final Integer[] keys = { ONE, TWO }; final MultiKey<Integer> mk = new MultiKey<>(keys, true); final Object[] array = mk.getKeys(); assertNotSame(array, keys); @@ -258,7 +258,7 @@ public class MultiKeyTest { @Test public void testGetKeysArrayConstructorNonCloned() { - final Integer[] keys = new Integer[] { ONE, TWO }; + final Integer[] keys = { ONE, TWO }; final MultiKey<Integer> mk = new MultiKey<>(keys, false); final Object[] array = mk.getKeys(); assertNotSame(array, keys); // still not equal 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 f9a17ee..f5396cf 100644 --- a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java @@ -1496,7 +1496,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { final ArrayList<String> list = new ArrayList<>(); final String prefix = "CursorableLinkedListTest"; final String bulk = ".bulkTestSubList"; - final String[] ignored = new String[] { + final String[] ignored = { ".testEmptyListSerialization", ".testFullListSerialization", ".testEmptyListCompatibility", 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 b9bd9c8..87de370 100644 --- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java @@ -61,18 +61,18 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { Integer.valueOf(2), "Three", Integer.valueOf(4), - new Double(5), - new Float(6), + Double.valueOf(5), + Float.valueOf(6), "Seven", "Eight", "Nine", Integer.valueOf(10), - new Short((short) 11), - new Long(12), + Short.valueOf((short) 11), + Long.valueOf(12), "Thirteen", "14", "15", - new Byte((byte) 16) + Byte.valueOf((byte) 16) }; } @@ -234,7 +234,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { } public void testFactory() { - final Integer[] array = new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(1) }; + final Integer[] array = { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(1) }; final ArrayList<Integer> list = new ArrayList<>(Arrays.asList(array)); final SetUniqueList<Integer> lset = SetUniqueList.setUniqueList(list); @@ -337,12 +337,12 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { // override for set behavior resetFull(); final int size = getCollection().size(); - getCollection().set(0, (E) new Long(1000)); + getCollection().set(0, (E) Long.valueOf(1000)); assertEquals(size, getCollection().size()); - getCollection().set(2, (E) new Long(1000)); + getCollection().set(2, (E) Long.valueOf(1000)); assertEquals(size - 1, getCollection().size()); - assertEquals(new Long(1000), getCollection().get(1)); // set into 2, but shifted down to 1 + assertEquals(Long.valueOf(1000), getCollection().get(1)); // set into 2, but shifted down to 1 } @SuppressWarnings("unchecked") @@ -596,12 +596,12 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { if (extraVerify) { final int size = getCollection().size(); - getCollection().add((E) new Long(1000)); + getCollection().add((E) Long.valueOf(1000)); assertEquals(size + 1, getCollection().size()); - getCollection().add((E) new Long(1000)); + getCollection().add((E) Long.valueOf(1000)); assertEquals(size + 1, getCollection().size()); - assertEquals(new Long(1000), getCollection().get(size)); + assertEquals(Long.valueOf(1000), getCollection().get(size)); getCollection().remove(size); } diff --git a/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java b/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java index 92da3d8..cef6b57 100644 --- a/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java @@ -109,7 +109,7 @@ public class TransformedListTest<E> extends AbstractListTest<E> { public void testTransformedList_decorateTransform() { final List<Object> originalList = new ArrayList<>(); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalList.add(el); } diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java index 69af4e7..e30fef4 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java @@ -299,7 +299,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { */ @SuppressWarnings("unchecked") public K[] getSampleKeys() { - final Object[] result = new Object[] { + final Object[] result = { "blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee", "hello", "goodbye", "we'll", "see", "you", "all", "again", "key", @@ -354,7 +354,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { */ @SuppressWarnings("unchecked") public V[] getSampleValues() { - final Object[] result = new Object[] { + final Object[] result = { "blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev", "hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv", isAllowNullValue() && !JDK12 ? null : "nonnullvalue", @@ -377,7 +377,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { */ @SuppressWarnings("unchecked") public V[] getNewSampleValues() { - final Object[] result = new Object[] { + final Object[] result = { isAllowNullValue() && !JDK12 && isAllowDuplicateValues() ? null : "newnonnullvalue", "newvalue", isAllowDuplicateValues() ? "newvalue" : "newvalue2", 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 9e95343..9bccbf7 100644 --- a/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LazySortedMapTest.java @@ -39,7 +39,7 @@ import org.junit.Test; @SuppressWarnings("boxing") public class LazySortedMapTest<K, V> extends AbstractSortedMapTest<K, V> { - private class ReverseStringComparator implements Comparator<String> { + private static class ReverseStringComparator implements Comparator<String> { @Override public int compare(final String arg0, final String arg1) { return arg1.compareTo(arg0); diff --git a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java index 9251662..4876405 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java @@ -121,8 +121,8 @@ public class MultiKeyMapTest<K, V> extends AbstractIterableMapTest<MultiKey<? ex assertFalse(map.containsValue(null)); assertNull(map.remove(null)); assertFalse(map.entrySet().contains(null)); - assertFalse(map.keySet().contains(null)); - assertFalse(map.values().contains(null)); + assertFalse(map.containsKey(null)); + assertFalse(map.containsValue(null)); try { map.put(null, null); fail(); 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 4edaf51..4e8b0b1 100644 --- a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java @@ -214,7 +214,7 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> { public void testKeySet() { final Map<Integer, String> m = makeTestMap(); - assertEquals(3, m.keySet().size()); + assertEquals(3, m.size()); } public void testPut() { @@ -234,7 +234,7 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> { public void testValues() { final Map<Integer, String> m = makeTestMap(); - assertEquals(3, m.values().size()); + assertEquals(3, m.size()); } public void testZeroTimeToLive() { diff --git a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java index bfaf957..064516e 100644 --- a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java @@ -88,8 +88,8 @@ public class ReferenceMapTest<K, V> extends AbstractIterableMapTest<K, V> { assertFalse(map.containsValue(null)); assertNull(map.remove(null)); assertFalse(map.entrySet().contains(null)); - assertFalse(map.keySet().contains(null)); - assertFalse(map.values().contains(null)); + assertFalse(map.containsKey(null)); + assertFalse(map.containsValue(null)); try { map.put(null, null); fail(); diff --git a/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java b/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java index d8f2160..ffb2828 100644 --- a/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java @@ -45,7 +45,7 @@ public class TransformedMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings({ "unchecked", "rawtypes" }) public void testTransformedMap() { - final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; + final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; Map<K, V> map = TransformedMap .transformingMap( diff --git a/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java index a2ea6f9..e5979ac 100644 --- a/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java @@ -65,7 +65,7 @@ public class TransformedSortedMapTest<K, V> extends AbstractSortedMapTest<K, V> @SuppressWarnings("unchecked") public void testTransformedMap() { - final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; + final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; SortedMap<K, V> map = TransformedSortedMap .transformingSortedMap( diff --git a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java index 7307b42..f40776b 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java @@ -129,7 +129,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes */ @SuppressWarnings("unchecked") public K[] getSampleKeys() { - final Object[] result = new Object[] { + final Object[] result = { "one", "one", "two", "two", "three", "three" }; @@ -144,7 +144,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes */ @SuppressWarnings("unchecked") public V[] getSampleValues() { - final Object[] result = new Object[] { + final Object[] result = { "uno", "un", "dos", "deux", "tres", "trois" }; diff --git a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java index e47bd2e..7c7d9cd 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java @@ -51,7 +51,7 @@ public class TransformedMultiValuedMapTest<K, V> extends AbstractMultiValuedMapT // ----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testKeyTransformedMap() { - final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; + final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; final MultiValuedMap<K, V> map = TransformedMultiValuedMap.transformingMap( new ArrayListValuedHashMap<K, V>(), @@ -75,7 +75,7 @@ public class TransformedMultiValuedMapTest<K, V> extends AbstractMultiValuedMapT @SuppressWarnings("unchecked") public void testValueTransformedMap() { - final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; + final Object[] els = { "1", "3", "5", "7", "2", "4", "6" }; final MultiValuedMap<K, V> map = TransformedMultiValuedMap.transformingMap( new ArrayListValuedHashMap<K, V>(), null, 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 e49b192..572cdcd 100644 --- a/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java +++ b/src/test/java/org/apache/commons/collections4/properties/EmptyPropertiesTest.java @@ -150,7 +150,7 @@ public class EmptyPropertiesTest { @Test public void testKeySet() { - assertTrue(PropertiesFactory.EMPTY_PROPERTIES.keySet().isEmpty()); + assertTrue(PropertiesFactory.EMPTY_PROPERTIES.isEmpty()); } @Test @@ -360,6 +360,6 @@ public class EmptyPropertiesTest { @Test public void testValues() { - assertTrue(PropertiesFactory.EMPTY_PROPERTIES.values().isEmpty()); + assertTrue(PropertiesFactory.EMPTY_PROPERTIES.isEmpty()); } } diff --git a/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java index cd3a9e9..1e71a4f 100644 --- a/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java @@ -65,7 +65,7 @@ public class TransformedQueueTest<E> extends AbstractQueueTest<E> { final Queue<Object> queue = TransformedQueue.transformingQueue(new LinkedList<>(), TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, queue.size()); - final Object[] elements = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; + final Object[] elements = { "1", "3", "5", "7", "2", "4", "6" }; for (int i = 0; i < elements.length; i++) { queue.add(elements[i]); assertEquals(i + 1, queue.size()); @@ -81,7 +81,7 @@ public class TransformedQueueTest<E> extends AbstractQueueTest<E> { @SuppressWarnings({ "rawtypes", "unchecked" }) public void testTransformedQueue_decorateTransform() { final Queue originalQueue = new LinkedList(); - final Object[] elements = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] elements = {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalQueue, elements); final Queue<?> queue = TransformedQueue.transformedQueue(originalQueue, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); 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 4ed0737..66d67cf 100644 --- a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java @@ -57,7 +57,7 @@ public class SequencesComparatorTest { @Test public void testMinimal() { - final String[] shadokAlph = new String[] { + final String[] shadokAlph = { "GA", "BU", "ZO", @@ -109,7 +109,7 @@ public class SequencesComparatorTest { @Test public void testShadok() { final int lgMax = 5; - final String[] shadokAlph = new String[] { + final String[] shadokAlph = { "GA", "BU", "ZO", @@ -154,7 +154,7 @@ public class SequencesComparatorTest { return list; } - private class ExecutionVisitor<T> implements CommandVisitor<T> { + private static class ExecutionVisitor<T> implements CommandVisitor<T> { private List<T> v; private int index; 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 457069a..12fe709 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java @@ -76,7 +76,7 @@ public class TransformedNavigableSetTest<E> extends AbstractNavigableSetTest<E> public void testTransformedSet_decorateTransform() { final Set<Object> originalSet = new TreeSet<>(); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalSet, els); final Set<?> set = TransformedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java index 9c71c02..e309d1d 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java @@ -81,7 +81,7 @@ public class TransformedSetTest<E> extends AbstractSetTest<E> { public void testTransformedSet_decorateTransform() { final Set<Object> originalSet = new HashSet<>(); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalSet, els); final Set<?> set = TransformedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(els.length, set.size()); 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 d222397..f04f484 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java @@ -74,7 +74,7 @@ public class TransformedSortedSetTest<E> extends AbstractSortedSetTest<E> { public void testTransformedSet_decorateTransform() { final Set<Object> originalSet = new TreeSet<>(); - final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; + final Object[] els = {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalSet, els); final Set<?> set = TransformedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(els.length, set.size()); diff --git a/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java index 8c2c120..37f0166 100644 --- a/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java +++ b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java @@ -50,8 +50,8 @@ public class TransformedSplitMapTest extends BulkTest { final TransformedSplitMap<Integer, String, Object, Class<?>> map = TransformedSplitMap.transformingMap( new HashMap<String, Class<?>>(), intToString, objectToClass); - final Integer[] k = new Integer[] { 0, 1, 2, 3, 4, 5, 6 }; - final Object[] v = new Object[] { "", new Object(), new HashMap<>(), 0, BigInteger.TEN, null, + final Integer[] k = { 0, 1, 2, 3, 4, 5, 6 }; + final Object[] v = { "", new Object(), new HashMap<>(), 0, BigInteger.TEN, null, new Object[0] }; assertEquals(0, map.size()); diff --git a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java index 7fb131d..0596d6c 100755 --- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java +++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java @@ -61,7 +61,7 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> { public void testPrefixMap() { final PatriciaTrie<String> trie = new PatriciaTrie<>(); - final String[] keys = new String[]{ + final String[] keys = { "", "Albert", "Xavier", "XyZ", "Anna", "Alien", "Alberto", "Alberts", "Allie", "Alliese", "Alabama", "Banane", @@ -289,7 +289,7 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> { public void testPrefixMapRemoval() { final PatriciaTrie<String> trie = new PatriciaTrie<>(); - final String[] keys = new String[]{ + final String[] keys = { "Albert", "Xavier", "XyZ", "Anna", "Alien", "Alberto", "Alberts", "Allie", "Alliese", "Alabama", "Banane", "Blabla", "Amber", "Ammun", "Akka", "Akko", "Albertoo", @@ -338,15 +338,15 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> { assertEquals("测试", aTree.prefixMap("点").get("点评")); assertFalse(aTree.prefixMap("点").isEmpty()); assertEquals(1, aTree.prefixMap("点").size()); - assertEquals(1, aTree.prefixMap("点").keySet().size()); + assertEquals(1, aTree.prefixMap("点").size()); assertEquals(1, aTree.prefixMap("点").entrySet().size()); - assertEquals(1, aTree.prefixMap("点评").values().size()); + assertEquals(1, aTree.prefixMap("点评").size()); aTree.clear(); aTree.put("点评", "联盟"); aTree.put("点版", "定向"); - assertEquals(2, aTree.prefixMap("点").keySet().size()); - assertEquals(2, aTree.prefixMap("点").values().size()); + assertEquals(2, aTree.prefixMap("点").size()); + assertEquals(2, aTree.prefixMap("点").size()); } public void testPrefixMapSizes2() { @@ -384,8 +384,8 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> { prefixMap.clear(); assertTrue(prefixMap.isEmpty()); - assertTrue(prefixMap.keySet().isEmpty()); - assertTrue(prefixMap.values().isEmpty()); + assertTrue(prefixMap.isEmpty()); + assertTrue(prefixMap.isEmpty()); assertEquals(new HashSet<>(Arrays.asList("Anael", "Analu", "Anatole", "Anna")), trie.keySet()); assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList<>(trie.values())); } @@ -398,8 +398,8 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> { prefixMap.clear(); assertTrue(prefixMap.isEmpty()); - assertTrue(prefixMap.keySet().isEmpty()); - assertTrue(prefixMap.values().isEmpty()); + assertTrue(prefixMap.isEmpty()); + assertTrue(prefixMap.isEmpty()); assertEquals(new HashSet<String>(), trie.keySet()); assertEquals(new ArrayList<Integer>(0), new ArrayList<>(trie.values())); } @@ -421,8 +421,8 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> { for (final String key : keys) { prefixMap.remove(key); } - assertTrue(prefixMap.keySet().isEmpty()); - assertTrue(prefixMap.values().isEmpty()); + assertTrue(prefixMap.isEmpty()); + assertTrue(prefixMap.isEmpty()); assertEquals(new HashSet<>(Arrays.asList("Anael", "Analu", "Anatole", "Anna")), trie.keySet()); assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList<>(trie.values())); }