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

com.mmdemirbas.urlbuilder.UrlBuilderJavaTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
dl 0
loc 23
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 3 1
A fromSchemeAndHost() 0 10 1
fromURL 0 3 ?
A fromURL() 0 3 1
fromSchemeAndHost 0 10 ?
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