URIUtilsTest.java
1.29 KB
package pl.itcrowd.youtrack.api.rest;
import org.junit.Test;
import pl.itcrowd.youtrack.api.Filter;
import pl.itcrowd.youtrack.api.URIUtils;
import pl.itcrowd.youtrack.api.defaults.StateValues;
import java.net.URI;
import java.net.URISyntaxException;
import static org.junit.Assert.assertEquals;
public class URIUtilsTest {
@Test
public void buildURI() throws URISyntaxException
{
// Given
final URI baseA = new URI("http://localhost:8080/youtrack/");
final URI baseB = new URI("http://localhost/youtrack/");
final String pathA = "/rest/admin/bundle/QA note types";
final String queryA = "q=" + Filter.stateFilter(StateValues.NotWontFix).maxResults(20);
// When
final URI uriA = URIUtils.buildURI(baseA, pathA);
final URI uriB = URIUtils.buildURI(baseA, pathA, queryA);
final URI uriC = URIUtils.buildURI(baseB, pathA, queryA);
// Then
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());
}
}