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 b57845960..4fb0a3807 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java @@ -57,7 +57,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes /** MultiValuedHashMap created by reset(). */ protected MultiValuedMap confirmed; - public AbstractMultiValuedMapTest(String testName) { + public AbstractMultiValuedMapTest(final String testName) { super(testName); } @@ -146,7 +146,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return map; } - protected void addSampleMappings(MultiValuedMap map) { + protected void addSampleMappings(final MultiValuedMap map) { final K[] keys = getSampleKeys(); final V[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { @@ -168,7 +168,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return this.confirmed; } - public void setConfirmed(MultiValuedMap map) { + public void setConfirmed(final MultiValuedMap map) { this.confirmed = map; } @@ -206,6 +206,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public void testMultipleValues() { final MultiValuedMap map = makeFullMap(); @SuppressWarnings("unchecked") + final Collection col = map.get((K) "one"); assertTrue(col.contains("uno")); assertTrue(col.contains("un")); @@ -229,8 +230,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes } resetEmpty(); final MultiValuedMap map = getMap(); - Collection col1 = map.get((K) "one"); - Collection col2 = map.get((K) "one"); + final Collection col1 = map.get((K) "one"); + final Collection col2 = map.get((K) "one"); assertTrue(col1.isEmpty()); assertTrue(col2.isEmpty()); assertEquals(0, map.size()); @@ -275,6 +276,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes resetFull(); final MultiValuedMap map = getMap(); @SuppressWarnings("unchecked") + final Iterator it = map.get((K) "one").iterator(); while (it.hasNext()) { it.next(); @@ -286,7 +288,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes assertFalse(map.containsValue("uno")); assertFalse(map.containsValue("un")); assertEquals(4, map.size()); - Collection coll = map.remove("one"); + final Collection coll = map.remove("one"); assertNotNull(coll); assertEquals(0, coll.size()); } @@ -354,7 +356,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return; } final MultiValuedMap map = makeFullMap(); - Collection values = map.values(); + final Collection values = map.values(); values.remove("uno"); values.remove("un"); assertFalse(map.containsKey("one")); @@ -388,10 +390,10 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public void testEntriesCollectionIterator() { final MultiValuedMap map = makeFullMap(); - Collection values = new ArrayList<>(map.values()); - Iterator> iterator = map.entries().iterator(); + final Collection values = new ArrayList<>(map.values()); + final Iterator> iterator = map.entries().iterator(); while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + final Map.Entry entry = iterator.next(); assertTrue(map.containsMapping(entry.getKey(), entry.getValue())); assertTrue(values.contains(entry.getValue())); if (isRemoveSupported()) { @@ -596,7 +598,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes try { map.putAll((K) "A", null); fail("expecting NullPointerException"); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { // expected } @@ -638,8 +640,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes } public void testKeysMultiSet() { - MultiValuedMap map = makeFullMap(); - MultiSet keyMultiSet = map.keys(); + final MultiValuedMap map = makeFullMap(); + final MultiSet keyMultiSet = map.keys(); assertEquals(2, keyMultiSet.getCount("one")); assertEquals(2, keyMultiSet.getCount("two")); assertEquals(2, keyMultiSet.getCount("three")); @@ -647,13 +649,13 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes } public void testKeysBagIterator() { - MultiValuedMap map = makeFullMap(); - Collection col = new ArrayList<>(); - Iterator it = map.keys().iterator(); + final MultiValuedMap map = makeFullMap(); + final Collection col = new ArrayList<>(); + final Iterator it = map.keys().iterator(); while (it.hasNext()) { col.add(it.next()); } - Bag bag = new HashBag<>(col); + final Bag bag = new HashBag<>(col); assertEquals(2, bag.getCount("one")); assertEquals(2, bag.getCount("two")); assertEquals(2, bag.getCount("three")); @@ -662,9 +664,9 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @SuppressWarnings("unchecked") public void testKeysBagContainsAll() { - MultiValuedMap map = makeFullMap(); - MultiSet keyMultiSet = map.keys(); - Collection col = (Collection) Arrays.asList("one", "two", "three", "one", "two", "three"); + final MultiValuedMap map = makeFullMap(); + final MultiSet keyMultiSet = map.keys(); + final Collection col = (Collection) Arrays.asList("one", "two", "three", "one", "two", "three"); assertTrue(keyMultiSet.containsAll(col)); } @@ -676,7 +678,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes resetFull(); mapCol = getMap().asMap(); - Collection col = mapCol.get("one"); + final Collection col = mapCol.get("one"); assertNotNull(col); assertTrue(col.contains("un")); assertTrue(col.contains("uno")); @@ -687,7 +689,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return; } resetFull(); - Map> mapCol = getMap().asMap(); + final Map> mapCol = getMap().asMap(); mapCol.remove("one"); assertFalse(getMap().containsKey("one")); assertEquals(4, getMap().size()); @@ -701,8 +703,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes resetFull(); mapIt = getMap().mapIterator(); while (mapIt.hasNext()) { - K key = mapIt.next(); - V value = mapIt.getValue(); + final K key = mapIt.next(); + final V value = mapIt.getValue(); assertTrue(getMap().containsMapping(key, value)); } } @@ -712,7 +714,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return; } resetFull(); - MapIterator mapIt = getMap().mapIterator(); + final MapIterator mapIt = getMap().mapIterator(); while (mapIt.hasNext()) { mapIt.next(); mapIt.remove(); @@ -723,12 +725,12 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @SuppressWarnings("unchecked") public void testMapIteratorUnsupportedSet() { resetFull(); - MapIterator mapIt = getMap().mapIterator(); + final MapIterator mapIt = getMap().mapIterator(); mapIt.next(); try { mapIt.setValue((V) "some value"); fail(); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { } } @@ -1075,8 +1077,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @Override @SuppressWarnings("unchecked") public K[] getSampleKeys() { - K[] samplekeys = AbstractMultiValuedMapTest.this.getSampleKeys(); - Object[] finalKeys = new Object[3]; + final K[] samplekeys = AbstractMultiValuedMapTest.this.getSampleKeys(); + final Object[] finalKeys = new Object[3]; for (int i = 0; i < 3; i++) { finalKeys[i] = samplekeys[i * 2]; } @@ -1089,11 +1091,11 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes // Calling getMap() instead of makeObject() would make more sense, but due to concurrency // issues, this may lead to intermittent issues. See COLLECTIONS-661. A better solution // would be to re-design the tests, or add a boolean method to the parent. - boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap; - V[] sampleValues = AbstractMultiValuedMapTest.this.getSampleValues(); - Collection[] colArr = new Collection[3]; + final boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap; + final V[] sampleValues = AbstractMultiValuedMapTest.this.getSampleValues(); + final Collection[] colArr = new Collection[3]; for(int i = 0; i < 3; i++) { - Collection coll = Arrays.asList(sampleValues[i*2], sampleValues[i*2 + 1]); + final Collection coll = Arrays.asList(sampleValues[i*2], sampleValues[i*2 + 1]); colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll; } return colArr; @@ -1104,11 +1106,11 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public Collection[] getNewSampleValues() { // See comment in getSampleValues() to understand why we are calling makeObject() and not // getMap(). See COLLECTIONS-661 for more. - boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap; - Object[] sampleValues = { "ein", "ek", "zwei", "duey", "drei", "teen" }; - Collection[] colArr = new Collection[3]; + final boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap; + final Object[] sampleValues = { "ein", "ek", "zwei", "duey", "drei", "teen" }; + final Collection[] colArr = new Collection[3]; for (int i = 0; i < 3; i++) { - Collection coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]); + final Collection coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]); colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll; } return colArr;