aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-28 17:44:40 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-28 17:44:40 +0200
commitd1b514f16193b48f381164879120a2da9c4219aa (patch)
tree870fb0ecda71232933ee22376bfdb8f5fed9c453
parent5ea06e340b841a1868dd0d500c5829db5ac2134a (diff)
downloadsonarqube-d1b514f16193b48f381164879120a2da9c4219aa.tar.gz
sonarqube-d1b514f16193b48f381164879120a2da9c4219aa.zip
SONAR-5341 Update Issues WS Java client due to removal of issue.componentId and issue.effortToFix
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java5
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java3
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java9
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java11
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java25
-rw-r--r--sonar-ws-client/src/test/resources/org/sonar/wsclient/issue/internal/IssueJsonParserTest/search.json2
6 files changed, 23 insertions, 32 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java
index 7949a54b6bc..6a9d8477490 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java
@@ -37,8 +37,6 @@ public interface Issue {
String componentKey();
- Long componentId();
-
String projectKey();
String ruleKey();
@@ -52,9 +50,6 @@ public interface Issue {
Integer line();
@CheckForNull
- Double effortToFix();
-
- @CheckForNull
String debt();
String status();
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java
index 0b7de948226..702b83760ae 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java
@@ -54,6 +54,9 @@ public interface Issues {
@CheckForNull
Component componentById(long id);
+ @CheckForNull
+ Component componentByKey(String key);
+
Collection<Component> projects();
@CheckForNull
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java
index f55ff479e49..eadf2b9f1ee 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java
@@ -49,10 +49,6 @@ public class DefaultIssue implements Issue {
return JsonUtils.getString(json, "component");
}
- public Long componentId() {
- return JsonUtils.getLong(json, "componentId");
- }
-
public String projectKey() {
return JsonUtils.getString(json, "project");
}
@@ -76,11 +72,6 @@ public class DefaultIssue implements Issue {
}
@CheckForNull
- public Double effortToFix() {
- return JsonUtils.getDouble(json, "effortToFix");
- }
-
- @CheckForNull
public String debt() {
return JsonUtils.getString(json, "debt");
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java
index 2b76fa74634..39e5ecbfffb 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java
@@ -41,6 +41,7 @@ public class DefaultIssues implements Issues {
private final Map<String, Rule> rulesByKey = new HashMap<String, Rule>();
private final Map<String, User> usersByKey = new HashMap<String, User>();
private final Map<Long, Component> componentsById = new HashMap<Long, Component>();
+ private final Map<String, Component> componentsByKey = new HashMap<String, Component>();
private final Map<String, Component> projectsByKey = new HashMap<String, Component>();
private final Map<String, ActionPlan> actionPlansByKey = new HashMap<String, ActionPlan>();
private Paging paging;
@@ -72,12 +73,12 @@ public class DefaultIssues implements Issues {
}
public Collection<Component> components() {
- return componentsById.values();
+ return componentsByKey.values();
}
@CheckForNull
public Component component(Issue issue) {
- return componentsById.get(issue.componentId());
+ return componentsByKey.get(issue.componentKey());
}
@CheckForNull
@@ -85,6 +86,11 @@ public class DefaultIssues implements Issues {
return componentsById.get(id);
}
+ @CheckForNull
+ public Component componentByKey(String key) {
+ return componentsByKey.get(key);
+ }
+
public Collection<Component> projects() {
return projectsByKey.values();
}
@@ -134,6 +140,7 @@ public class DefaultIssues implements Issues {
DefaultIssues addComponent(Component c) {
componentsById.put(c.id(), c);
+ componentsByKey.put(c.key(), c);
return this;
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java
index 5e5948fcc6a..6b4132be8b8 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java
@@ -42,7 +42,6 @@ public class IssueJsonParserTest {
Issue first = list.get(0);
assertThat(first.key()).isEqualTo("ABCDE");
assertThat(first.componentKey()).isEqualTo("Action.java");
- assertThat(first.componentId()).isEqualTo(10L);
assertThat(first.projectKey()).isEqualTo("struts");
assertThat(first.ruleKey()).isEqualTo("squid:CycleBetweenPackages");
assertThat(first.severity()).isEqualTo("CRITICAL");
@@ -51,7 +50,6 @@ public class IssueJsonParserTest {
assertThat(first.status()).isEqualTo("OPEN");
assertThat(first.assignee()).isEqualTo("karadoc");
assertThat(first.message()).isEqualTo("the message");
- assertThat(first.effortToFix()).isEqualTo(4.2);
assertThat(first.debt()).isNull();
assertThat(first.reporter()).isEqualTo("perceval");
assertThat(first.author()).isEqualTo("pirlouis");
@@ -67,7 +65,6 @@ public class IssueJsonParserTest {
Issue second = list.get(1);
assertThat(second.key()).isEqualTo("FGHIJ");
assertThat(second.line()).isNull();
- assertThat(second.effortToFix()).isNull();
assertThat(second.debt()).isNull();
assertThat(second.reporter()).isNull();
assertThat(second.author()).isNull();
@@ -111,7 +108,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_comments() throws Exception {
+ public void parse_comments() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/issue-with-comments.json"));
Issues issues = new IssueJsonParser().parseIssues(json);
assertThat(issues.size()).isEqualTo(1);
@@ -133,7 +130,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_users() throws Exception {
+ public void parse_users() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/issue-with-users.json"));
Issues issues = new IssueJsonParser().parseIssues(json);
@@ -153,7 +150,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_components() throws Exception {
+ public void parse_components() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/issue-with-components.json"));
Issues issues = new IssueJsonParser().parseIssues(json);
@@ -168,11 +165,12 @@ public class IssueJsonParserTest {
assertThat(component.subProjectId()).isEqualTo(2L);
assertThat(component.projectId()).isEqualTo(1L);
+ assertThat(issues.componentByKey("struts:Action.java").key()).isEqualTo("struts:Action.java");
assertThat(issues.componentById(10).key()).isEqualTo("struts:Action.java");
}
@Test
- public void should_parse_projects() throws Exception {
+ public void parse_projects() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/issue-with-projects.json"));
Issues issues = new IssueJsonParser().parseIssues(json);
@@ -186,7 +184,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_action_plans() throws Exception {
+ public void parse_action_plans() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/issue-with-action-plans.json"));
Issues issues = new IssueJsonParser().parseIssues(json);
@@ -203,7 +201,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_technical_debt() throws Exception {
+ public void parse_technical_debt() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/issue-with-technical-debt.json"));
Issues issues = new IssueJsonParser().parseIssues(json);
assertThat(issues.size()).isEqualTo(1);
@@ -212,9 +210,8 @@ public class IssueJsonParserTest {
assertThat(issue.debt()).isEqualTo("3d10min");
}
-
@Test
- public void should_parse_changelog() throws Exception {
+ public void parse_changelog() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/changelog.json"));
List<IssueChange> changes = new IssueJsonParser().parseChangelog(json);
@@ -243,7 +240,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_changelog_with_technical_debt() throws Exception {
+ public void parse_changelog_with_technical_debt() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/changelog-with-technical-debt.json"));
List<IssueChange> changes = new IssueJsonParser().parseChangelog(json);
@@ -260,7 +257,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_changelog_with_only_new_technical_debt() throws Exception {
+ public void parse_changelog_with_only_new_technical_debt() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/changelog-with-only-new-technical-debt.json"));
List<IssueChange> changes = new IssueJsonParser().parseChangelog(json);
@@ -277,7 +274,7 @@ public class IssueJsonParserTest {
}
@Test
- public void should_parse_bulk_change() throws Exception {
+ public void parse_bulk_change() throws Exception {
String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/internal/IssueJsonParserTest/bulk-change.json"));
BulkChange bulkChange = new IssueJsonParser().parseBulkChange(json);
diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/issue/internal/IssueJsonParserTest/search.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/issue/internal/IssueJsonParserTest/search.json
index 9890708cfa9..38ee33159f5 100644
--- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/issue/internal/IssueJsonParserTest/search.json
+++ b/sonar-ws-client/src/test/resources/org/sonar/wsclient/issue/internal/IssueJsonParserTest/search.json
@@ -3,7 +3,6 @@
{
"key": "ABCDE",
"component": "Action.java",
- "componentId": 10,
"project": "struts",
"rule": "squid:CycleBetweenPackages",
"severity": "CRITICAL",
@@ -11,7 +10,6 @@
"resolution": "FIXED",
"status": "OPEN",
"assignee": "karadoc",
- "effortToFix": 4.2,
"message": "the message",
"title": "the title",
"reporter": "perceval",