add test for updating a value
This commit is contained in:
@@ -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<String, String> 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<String> 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");
|
||||
|
||||
Reference in New Issue
Block a user