Skip to content

Commit

Permalink
Add AbstractMapTest.testMapComputeIfAbsent()
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Sep 25, 2024
1 parent c96dc7a commit 786ab23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4.map;

import static org.apache.commons.collections4.map.LazyMap.lazyMap;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
Expand Down Expand Up @@ -50,9 +49,14 @@ public String getCompatibilityVersion() {
return "4";
}

@Override
protected boolean isLazyMapTest() {
return true;
}

@Override
public LazyMap<K, V> makeObject() {
return lazyMap(new HashMap<>(), FactoryUtils.<V>nullFactory());
return LazyMap.lazyMap(new HashMap<>(), FactoryUtils.<V>nullFactory());
}

@Test
Expand All @@ -63,7 +67,7 @@ public void testMapGet() {

@Test
public void testMapGetWithFactory() {
Map<Integer, Number> map = lazyMap(new HashMap<>(), oneFactory);
Map<Integer, Number> map = LazyMap.lazyMap(new HashMap<>(), oneFactory);
assertEquals(0, map.size());
final Number i1 = map.get("Five");
assertEquals(1, i1);
Expand All @@ -73,7 +77,7 @@ public void testMapGetWithFactory() {
assertEquals(1, map.size());
assertSame(i1, i2);

map = lazyMap(new HashMap<>(), FactoryUtils.<Long>nullFactory());
map = LazyMap.lazyMap(new HashMap<>(), FactoryUtils.<Long>nullFactory());
final Object o = map.get("Five");
assertNull(o);
assertEquals(1, map.size());
Expand All @@ -82,7 +86,7 @@ public void testMapGetWithFactory() {
@Test
public void testMapGetWithTransformer() {
final Transformer<Number, Integer> intConverter = Number::intValue;
final Map<Long, Number> map = lazyMap(new HashMap<>(), intConverter);
final Map<Long, Number> map = LazyMap.lazyMap(new HashMap<>(), intConverter);
assertEquals(0, map.size());
final Number i1 = map.get(123L);
assertEquals(123, i1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public boolean isAllowNullKey() {
return false;
}

@Override
protected boolean isLazyMapTest() {
return true;
}

@Override
public SortedMap<K, V> makeObject() {
return lazySortedMap(new TreeMap<>(), FactoryUtils.<V>nullFactory());
Expand Down

0 comments on commit 786ab23

Please sign in to comment.