]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5341 Update Issues WS Java client due to removal of issue.componentId and issue...
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 28 May 2014 15:44:40 +0000 (17:44 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 28 May 2014 15:44:40 +0000 (17:44 +0200)
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java
sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/IssueJsonParserTest.java
sonar-ws-client/src/test/resources/org/sonar/wsclient/issue/internal/IssueJsonParserTest/search.json

index 7949a54b6bc69100094dd25b49b09677754fbe46..6a9d8477490acc18499d2d5c1c5f1bdacf6a8162 100644 (file)
@@ -37,8 +37,6 @@ public interface Issue {
 
   String componentKey();
 
-  Long componentId();
-
   String projectKey();
 
   String ruleKey();
@@ -51,9 +49,6 @@ public interface Issue {
   @CheckForNull
   Integer line();
 
-  @CheckForNull
-  Double effortToFix();
-
   @CheckForNull
   String debt();
 
index 0b7de9482266d9d08343fe388125e4dba6c234ec..702b83760ae2a1d91f43cc76bfa9919de7b87cac 100644 (file)
@@ -54,6 +54,9 @@ public interface Issues {
   @CheckForNull
   Component componentById(long id);
 
+  @CheckForNull
+  Component componentByKey(String key);
+
   Collection<Component> projects();
 
   @CheckForNull
index f55ff479e499ce16012969cdd4e472deada354d1..eadf2b9f1ee78d5301cf975e385da50460b3b4be 100644 (file)
@@ -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");
   }
@@ -75,11 +71,6 @@ public class DefaultIssue implements Issue {
     return JsonUtils.getInteger(json, "line");
   }
 
-  @CheckForNull
-  public Double effortToFix() {
-    return JsonUtils.getDouble(json, "effortToFix");
-  }
-
   @CheckForNull
   public String debt() {
     return JsonUtils.getString(json, "debt");
index 2b76fa74634c3d465194a820f613d3ddac6787db..39e5ecbfffba01c615abab580cd314de18176458 100644 (file)
@@ -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;
   }
 
index 5e5948fcc6a5316046045a31f18fb193cbfb91da..6b4132be8b89907f6690295a00d1b0fabfac0c78 100644 (file)
@@ -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);
 
index 9890708cfa901448d2760b1303b5fd1adda65e42..38ee33159f50ab80b980616895f3815a52e3f1ca 100644 (file)
@@ -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",