Merge branch 'mikhail.golubev/configurable-issues-states'
[idea/community.git] / plugins / tasks / tasks-tests / test / com / intellij / tasks / integration / SprintlyIntegrationTest.java
1 package com.intellij.tasks.integration;
2
3 import com.intellij.tasks.Task;
4 import com.intellij.tasks.TaskTestUtil;
5 import com.intellij.tasks.generic.GenericRepository;
6 import com.intellij.tasks.generic.GenericRepositoryType;
7 import org.jetbrains.annotations.NotNull;
8
9 import static com.intellij.tasks.TaskTestUtil.TaskBuilder;
10 import static com.intellij.tasks.TaskTestUtil.assertTasksEqual;
11
12 /**
13  * @author Mikhail Golubev
14  */
15 public class SprintlyIntegrationTest extends GenericSubtypeTestCase {
16   private static final String TASK_LIST_RESPONSE = "[\n" +
17                                                    "   {\n" +
18                                                    "      \"number\" : 1,\n" +
19                                                    "      \"progress\" : {\n" +
20                                                    "         \"started_at\" : \"2013-09-03T16:12:51+00:00\",\n" +
21                                                    "         \"triaged_at\" : \"2013-09-03T16:12:35+00:00\"\n" +
22                                                    "      },\n" +
23                                                    "      \"status\" : \"in-progress\",\n" +
24                                                    "      \"last_modified\" : \"2013-09-03T16:12:51+00:00\",\n" +
25                                                    "      \"score\" : \"~\",\n" +
26                                                    "      \"description\" : \"These SEGFAULTs oppress me\",\n" +
27                                                    "      \"tags\" : [\n" +
28                                                    "         \"bar\",\n" +
29                                                    "         \"tag\",\n" +
30                                                    "         \"foo\"\n" +
31                                                    "      ],\n" +
32                                                    "      \"email\" : {\n" +
33                                                    "         \"files\" : \"files-505027@items.sprint.ly\",\n" +
34                                                    "         \"discussion\" : \"discussion-505027@items.sprint.ly\"\n" +
35                                                    "      },\n" +
36                                                    "      \"created_at\" : \"2013-09-03T16:10:43+00:00\",\n" +
37                                                    "      \"assigned_to\" : {\n" +
38                                                    "         \"last_login\" : \"2013-09-03T16:02:32+00:00\",\n" +
39                                                    "         \"email\" : \"qsolo825@gmail.com\",\n" +
40                                                    "         \"created_at\" : \"2013-09-03T16:02:30+00:00\",\n" +
41                                                    "         \"id\" : 17259,\n" +
42                                                    "         \"last_name\" : \"Golubev\",\n" +
43                                                    "         \"first_name\" : \"Mikhail\"\n" +
44                                                    "      },\n" +
45                                                    "      \"type\" : \"defect\",\n" +
46                                                    "      \"product\" : {\n" +
47                                                    "         \"name\" : \"My Enormous Project\",\n" +
48                                                    "         \"id\" : 14182,\n" +
49                                                    "         \"archived\" : false\n" +
50                                                    "      },\n" +
51                                                    "      \"title\" : \"Nasty Bug!\",\n" +
52                                                    "      \"short_url\" : \"http://sprint.ly/i/14182/1/\",\n" +
53                                                    "      \"created_by\" : {\n" +
54                                                    "         \"last_login\" : \"2013-09-03T16:02:32+00:00\",\n" +
55                                                    "         \"email\" : \"qsolo825@gmail.com\",\n" +
56                                                    "         \"created_at\" : \"2013-09-03T16:02:30+00:00\",\n" +
57                                                    "         \"id\" : 17259,\n" +
58                                                    "         \"last_name\" : \"Golubev\",\n" +
59                                                    "         \"first_name\" : \"Mikhail\"\n" +
60                                                    "      }\n" +
61                                                    "   },\n" +
62                                                    "   {\n" +
63                                                    "      \"number\" : 2,\n" +
64                                                    "      \"progress\" : {\n" +
65                                                    "         \"triaged_at\" : \"2013-09-03T16:14:08+00:00\"\n" +
66                                                    "      },\n" +
67                                                    "      \"status\" : \"backlog\",\n" +
68                                                    "      \"last_modified\" : \"2013-09-04T10:18:02+00:00\",\n" +
69                                                    "      \"score\" : \"~\",\n" +
70                                                    "      \"description\" : \"Finish Sprint.ly connector\",\n" +
71                                                    "      \"tags\" : [\n" +
72                                                    "         \"foo\"\n" +
73                                                    "      ],\n" +
74                                                    "      \"email\" : {\n" +
75                                                    "         \"files\" : \"files-505035@items.sprint.ly\",\n" +
76                                                    "         \"discussion\" : \"discussion-505035@items.sprint.ly\"\n" +
77                                                    "      },\n" +
78                                                    "      \"created_at\" : \"2013-09-03T16:13:54+00:00\",\n" +
79                                                    "      \"assigned_to\" : {\n" +
80                                                    "         \"last_login\" : \"2013-09-03T16:02:32+00:00\",\n" +
81                                                    "         \"email\" : \"qsolo825@gmail.com\",\n" +
82                                                    "         \"created_at\" : \"2013-09-03T16:02:30+00:00\",\n" +
83                                                    "         \"id\" : 17259,\n" +
84                                                    "         \"last_name\" : \"Golubev\",\n" +
85                                                    "         \"first_name\" : \"Mikhail\"\n" +
86                                                    "      },\n" +
87                                                    "      \"type\" : \"task\",\n" +
88                                                    "      \"product\" : {\n" +
89                                                    "         \"name\" : \"My Enormous Project\",\n" +
90                                                    "         \"id\" : 14182,\n" +
91                                                    "         \"archived\" : false\n" +
92                                                    "      },\n" +
93                                                    "      \"title\" : \"Some task\",\n" +
94                                                    "      \"short_url\" : \"http://sprint.ly/i/14182/2/\",\n" +
95                                                    "      \"created_by\" : {\n" +
96                                                    "         \"last_login\" : \"2013-09-03T16:02:32+00:00\",\n" +
97                                                    "         \"email\" : \"qsolo825@gmail.com\",\n" +
98                                                    "         \"created_at\" : \"2013-09-03T16:02:30+00:00\",\n" +
99                                                    "         \"id\" : 17259,\n" +
100                                                    "         \"last_name\" : \"Golubev\",\n" +
101                                                    "         \"first_name\" : \"Mikhail\"\n" +
102                                                    "      }\n" +
103                                                    "   }\n" +
104                                                    "]\n";
105
106   public static final String SINGLE_TASK_RESPONSE = "{\n" +
107                                                     "   \"number\" : 1,\n" +
108                                                     "   \"progress\" : {\n" +
109                                                     "      \"started_at\" : \"2013-09-03T16:12:51+00:00\",\n" +
110                                                     "      \"triaged_at\" : \"2013-09-03T16:12:35+00:00\"\n" +
111                                                     "   },\n" +
112                                                     "   \"status\" : \"in-progress\",\n" +
113                                                     "   \"last_modified\" : \"2013-09-04T13:53:14+00:00\",\n" +
114                                                     "   \"score\" : \"~\",\n" +
115                                                     "   \"description\" : \"This is this horrible bug's description\",\n" +
116                                                     "   \"tags\" : [\n" +
117                                                     "      \"bar\",\n" +
118                                                     "      \"tag\",\n" +
119                                                     "      \"foo\"\n" +
120                                                     "   ],\n" +
121                                                     "   \"email\" : {\n" +
122                                                     "      \"files\" : \"files-505027@items.sprint.ly\",\n" +
123                                                     "      \"discussion\" : \"discussion-505027@items.sprint.ly\"\n" +
124                                                     "   },\n" +
125                                                     "   \"created_at\" : \"2013-09-03T16:10:43+00:00\",\n" +
126                                                     "   \"assigned_to\" : {\n" +
127                                                     "      \"last_login\" : \"2013-09-03T16:02:32+00:00\",\n" +
128                                                     "      \"email\" : \"qsolo825@gmail.com\",\n" +
129                                                     "      \"created_at\" : \"2013-09-03T16:02:30+00:00\",\n" +
130                                                     "      \"id\" : 17259,\n" +
131                                                     "      \"last_name\" : \"Golubev\",\n" +
132                                                     "      \"first_name\" : \"Mikhail\"\n" +
133                                                     "   },\n" +
134                                                     "   \"type\" : \"defect\",\n" +
135                                                     "   \"product\" : {\n" +
136                                                     "      \"name\" : \"My Enormous Project\",\n" +
137                                                     "      \"id\" : 14182,\n" +
138                                                     "      \"archived\" : false\n" +
139                                                     "   },\n" +
140                                                     "   \"title\" : \"Nasty Bug!\",\n" +
141                                                     "   \"short_url\" : \"http://sprint.ly/i/14182/1/\",\n" +
142                                                     "   \"created_by\" : {\n" +
143                                                     "      \"last_login\" : \"2013-09-03T16:02:32+00:00\",\n" +
144                                                     "      \"email\" : \"qsolo825@gmail.com\",\n" +
145                                                     "      \"created_at\" : \"2013-09-03T16:02:30+00:00\",\n" +
146                                                     "      \"id\" : 17259,\n" +
147                                                     "      \"last_name\" : \"Golubev\",\n" +
148                                                     "      \"first_name\" : \"Mikhail\"\n" +
149                                                     "   }\n" +
150                                                     "}\n";
151
152   public void testParsingTaskList() throws Exception {
153     Task[] tasks = myRepository.getActiveResponseHandler().parseIssues(TASK_LIST_RESPONSE, 50);
154     assertTasksEqual(new Task[]{
155       new TaskBuilder("1", "Nasty Bug!", myRepository)
156         .withDescription("These SEGFAULTs oppress me")
157         .withIssueUrl("http://sprint.ly/i/14182/1/")
158         .withUpdated("2013-09-03 16:12:51")
159         .withCreated("2013-09-03 16:10:43"),
160       new TaskBuilder("2", "Some task", myRepository)
161         .withDescription("Finish Sprint.ly connector")
162         .withIssueUrl("http://sprint.ly/i/14182/2/")
163         .withUpdated("2013-09-04 10:18:02")
164         .withCreated("2013-09-03 16:13:54")
165     }, tasks);
166   }
167
168   public void testParsingSingleTask() throws Exception {
169     Task task = myRepository.getActiveResponseHandler().parseIssue(SINGLE_TASK_RESPONSE);
170     assertTasksEqual(
171       new TaskBuilder("1", "Nasty Bug!", myRepository)
172         .withDescription("This is this horrible bug's description")
173         .withIssueUrl("http://sprint.ly/i/14182/1/")
174         .withUpdated("2013-09-04 13:53:14")
175         .withCreated("2013-09-03 16:10:43"),
176       task);
177   }
178
179   @NotNull
180   @Override
181   protected GenericRepository createRepository(GenericRepositoryType genericType) {
182     return (GenericRepository)genericType.new SprintlyRepository().createRepository();
183   }
184 }