Completed
Push — master ( 0da034...d1285f )
by Muhammed
05:48
created

fromURL

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
1
package com.mmdemirbas.urlbuilder;
2
3
import org.junit.jupiter.api.Assertions;
4
import org.junit.jupiter.api.Test;
5
6
import java.net.URL;
7
8
import static com.mmdemirbas.urlbuilder.UrlBuilder.pair;
9
10
final class UrlBuilderJavaTest {
11
    private final String URL = "http://foo.com/with%20spaces/path/with/varArgs/&=%3F%2F;matrix=param%3F?fancy%20%2B%20name=fancy?%3Dvalue#%23?=";
12
13
    @Test
14
    void fromSchemeAndHost() {
15
        Assertions.assertEquals(URL,
16
                                UrlBuilder.from("http", "foo.com")
17
                                          .addPath("with spaces")
18
                                          .addPaths("path", "with", "varArgs")
19
                                          .addPath("&=?/", pair("matrix", "param?"))
20
                                          .setQuery(pair("fancy + name", "fancy?=value"))
21
                                          .setFragment("#?=")
22
                                          .toUrlString());
23
    }
24
25
    @Test
26
    void fromString() {
27
        Assertions.assertEquals(URL, UrlBuilder.from(URL).toUrlString());
28
    }
29
30
    @Test
31
    void fromURL() throws Exception {
32
        Assertions.assertEquals(URL, UrlBuilder.from(new URL(URL)).toUrlString());
33
    }
34
}
35