View Javadoc

1   /*
2    * Copyright (C) 2012 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.internal.json;
18  
19  import com.atlassian.jira.rest.client.TestUtil;
20  import com.atlassian.jira.rest.client.api.domain.BasicComponent;
21  import com.atlassian.jira.rest.client.api.domain.BasicUser;
22  import com.atlassian.jira.rest.client.api.domain.User;
23  import com.atlassian.jira.rest.client.api.domain.Version;
24  import com.google.common.collect.ImmutableMap;
25  
26  import java.net.URI;
27  
28  import static com.atlassian.jira.rest.client.TestUtil.toUri;
29  
30  /**
31   * Constants used in various unit tests.
32   * All constants including full URIs are usually useless in integration tests though, as during integration
33   * tests we may be testing against a JIRA running on a different port and with a different web context
34   *
35   * @since v0.1
36   */
37  public class TestConstants {
38      public static final String USER1_USERNAME = "wseliga";
39  
40      public static final String USER1_PASSWORD = "wseliga";
41  
42      public static final String ADMIN_USERNAME = "admin";
43  
44      public static final String ADMIN_PASSWORD = "admin";
45  
46      // USER1_BASIC_DEPRECATED is deprecated - all tests that use this constant should be reviewed (JIRA now returns more info than we test)
47      public static final BasicUser USER1_BASIC_DEPRECATED = new BasicUser(toUri("http://localhost:8090/jira/rest/api/latest/user?username=wseliga"), USER1_USERNAME, "Wojciech Seliga");
48      public static final BasicUser USER1_BASIC = new BasicUser(toUri("http://localhost:8090/jira/rest/api/2/user?username=wseliga"), USER1_USERNAME, "Wojciech Seliga");
49      public static final User USER1 = new User(toUri("http://localhost:8090/jira/rest/api/2/user?username=wseliga"), USER1_USERNAME,
50              "Wojciech Seliga", "wojciech.seliga@spartez.com", null, ImmutableMap.of(
51              "16x16", URI.create("http://localhost:8090/jira/secure/useravatar?size=small&avatarId=10082"),
52              "48x48", URI.create("http://localhost:8090/jira/secure/useravatar?avatarId=10082")), null);
53  
54      // USER_ADMIN_DEPRECATED this is deprecated - all tests that use this constant should be reviewed (JIRA now returns more info than we test)
55      public static final BasicUser USER_ADMIN_BASIC_DEPRECATED = new BasicUser(toUri("http://localhost:8090/jira/rest/api/latest/user?username=admin"), ADMIN_USERNAME, "Administrator");
56      public static final BasicUser USER_ADMIN_BASIC = new BasicUser(toUri("http://localhost:8090/jira/rest/api/2/user?username=admin"), ADMIN_USERNAME, "Administrator");
57      public static final BasicUser USER_ADMIN_BASIC_LATEST = new BasicUser(toUri("http://localhost:8090/jira/rest/api/latest/user?username=admin"), ADMIN_USERNAME, "Administrator");
58      public static final User USER_ADMIN = new User(toUri("http://localhost:8090/jira/rest/api/2/user?username=admin"), ADMIN_USERNAME, "Administrator",
59              "wojciech.seliga@spartez.com", null, ImmutableMap.of(
60              "16x16", URI.create("http://localhost:8090/jira/secure/useravatar?size=small&ownerId=admin&avatarId=10054"),
61              "48x48", URI.create("http://localhost:8090/jira/secure/useravatar?ownerId=admin&avatarId=10054")), null);
62  
63      public static final String USER2_USERNAME = "user";
64  
65      public static final String USER2_PASSWORD = "user";
66  
67      @SuppressWarnings("UnusedDeclaration")
68      public static final BasicUser USER2 = new BasicUser(toUri("http://localhost:8090/jira/rest/api/latest/user?username=user"), USER2_USERNAME, "My Test User");
69  
70      public static final Version VERSION_1 = new Version(toUri("http://localhost:8090/jira/rest/api/latest/version/10001"),
71              10001L, "1", "initial version", false, false, null);
72  
73      public static final Version VERSION_1_1 = new Version(toUri("http://localhost:8090/jira/rest/api/latest/version/10000"),
74              10000L, "1.1", "Some version", true, false, TestUtil.toDateTime("2010-08-25T00:00:00.000+0200"));
75  
76      public static final BasicComponent BCOMPONENT_A = new BasicComponent(toUri("http://localhost:8090/jira/rest/api/latest/component/10000"),
77              10000L, "Component A", "this is some description of component A");
78  
79      public static final BasicComponent BCOMPONENT_B = new BasicComponent(toUri("http://localhost:8090/jira/rest/api/latest/component/10001"),
80              10001L, "Component B", "another description");
81  
82      public static final String DEFAULT_JIRA_DUMP_FILE = "jira-dump.xml";
83      public static final String DATA_FOR_UNIT_TESTS_FILE = "data-for-unit-tests.xml";
84      public static final String EXPORT_FOR_HISTORY_TESTS_FILE = "export-for-history-tests.xml";
85      public static final String JIRA_DUMP_CREATING_ISSUE_TESTS_FILE = "jira-dump-creating-issue-tests.xml";
86      public static final String JIRA_DUMP_UNASSIGNED_FILE = "jira-dump-unassigned.xml";
87      public static final String JIRA_DUMP_WITH_COMMENT_AND_WORKLOG_FROM_REMOVED_USER_FILE = "jira-dump-with-comment-and-worklog-from-removed-user.xml";
88      public static final String JIRA_DUMP_WITH_FILTERS_FILE = "jira-dump-with-filters.xml";
89  }