Blame view

src/test/java/pl/itcrowd/youtrack/api/rest/URIUtilsTest.java 1.29 KB
bernard authored
1
package pl.itcrowd.youtrack.api.rest;
bernard authored
2 3

import org.junit.Test;
bernard authored
4 5 6
import pl.itcrowd.youtrack.api.Filter;
import pl.itcrowd.youtrack.api.URIUtils;
import pl.itcrowd.youtrack.api.defaults.StateValues;
bernard authored
7 8 9 10 11 12 13 14

import java.net.URI;
import java.net.URISyntaxException;

import static org.junit.Assert.assertEquals;

public class URIUtilsTest {
bernard authored
15 16 17
    @Test
    public void buildURI() throws URISyntaxException
    {
bernard authored
18
//      Given
bernard authored
19 20
        final URI baseA = new URI("http://localhost:8080/youtrack/");
        final URI baseB = new URI("http://localhost/youtrack/");
bernard authored
21 22
        final String pathA = "/rest/admin/bundle/QA note types";
        final String queryA = "q=" + Filter.stateFilter(StateValues.NotWontFix).maxResults(20);
bernard authored
23 24

//      When
bernard authored
25 26 27
        final URI uriA = URIUtils.buildURI(baseA, pathA);
        final URI uriB = URIUtils.buildURI(baseA, pathA, queryA);
        final URI uriC = URIUtils.buildURI(baseB, pathA, queryA);
bernard authored
28 29

//      Then
bernard authored
30 31 32
        assertEquals("http://localhost:8080/youtrack/rest/admin/bundle/QA%20note%20types", uriA.toString());
        assertEquals("http://localhost:8080/youtrack/rest/admin/bundle/QA%20note%20types?q=state:-%7BWon't%20fix%7D&max=20", uriB.toString());
        assertEquals("http://localhost/youtrack/rest/admin/bundle/QA%20note%20types?q=state:-%7BWon't%20fix%7D&max=20", uriC.toString());
bernard authored
33
    }
bernard authored
34
}