Files
spring-boot-rest/libraries-2/src/test/java/com/baeldung/mapdb/HTreeMapUnitTest.java
Sam Millington 7c4019e384 [BAEL-2959] A Guide to MapDB code (#7042)
* [BAEL-2959] A Guide to MapDB code

* [BAEL-2959] fixes

* [BAEL-2959] made VOLUME_LOCATION static in SortedTableMapUnitTest

* moved mapdb files from libraries to libraries-2

* [BAEL-2959] formatting fixes

* updated pom.xml
2019-07-02 21:01:30 +01:00

39 lines
881 B
Java

package com.baeldung.mapdb;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.mapdb.*;
import java.io.IOException;
import static junit.framework.Assert.assertEquals;
public class HTreeMapUnitTest {
@Test
public void givenValidDB_whenHTreeMapAddedToAndRetrieved_CheckedRetrievalCorrect() {
DB db = DBMaker.memoryDB().make();
HTreeMap<String, String> hTreeMap = db
.hashMap("myTreMap")
.keySerializer(Serializer.STRING)
.valueSerializer(Serializer.STRING)
.create();
hTreeMap.put("key1", "value1");
hTreeMap.put("key2", "value2");
assertEquals(2, hTreeMap.size());
//add another value with the same key
hTreeMap.put("key1", "value3");
assertEquals(2, hTreeMap.size());
assertEquals("value3", hTreeMap.get("key1"));
}
}