diff --git a/block-storage/src/test/java/org/lucares/pdb/map/PersistentMapTest.java b/block-storage/src/test/java/org/lucares/pdb/map/PersistentMapTest.java index 0e761a9..23e216e 100644 --- a/block-storage/src/test/java/org/lucares/pdb/map/PersistentMapTest.java +++ b/block-storage/src/test/java/org/lucares/pdb/map/PersistentMapTest.java @@ -4,10 +4,12 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.security.SecureRandom; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Queue; @@ -57,6 +59,26 @@ public class PersistentMapTest { } } + @Test + public void testUpdateValues() throws Exception { + final Path file = dataDirectory.resolve("map.db"); + try (final PersistentMap map = new PersistentMap<>(file, dataDirectory, + PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) { + map.putValue("key", "first"); + + Assertions.assertEquals("first", map.getValue("key")); + + map.putValue("key", "second"); + Assertions.assertEquals("second", map.getValue("key")); + + final List allValuesInMap = new ArrayList<>(); + map.forAll((k, v) -> { + allValuesInMap.add(v); + }); + Assertions.assertEquals(List.of("second"), allValuesInMap); + } + } + @Test public void testManyValues() throws Exception { final Path file = dataDirectory.resolve("map.db");