import org.sonar.server.issue.ActionService;
import org.sonar.server.issue.IssueService;
import org.sonar.server.technicaldebt.InternalRubyTechnicalDebtService;
+import org.sonar.server.text.RubyTextService;
import org.sonar.server.user.UserSession;
import java.util.Arrays;
private final IssueService issueService;
private final ActionService actionService;
private final InternalRubyTechnicalDebtService technicalDebtService;
+ private final RubyTextService textService;
- public IssueShowWsHandler(IssueFinder issueFinder, IssueService issueService, ActionService actionService, InternalRubyTechnicalDebtService technicalDebtService) {
+ public IssueShowWsHandler(IssueFinder issueFinder, IssueService issueService, ActionService actionService,
+ InternalRubyTechnicalDebtService technicalDebtService, RubyTextService textService) {
this.issueFinder = issueFinder;
this.issueService = issueService;
this.actionService = actionService;
this.technicalDebtService = technicalDebtService;
+ this.textService = textService;
}
@Override
.prop("key", comment.key())
.prop("userLogin", userLogin)
.prop("userName", userLogin != null ? queryResult.user(userLogin).name() : null)
- // TODO convert markdown to HTML
- // TODO add date
+ .prop("html", textService.markdownToHtml(comment.markdownText()))
+ // add markdownText ?
+ .prop("creationDate", DateUtils.formatDateTime(comment.createdAt()))
+ // TODO add formatted date
.endObject();
}
json.endArray();
import org.sonar.server.issue.ActionService;
import org.sonar.server.issue.IssueService;
import org.sonar.server.technicaldebt.InternalRubyTechnicalDebtService;
+import org.sonar.server.text.RubyTextService;
import org.sonar.server.user.MockUserSession;
import org.sonar.server.user.UserSession;
import org.sonar.server.ws.WsTester;
@Mock
InternalRubyTechnicalDebtService technicalDebtService;
+ @Mock
+ RubyTextService textService;
+
List<Issue> issues;
DefaultIssueQueryResult result;
result.addRules(newArrayList(Rule.create("squid", "AvoidCycle").setName("Avoid cycle")));
when(issueFinder.find(any(IssueQuery.class))).thenReturn(result);
- tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, actionService, technicalDebtService)));
+ tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, actionService, technicalDebtService, textService)));
}
@Test
public void show_issue_with_comments() throws Exception {
Issue issue = createStandardIssue()
.addComment(
- new DefaultIssueComment().setKey("COMMENT-ABCD").setMarkdownText("My comment").setUserLogin("john")
+ new DefaultIssueComment()
+ .setKey("COMMENT-ABCD")
+ .setMarkdownText("*My comment*")
+ .setUserLogin("john")
+ .setCreatedAt(DateUtils.parseDateTime("2014-01-23T19:10:03+0100"))
);
issues.add(issue);
result.addUsers(newArrayList((User) new DefaultUser().setLogin("john").setName("John")));
+ when(textService.markdownToHtml("*My comment*")).thenReturn("<b>My comment</b>");
+
MockUserSession.set();
SimpleRequest request = new SimpleRequest().setParam("key", issue.key());
tester.execute("show", request).assertJson(getClass(), "show_issue_with_comments.json");