|
@@ -28,32 +28,20 @@ import java.util.List;
|
28
|
28
|
import java.util.Map;
|
29
|
29
|
import java.util.stream.Collectors;
|
30
|
30
|
|
31
|
|
-import org.junit.Before;
|
32
|
31
|
import org.junit.Test;
|
33
|
|
-import org.junit.runner.RunWith;
|
34
|
|
-import org.mockito.runners.MockitoJUnitRunner;
|
35
|
32
|
|
36
|
33
|
import static junit.framework.TestCase.assertEquals;
|
37
|
34
|
|
38
|
|
-@RunWith(MockitoJUnitRunner.class)
|
39
|
|
-public class URLEncodingMapFlattenerTest {
|
|
35
|
+public class CollectionFunctionsTest {
|
40
|
36
|
|
41
|
|
- private URLEncodingMapFlattener instance;
|
42
|
|
- private Map<String, String> map;
|
43
|
|
-
|
44
|
|
- @Before
|
45
|
|
- public void setUp() throws Exception {
|
46
|
|
- instance = new URLEncodingMapFlattener();
|
47
|
|
- map = ImmutableMap.<String, String>builder()
|
|
37
|
+ @Test
|
|
38
|
+ public void testflattenAndEncodeKeyPair() throws Exception {
|
|
39
|
+ final Map<String, String> map = ImmutableMap.<String, String>builder()
|
48
|
40
|
.put("key", "value")
|
49
|
41
|
.put("key&", "value&")
|
50
|
42
|
.build();
|
51
|
|
- }
|
52
|
|
-
|
53
|
|
- @Test
|
54
|
|
- public void testApply() throws Exception {
|
55
|
43
|
final List<String> result = map.entrySet().stream()
|
56
|
|
- .flatMap(instance)
|
|
44
|
+ .flatMap(CollectionFunctions::flattenAndEncodeKeyPair)
|
57
|
45
|
.collect(Collectors.toList());
|
58
|
46
|
assertEquals(2, result.size());
|
59
|
47
|
assertEquals("key=value", result.get(0));
|