1   /*
2    * Copyright (C) 2010 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.jira.rest.client;
18  
19  import com.atlassian.jira.rest.client.domain.BasicUser;
20  import com.atlassian.jira.webtests.util.LocalTestEnvironmentData;
21  
22  import javax.ws.rs.core.UriBuilder;
23  import java.net.URI;
24  import java.net.URISyntaxException;
25  
26  public class IntegrationTestUtil {
27  	public static final BasicUser USER_ADMIN;
28      public static final BasicUser USER1;
29      public static final BasicUser USER2;
30  	public static final BasicUser USER_SLASH;
31  
32  	public static final int START_PROGRESS_TRANSITION_ID = 4;
33  	public static final int STOP_PROGRESS_TRANSITION_ID = 301;
34  	public static final String NUMERIC_CUSTOMFIELD_ID = "customfield_10000";
35  	public static final String NUMERIC_CUSTOMFIELD_TYPE = "com.atlassian.jira.plugin.system.customfieldtypes:float";
36  	private static final LocalTestEnvironmentData environmentData = new LocalTestEnvironmentData();
37  
38  
39  	static {
40          try {
41              USER1 = new BasicUser(getUserUri("wseliga"), "wseliga", "Wojciech Seliga");
42              USER2 = new BasicUser(getUserUri("user"), "user", "My Test User");
43  			USER_SLASH = new BasicUser(getUserUri("a/user/with/slash"), "a/user/with/slash", "A User with / in its username");
44              USER_ADMIN = new BasicUser(getUserUri("admin"), "admin", "Administrator");
45          } catch (URISyntaxException e) {
46              throw new RuntimeException(e);
47          }
48  
49      }
50  
51  	private static URI getUserUri(String username) throws URISyntaxException {
52  		return UriBuilder.fromUri(environmentData.getBaseUrl().toURI()).path("/rest/api/latest/user").queryParam("username", username).build();
53  	}
54  
55      public static URI concat(URI uri, String path) {
56          return UriBuilder.fromUri(uri).path(path).build();
57      }
58  
59  }