Blame view

src/test/java/pl/itcrowd/youtrack/api/rest/URIUtilsTest.java 1.36 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 15

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

import static org.junit.Assert.assertEquals;

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

//      When
bernard authored
26 27 28
        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
29 30

//      Then
bernard authored
31 32 33
        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
34
    }
bernard authored
35
}