Use final.
This commit is contained in:
parent
eed8a7adb3
commit
b9e2a97758
|
@ -57,7 +57,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
/** MultiValuedHashMap created by reset(). */
|
||||
protected MultiValuedMap<K, V> confirmed;
|
||||
|
||||
public AbstractMultiValuedMapTest(String testName) {
|
||||
public AbstractMultiValuedMapTest(final String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
return map;
|
||||
}
|
||||
|
||||
protected void addSampleMappings(MultiValuedMap<? super K, ? super V> map) {
|
||||
protected void addSampleMappings(final MultiValuedMap<? super K, ? super V> 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<K, V> extends AbstractObjectTes
|
|||
return this.confirmed;
|
||||
}
|
||||
|
||||
public void setConfirmed(MultiValuedMap<K, V> map) {
|
||||
public void setConfirmed(final MultiValuedMap<K, V> map) {
|
||||
this.confirmed = map;
|
||||
}
|
||||
|
||||
|
@ -206,6 +206,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
public void testMultipleValues() {
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
@SuppressWarnings("unchecked")
|
||||
final
|
||||
Collection<V> col = map.get((K) "one");
|
||||
assertTrue(col.contains("uno"));
|
||||
assertTrue(col.contains("un"));
|
||||
|
@ -229,8 +230,8 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
}
|
||||
resetEmpty();
|
||||
final MultiValuedMap<K, V> map = getMap();
|
||||
Collection<V> col1 = map.get((K) "one");
|
||||
Collection<V> col2 = map.get((K) "one");
|
||||
final Collection<V> col1 = map.get((K) "one");
|
||||
final Collection<V> col2 = map.get((K) "one");
|
||||
assertTrue(col1.isEmpty());
|
||||
assertTrue(col2.isEmpty());
|
||||
assertEquals(0, map.size());
|
||||
|
@ -275,6 +276,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
resetFull();
|
||||
final MultiValuedMap<K, V> map = getMap();
|
||||
@SuppressWarnings("unchecked")
|
||||
final
|
||||
Iterator<V> it = map.get((K) "one").iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
@ -286,7 +288,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
assertFalse(map.containsValue("uno"));
|
||||
assertFalse(map.containsValue("un"));
|
||||
assertEquals(4, map.size());
|
||||
Collection<V> coll = map.remove("one");
|
||||
final Collection<V> coll = map.remove("one");
|
||||
assertNotNull(coll);
|
||||
assertEquals(0, coll.size());
|
||||
}
|
||||
|
@ -354,7 +356,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
return;
|
||||
}
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
Collection<V> values = map.values();
|
||||
final Collection<V> values = map.values();
|
||||
values.remove("uno");
|
||||
values.remove("un");
|
||||
assertFalse(map.containsKey("one"));
|
||||
|
@ -388,10 +390,10 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
|
||||
public void testEntriesCollectionIterator() {
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
Collection<V> values = new ArrayList<>(map.values());
|
||||
Iterator<Map.Entry<K, V>> iterator = map.entries().iterator();
|
||||
final Collection<V> values = new ArrayList<>(map.values());
|
||||
final Iterator<Map.Entry<K, V>> iterator = map.entries().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<K, V> entry = iterator.next();
|
||||
final Map.Entry<K, V> 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<K, V> 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<K, V> extends AbstractObjectTes
|
|||
}
|
||||
|
||||
public void testKeysMultiSet() {
|
||||
MultiValuedMap<K, V> map = makeFullMap();
|
||||
MultiSet<K> keyMultiSet = map.keys();
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
final MultiSet<K> 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<K, V> extends AbstractObjectTes
|
|||
}
|
||||
|
||||
public void testKeysBagIterator() {
|
||||
MultiValuedMap<K, V> map = makeFullMap();
|
||||
Collection<K> col = new ArrayList<>();
|
||||
Iterator<K> it = map.keys().iterator();
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
final Collection<K> col = new ArrayList<>();
|
||||
final Iterator<K> it = map.keys().iterator();
|
||||
while (it.hasNext()) {
|
||||
col.add(it.next());
|
||||
}
|
||||
Bag<K> bag = new HashBag<>(col);
|
||||
final Bag<K> 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<K, V> extends AbstractObjectTes
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testKeysBagContainsAll() {
|
||||
MultiValuedMap<K, V> map = makeFullMap();
|
||||
MultiSet<K> keyMultiSet = map.keys();
|
||||
Collection<K> col = (Collection<K>) Arrays.asList("one", "two", "three", "one", "two", "three");
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
final MultiSet<K> keyMultiSet = map.keys();
|
||||
final Collection<K> col = (Collection<K>) Arrays.asList("one", "two", "three", "one", "two", "three");
|
||||
assertTrue(keyMultiSet.containsAll(col));
|
||||
}
|
||||
|
||||
|
@ -676,7 +678,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
|
||||
resetFull();
|
||||
mapCol = getMap().asMap();
|
||||
Collection<V> col = mapCol.get("one");
|
||||
final Collection<V> col = mapCol.get("one");
|
||||
assertNotNull(col);
|
||||
assertTrue(col.contains("un"));
|
||||
assertTrue(col.contains("uno"));
|
||||
|
@ -687,7 +689,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
return;
|
||||
}
|
||||
resetFull();
|
||||
Map<K, Collection<V>> mapCol = getMap().asMap();
|
||||
final Map<K, Collection<V>> mapCol = getMap().asMap();
|
||||
mapCol.remove("one");
|
||||
assertFalse(getMap().containsKey("one"));
|
||||
assertEquals(4, getMap().size());
|
||||
|
@ -701,8 +703,8 @@ public abstract class AbstractMultiValuedMapTest<K, V> 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<K, V> extends AbstractObjectTes
|
|||
return;
|
||||
}
|
||||
resetFull();
|
||||
MapIterator<K, V> mapIt = getMap().mapIterator();
|
||||
final MapIterator<K, V> mapIt = getMap().mapIterator();
|
||||
while (mapIt.hasNext()) {
|
||||
mapIt.next();
|
||||
mapIt.remove();
|
||||
|
@ -723,12 +725,12 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
@SuppressWarnings("unchecked")
|
||||
public void testMapIteratorUnsupportedSet() {
|
||||
resetFull();
|
||||
MapIterator<K, V> mapIt = getMap().mapIterator();
|
||||
final MapIterator<K, V> 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<K, V> 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<K, V> 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<V>[] colArr = new Collection[3];
|
||||
final boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap;
|
||||
final V[] sampleValues = AbstractMultiValuedMapTest.this.getSampleValues();
|
||||
final Collection<V>[] colArr = new Collection[3];
|
||||
for(int i = 0; i < 3; i++) {
|
||||
Collection<V> coll = Arrays.asList(sampleValues[i*2], sampleValues[i*2 + 1]);
|
||||
final Collection<V> 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<K, V> extends AbstractObjectTes
|
|||
public Collection<V>[] 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<V>[] colArr = new Collection[3];
|
||||
final boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap;
|
||||
final Object[] sampleValues = { "ein", "ek", "zwei", "duey", "drei", "teen" };
|
||||
final Collection<V>[] colArr = new Collection[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Collection<V> coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]);
|
||||
final Collection<V> coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]);
|
||||
colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll;
|
||||
}
|
||||
return colArr;
|
||||
|
|
Loading…
Reference in New Issue