1414import java .util .Arrays ;
1515import java .util .HashMap ;
1616import java .util .Map ;
17- import java .util .stream .Collectors ;
1817
19- import static java .util .stream .Collectors .collectingAndThen ;
2018import static java .util .stream .Collectors .joining ;
2119
2220public class EncoderDecoderTest {
@@ -62,8 +60,8 @@ public void givenRequestParam_whenUTF8Scheme_thenEncode() throws Exception {
6260 requestParams .put ("key3" , "value%3" );
6361
6462 String encodedURL = requestParams .keySet ().stream ()
65- .map (key -> key + "=" + encodeValue (requestParams .get (key )))
66- .collect (collectingAndThen ( joining ("&" ), params -> "http://www.baeldung.com?" + params ));
63+ .map (key -> key + "=" + encodeValue (requestParams .get (key )))
64+ .collect (joining ("&" , "http://www.baeldung.com?" , "" ));
6765
6866 Assert .assertThat (testUrl , CoreMatchers .is (encodedURL ));
6967 }
@@ -75,11 +73,11 @@ public void givenRequestParam_whenUTF8Scheme_thenDecodeRequestParams() throws Ex
7573 String query = url .getQuery ();
7674
7775 String decodedQuery = Arrays .stream (query .split ("&" ))
78- .map (param -> param .split ("=" )[0 ] + "=" + decode (param .split ("=" )[1 ]))
79- .collect (joining ("&" ));
76+ .map (param -> param .split ("=" )[0 ] + "=" + decode (param .split ("=" )[1 ]))
77+ .collect (joining ("&" ));
8078
8179 Assert .assertEquals (
82- "http://www.baeldung.com?key1=value 1&key2=value@!$2&key3=value%3" , url .getProtocol () + "://" + url .getHost () + "?" + decodedQuery );
80+ "http://www.baeldung.com?key1=value 1&key2=value@!$2&key3=value%3" , url .getProtocol () + "://" + url .getHost () + "?" + decodedQuery );
8381 }
8482
8583}
0 commit comments