BAEL-2480 Java Map to String conversion (#6075)

* BAEL-2480 Java Map to String conversion

* BAEL-2480 Java Map to String conversion

* BAEL-2480 Java Map to String conversion

* BAEL-2480 Java Map to String conversion
This commit is contained in:
Laurentiu Delcea
2019-01-10 23:21:06 +02:00
committed by maibin
parent 9e71023f98
commit b8dbc9d053
4 changed files with 126 additions and 0 deletions
@@ -0,0 +1,23 @@
package com.baeldung.convert;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import java.util.Map;
public class StringToMapUnitTest {
@Test
public void givenString_WhenUsingStream_ThenResultingStringIsCorrect() {
Map<String, String> wordsByKey = StringToMap.convertWithStream("1=one,2=two,3=three,4=four");
Assert.assertEquals(4, wordsByKey.size());
Assert.assertEquals("one", wordsByKey.get("1"));
}
@Test
void givenString_WhenUsingGuava_ThenResultingStringIsCorrect() {
Map<String, String> wordsByKey = StringToMap.convertWithGuava("1=one,2=two,3=three,4=four");
Assert.assertEquals(4, wordsByKey.size());
Assert.assertEquals("one", wordsByKey.get("1"));
}
}