}
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();
.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) {
.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");
}
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;
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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",
"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"]
+ }
+ ]
}
}
"transitions": [],
"actions": [],
"comments": [],
- "changelog": []
+ "changelog": [
+ {
+ "creationDate": "2014-01-22T19:10:03+0100",
+ "fCreationDate": "Jan 22, 2014 10:03 AM",
+ "diffs": ["Created"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}
"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"]
+ }
+ ]
}
}