]> source.dussan.org Git - sonarqube.git/commitdiff
Add a first entry in the issue changelog containing date of issue's creation
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 28 Jan 2014 09:39:40 +0000 (10:39 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 28 Jan 2014 09:39:40 +0000 (10:39 +0100)
15 files changed:
sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_action_plan.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_actions.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_actions_defined_by_plugins.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_assign_to_me_action.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_changelog.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_comments.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_dates.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_set_severity_action.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_technical_debt.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_transitions.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_with_users.json
sonar-server/src/test/resources/org/sonar/server/issue/ws/IssueShowWsHandlerTest/show_issue_without_assign_to_me_action.json

index c8e5f77fd8769a332824cc98c2cc09a41c622008..9f5c0c6c97d0da07794866f34386bf0f8c693198 100644 (file)
@@ -186,7 +186,15 @@ public class IssueShowWsHandler implements RequestHandler {
   }
 
   private void writeChangelog(Issue issue, JsonWriter json) {
-    json.name("changelog").beginArray();
+    json.name("changelog").beginArray()
+      .beginObject()
+      .prop("creationDate", DateUtils.formatDateTime(issue.creationDate()))
+      .prop("fCreationDate", formatDate(issue.creationDate()))
+      .name("diffs").beginArray()
+      .value(i18n.message(UserSession.get().locale(), "created", null))
+      .endArray()
+      .endObject();
+
     IssueChangelog changelog = issueChangelogService.changelog(issue);
     for (FieldDiffs diffs : changelog.changes()) {
       String userLogin = diffs.userLogin();
@@ -195,7 +203,6 @@ public class IssueShowWsHandler implements RequestHandler {
         .prop("userName", userLogin != null ? changelog.user(diffs).name() : null)
         .prop("creationDate", DateUtils.formatDateTime(diffs.creationDate()))
         .prop("fCreationDate", formatDate(diffs.creationDate()));
-
       json.name("diffs").beginArray();
       List<String> diffsFormatted = issueChangelogService.formatDiffs(diffs);
       for (String diff : diffsFormatted) {
index 7ef9cb93c408dc908fa8dfdd5dc220a3e379e71b..1959e1babf168b8ffa9732c608203f356bd9825c 100644 (file)
@@ -131,6 +131,9 @@ public class IssueShowWsHandlerTest {
       .setCreationDate(DateUtils.parseDateTime("2014-01-22T19:10:03+0100"));
     issues.add(issue);
 
+    when(i18n.formatDateTime(any(Locale.class), eq(issue.creationDate()))).thenReturn("Jan 22, 2014 10:03 AM");
+    when(i18n.message(any(Locale.class), eq("created"), eq((String) null))).thenReturn("Created");
+
     MockUserSession.set();
     WsTester.TestRequest request = tester.newRequest("show").setParam("key", issueKey);
     request.execute().assertJson(getClass(), "show_issue.json");
@@ -344,11 +347,14 @@ public class IssueShowWsHandlerTest {
   }
 
   private DefaultIssue createStandardIssue() {
-    return new DefaultIssue()
+    DefaultIssue issue = new DefaultIssue()
       .setKey("ABCD")
       .setComponentKey("org.sonar.server.issue.IssueClient")
       .setProjectKey("org.sonar.Sonar")
       .setRuleKey(RuleKey.of("squid", "AvoidCycle"))
       .setCreationDate(DateUtils.parseDateTime("2014-01-22T19:10:03+0100"));
+    when(i18n.formatDateTime(any(Locale.class), eq(issue.creationDate()))).thenReturn("Jan 22, 2014 10:03 AM");
+    when(i18n.message(any(Locale.class), eq("created"), eq((String) null))).thenReturn("Created");
+    return issue;
   }
 }
index 08bddf8422eb43622acf301e0b4cf0a5de7dc68a..be5cd9c8346b7195b39b3326b819e0a57fa42c6a 100644 (file)
     "status": "CLOSED",
     "severity": "MAJOR",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index dc9d14e6222747ba672d1f4e5b534a623634dfeb..49f7db8f8c06bab843c4ec8b40fbdac2d571754a 100644 (file)
     "actionPlan" : "AP-ABCD",
     "actionPlanName" : "Version 4.2",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index ddf54a26edacbfe944019308be68d3929b1bee16..011a92460cba11474dcfdccc6fb756ce1e8c0eff 100644 (file)
     "ruleName": "Avoid cycle",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [
        "comment", "assign", "assign_to_me", "plan"
     ],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index 38fd6674cb8420ed446997609a14d1f9f677a3a0..1b75cbc5b7cd876cbde2ec848859de9b6ddd0125 100644 (file)
     "ruleName": "Avoid cycle",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [
        "comment", "assign", "assign_to_me", "plan", "link-to-jira"
     ],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index ddf54a26edacbfe944019308be68d3929b1bee16..011a92460cba11474dcfdccc6fb756ce1e8c0eff 100644 (file)
     "ruleName": "Avoid cycle",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [
        "comment", "assign", "assign_to_me", "plan"
     ],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index 91e9d3754735f0d731d206d6f81474fca28fb69d..35bc7c3ef599e3051d43ba6bf423f2fc59b5ce5c 100644 (file)
@@ -9,10 +9,16 @@
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [],
     "comments": [],
     "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      },
       {
         "userName": "John",
         "creationDate": "2014-02-22T19:10:03+0100",
index 39be419acda32999bdd1b3edb111ea89280ce677..1e863053a9bbeb65064655ef806089f4e4884ff4 100644 (file)
@@ -9,6 +9,7 @@
     "rule": "squid:AvoidCycle",
     "ruleName": "Avoid cycle",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": ["comment", "assign", "assign_to_me", "plan"],
     "comments": [
         "updatable": true
       }
     ],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index 9de9bd41d9db0f9f6732655f874e3a9f75465619..67db98ec7c1e08d6ebcb5802b5f1b66905fb34e1 100644 (file)
     "transitions": [],
     "actions": [],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index 84547bc88ad9e307a237e1bea51480897905ad58..9e2ce2a3daad4af9204ace84d97aefbbc61385e3 100644 (file)
     "ruleName": "Avoid cycle",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [
        "comment", "assign", "assign_to_me", "plan", "set_severity"
     ],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index a65353a2264dd1895c71c8873afefd9882c2b956..f938630cfaa401b6d8bb5c4ffcc0afc982d17867 100644 (file)
     "ruleName": "Avoid cycle",
     "debt": "2 hours 1 minutes",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index 84b3f02ab4e7d598a7c68eecbf4a2c0baff4bc3a..d7646909a37d0896ab4a74ba3b829b513cb95a03 100644 (file)
     "status": "RESOLVED",
     "resolution": "FIXED",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": ["reopen"],
     "actions": ["comment"],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index 0585eef171b521833aee776628f395ec12c4de0f..f26e887d9d65a93d202f1d77cba093dd6ca2c711 100644 (file)
     "reporterName": "Steven",
     "author": "Henry",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }
index fefb526ccd37469412f7e62a88cae7bcc590b5e5..4adcdc4d5336d60e2a4ebe6775502807dfad3092 100644 (file)
     "assigneeName": "John",
     "status": "OPEN",
     "creationDate": "2014-01-22T19:10:03+0100",
+    "fCreationDate": "Jan 22, 2014 10:03 AM",
     "transitions": [],
     "actions": [
        "comment", "assign", "plan"
     ],
     "comments": [],
-    "changelog": []
+    "changelog": [
+      {
+        "creationDate": "2014-01-22T19:10:03+0100",
+        "fCreationDate": "Jan 22, 2014 10:03 AM",
+        "diffs": ["Created"]
+      }
+    ]
   }
 }