aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueParserTest.java
blob: 003bd527a60035eb95b098393be703a87b6da1e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * SonarQube, open source software quality management tool.
 * Copyright (C) 2008-2013 SonarSource
 * mailto:contact AT sonarsource DOT com
 *
 * SonarQube is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * SonarQube is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.sonar.wsclient.issue;

import org.apache.commons.io.IOUtils;
import org.junit.Test;

import java.util.List;

import static org.fest.assertions.Assertions.assertThat;

public class IssueParserTest {
  @Test
  public void test_GET_search() throws Exception {
    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/search.json"));
    Issues issues = new IssueParser().parseIssues(json);
    assertThat(issues).isNotNull();
    List<Issue> list = issues.list();
    assertThat(list).hasSize(2);
    Issue first = list.get(0);
    assertThat(first.key()).isEqualTo("ABCDE");
    assertThat(first.componentKey()).isEqualTo("Action.java");
    assertThat(first.ruleKey()).isEqualTo("squid:AvoidCycle");
    assertThat(first.severity()).isEqualTo("CRITICAL");
    assertThat(first.line()).isEqualTo(10);
    assertThat(first.resolution()).isEqualTo("FIXED");
    assertThat(first.status()).isEqualTo("OPEN");
    assertThat(first.assignee()).isEqualTo("karadoc");
    assertThat(first.description()).isEqualTo("the desc");
    assertThat(first.cost()).isEqualTo(4.2);
    assertThat(first.userLogin()).isEqualTo("perceval");
    assertThat(first.createdAt()).isNotNull();
    assertThat(first.updatedAt()).isNotNull();
    assertThat(first.closedAt()).isNotNull();
    assertThat(first.attribute("JIRA")).isEqualTo("FOO-1234");
    assertThat(first.attribute("OTHER")).isNull();
    assertThat(first.attributes()).hasSize(1);

    Issue second = list.get(1);
    assertThat(second.key()).isEqualTo("FGHIJ");
    assertThat(second.line()).isNull();
    assertThat(second.cost()).isNull();
    assertThat(second.description()).isNull();
    assertThat(second.attribute("JIRA")).isNull();
    assertThat(second.attributes()).isEmpty();
  }
}