aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-05-10 19:15:50 +0200
committerFabrice Bellingard <bellingard@gmail.com>2012-05-14 15:11:01 +0200
commit0216057456ba13bf8471b1ae57be58f2a4795ec9 (patch)
tree096255c3006e491f85a3739ebff7169a384e67d6 /plugins
parent9f98c79be1638dabadc5a15bbf2ef512bbbcb690 (diff)
downloadsonarqube-0216057456ba13bf8471b1ae57be58f2a4795ec9.tar.gz
sonarqube-0216057456ba13bf8471b1ae57be58f2a4795ec9.zip
SONAR-2541 Replace "review_data" table by "data" column on "reviews"
- And feed this column when linking a review to JIRA, so that the menu does not appear any more.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-reviews-plugin/src/main/java/org/sonar/plugins/reviews/jira/JiraLinkReviewAction.java9
-rw-r--r--plugins/sonar-reviews-plugin/src/test/java/org/sonar/plugins/reviews/jira/JiraLinkReviewActionTest.java7
2 files changed, 16 insertions, 0 deletions
diff --git a/plugins/sonar-reviews-plugin/src/main/java/org/sonar/plugins/reviews/jira/JiraLinkReviewAction.java b/plugins/sonar-reviews-plugin/src/main/java/org/sonar/plugins/reviews/jira/JiraLinkReviewAction.java
index 02f97366428..5a5495e9b93 100644
--- a/plugins/sonar-reviews-plugin/src/main/java/org/sonar/plugins/reviews/jira/JiraLinkReviewAction.java
+++ b/plugins/sonar-reviews-plugin/src/main/java/org/sonar/plugins/reviews/jira/JiraLinkReviewAction.java
@@ -20,6 +20,7 @@
package org.sonar.plugins.reviews.jira;
import com.atlassian.jira.rpc.soap.client.RemoteIssue;
+import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.database.model.User;
import org.sonar.api.reviews.LinkReviewAction;
@@ -75,6 +76,9 @@ public class JiraLinkReviewAction implements LinkReviewAction {
}
addCommentToReview(review, issue, user, reviewContext.get(COMMENT_TEXT_PARAM));
+
+ updateReviewWithIssueInfo(review, issue);
+
}
private ReviewDto getReviewId(Map<String, String> reviewContext) {
@@ -120,4 +124,9 @@ public class JiraLinkReviewAction implements LinkReviewAction {
reviewCommentDao.insert(comment);
}
+ protected void updateReviewWithIssueInfo(ReviewDto review, RemoteIssue issue) {
+ review.addKeyValueToData(this.getId(), issue.getKey());
+ reviewDao.update(Lists.newArrayList(review));
+ }
+
}
diff --git a/plugins/sonar-reviews-plugin/src/test/java/org/sonar/plugins/reviews/jira/JiraLinkReviewActionTest.java b/plugins/sonar-reviews-plugin/src/test/java/org/sonar/plugins/reviews/jira/JiraLinkReviewActionTest.java
index d938259ac91..04e3d1c1643 100644
--- a/plugins/sonar-reviews-plugin/src/test/java/org/sonar/plugins/reviews/jira/JiraLinkReviewActionTest.java
+++ b/plugins/sonar-reviews-plugin/src/test/java/org/sonar/plugins/reviews/jira/JiraLinkReviewActionTest.java
@@ -34,6 +34,7 @@ import org.sonar.core.review.ReviewDao;
import org.sonar.core.review.ReviewDto;
import org.sonar.plugins.reviews.jira.soap.JiraSOAPClient;
+import java.util.Collection;
import java.util.Map;
import static org.hamcrest.Matchers.is;
@@ -93,6 +94,12 @@ public class JiraLinkReviewActionTest {
assertThat(comment.getReviewId(), is(45L));
assertThat(comment.getUserId(), is(12L));
assertThat(comment.getText(), is("Hello world\n\nReview linked to JIRA issue: http://localhost:8080/browse/FOO-15"));
+
+ ArgumentCaptor<Collection> reviewCaptor = ArgumentCaptor.forClass(Collection.class);
+ verify(reviewDao).update(reviewCaptor.capture());
+ ReviewDto reviewDto = (ReviewDto) reviewCaptor.getValue().iterator().next();
+ assertThat(reviewDto.getData(), is(action.getId() + "=FOO-15"));
+
}
@Test