bernard
authored
2013-04-04 13:08:24 +0000
1
package pl . itcrowd . youtrack . api . rest ;
bernard
authored
2012-11-05 09:56:36 +0000
2
3
import org.junit.Test ;
bernard
authored
2013-04-04 13:08:24 +0000
4
5
6
import pl.itcrowd.youtrack.api.Filter ;
import pl.itcrowd.youtrack.api.URIUtils ;
import pl.itcrowd.youtrack.api.defaults.StateValues ;
bernard
authored
2012-11-05 09:56:36 +0000
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
2012-11-05 12:23:53 +0000
16
17
18
@Test
public void buildURI () throws URISyntaxException
{
bernard
authored
2012-11-05 09:56:36 +0000
19
// Given
bernard
authored
2012-11-21 12:08:03 +0000
20
21
final URI baseA = new URI ( "http://localhost:8080/youtrack/" );
final URI baseB = new URI ( "http://localhost/youtrack/" );
bernard
authored
2012-11-05 12:23:53 +0000
22
23
final String pathA = "/rest/admin/bundle/QA note types" ;
final String queryA = "q=" + Filter . stateFilter ( StateValues . NotWontFix ). maxResults ( 20 );
bernard
authored
2012-11-05 09:56:36 +0000
24
25
// When
bernard
authored
2012-11-21 12:08:03 +0000
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
2012-11-05 09:56:36 +0000
29
30
// Then
bernard
authored
2012-11-21 12:08:03 +0000
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
2012-11-05 12:23:53 +0000
34
}
bernard
authored
2012-11-05 09:56:36 +0000
35
}