]> source.dussan.org Git - sonarqube.git/commitdiff
Fix conflicts
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 27 May 2013 17:05:54 +0000 (19:05 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 27 May 2013 17:06:01 +0000 (19:06 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java [deleted file]
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueQueryResult.java [new file with mode: 0644]
sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueQueryResultTest.java
sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java
sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueQueryResult.java [deleted file]

index 779c33832edebe0685c5988fb338888f975518a7..741f1176f1a2a303587013d2b50746decc85d54a 100644 (file)
@@ -17,7 +17,6 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-
 package org.sonar.plugins.core;
 
 import com.google.common.collect.ImmutableList;
@@ -36,21 +35,13 @@ import org.sonar.plugins.core.issue.notification.*;
 import org.sonar.plugins.core.measurefilters.MyFavouritesFilter;
 import org.sonar.plugins.core.measurefilters.ProjectFilter;
 import org.sonar.plugins.core.notifications.alerts.NewAlerts;
-import org.sonar.plugins.core.notifications.reviews.ChangesInReviewAssignedToMeOrCreatedByMe;
-import org.sonar.plugins.core.notifications.reviews.NewFalsePositiveReview;
-import org.sonar.plugins.core.notifications.violations.NewViolationsOnFirstDifferentialPeriod;
 import org.sonar.plugins.core.security.ApplyProjectRolesDecorator;
 import org.sonar.plugins.core.sensors.*;
 import org.sonar.plugins.core.timemachine.*;
 import org.sonar.plugins.core.web.Lcom4Viewer;
 import org.sonar.plugins.core.web.TestsViewer;
 import org.sonar.plugins.core.widgets.*;
-import org.sonar.plugins.core.widgets.issues.ActionPlansWidget;
 import org.sonar.plugins.core.widgets.issues.*;
-import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget;
-import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget;
-import org.sonar.plugins.core.widgets.reviews.ProjectReviewsWidget;
-import org.sonar.plugins.core.widgets.reviews.ReviewsPerDeveloperWidget;
 
 import java.util.List;
 
@@ -446,7 +437,6 @@ public final class CorePlugin extends SonarPlugin {
       NoSonarFilter.class,
       DirectoriesDecorator.class,
       FilesDecorator.class,
-      ReviewNotifications.class,
       IndexProjectPostJob.class,
       ManualMeasureDecorator.class,
 
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java
deleted file mode 100644 (file)
index d9224b9..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.plugins.core.sensors;
-
-import org.sonar.api.BatchExtension;
-import org.sonar.api.database.model.User;
-import org.sonar.api.notifications.Notification;
-import org.sonar.api.notifications.NotificationManager;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.security.UserFinder;
-import org.sonar.core.review.ReviewDto;
-
-import javax.annotation.Nullable;
-
-public class ReviewNotifications implements BatchExtension {
-  private NotificationManager notificationManager;
-  private UserFinder userFinder;
-
-  public ReviewNotifications(NotificationManager notificationManager, UserFinder userFinder) {
-    this.notificationManager = notificationManager;
-    this.userFinder = userFinder;
-  }
-
-  void notifyReopened(ReviewDto review, Project project, Resource resource) {
-    Notification notification = createReviewNotification(review, project, resource)
-        .setFieldValue("old.status", review.getStatus())
-        .setFieldValue("new.status", ReviewDto.STATUS_REOPENED)
-        .setFieldValue("old.resolution", review.getResolution())
-        .setFieldValue("new.resolution", null);
-    notificationManager.scheduleForSending(notification);
-  }
-
-  void notifyClosed(ReviewDto review, Project project, @Nullable Resource resource) {
-    Notification notification = createReviewNotification(review, project, resource)
-        .setFieldValue("old.status", review.getStatus())
-        .setFieldValue("new.status", ReviewDto.STATUS_CLOSED);
-    notificationManager.scheduleForSending(notification);
-  }
-
-  private Notification createReviewNotification(ReviewDto review, Project project, @Nullable Resource resource) {
-    return new Notification("review-changed")
-        .setDefaultMessage("Review #" + review.getId() + " has changed.")
-        .setFieldValue("reviewId", String.valueOf(review.getId()))
-        .setFieldValue("project", project.getRoot().getLongName())
-        .setFieldValue("projectId", String.valueOf(project.getId()))
-        .setFieldValue("resource", resource != null ? resource.getLongName() : null)
-        .setFieldValue("title", review.getTitle())
-        .setFieldValue("creator", getCreator(review))
-        .setFieldValue("assignee", getAssignee(review));
-  }
-
-  private String getCreator(ReviewDto review) {
-    if (review.getUserId() == null) { // no creator and in fact this should never happen in real-life, however happens during unit tests
-      return null;
-    }
-    User user = userFinder.findById(review.getUserId());
-    return user != null ? user.getLogin() : null;
-  }
-
-  private String getAssignee(ReviewDto review) {
-    if (review.getAssigneeId() == null) { // not assigned
-      return null;
-    }
-    User user = userFinder.findById(review.getAssigneeId().intValue());
-    return user != null ? user.getLogin() : null;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueQueryResult.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueQueryResult.java
new file mode 100644 (file)
index 0000000..239d1b8
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.core.issue;
+
+import com.google.common.collect.Maps;
+import org.sonar.api.component.Component;
+import org.sonar.api.issue.ActionPlan;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueQueryResult;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.user.User;
+import org.sonar.api.utils.Paging;
+
+import javax.annotation.CheckForNull;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultIssueQueryResult implements IssueQueryResult {
+
+  private List<Issue> issues;
+  private final Map<RuleKey, Rule> rulesByKey = Maps.newHashMap();
+  private final Map<String, Component> componentsByKey = Maps.newHashMap();
+  private final Map<String, Component> projectsByKey = Maps.newHashMap();
+  private final Map<String, ActionPlan> actionPlansByKey = Maps.newHashMap();
+  private final Map<String, User> usersByLogin = Maps.newHashMap();
+  private boolean maxResultsReached;
+  private Paging paging;
+
+  public DefaultIssueQueryResult(List<Issue> issues){
+    this.issues = issues;
+  }
+
+  public DefaultIssueQueryResult addRules(Collection<Rule> rules){
+    for (Rule rule : rules) {
+      rulesByKey.put(rule.ruleKey(), rule);
+    }
+    return this;
+  }
+
+  public DefaultIssueQueryResult addComponents(Collection<Component> components){
+    for (Component component : components) {
+      componentsByKey.put(component.key(), component);
+    }
+    return this;
+  }
+
+  public DefaultIssueQueryResult addProjects(Collection<Component> projects){
+    for (Component project : projects) {
+      projectsByKey.put(project.key(), project);
+    }
+    return this;
+  }
+
+  public DefaultIssueQueryResult addActionPlans(Collection<ActionPlan> actionPlans){
+    for (ActionPlan actionPlan : actionPlans) {
+      actionPlansByKey.put(actionPlan.key(), actionPlan);
+    }
+    return this;
+  }
+
+  public DefaultIssueQueryResult addUsers(Collection<User> users){
+    for (User user : users) {
+      usersByLogin.put(user.login(), user);
+    }
+    return this;
+  }
+
+  public DefaultIssueQueryResult setMaxResultsReached(boolean maxResultsReached){
+    this.maxResultsReached = maxResultsReached;
+    return this;
+  }
+
+  public DefaultIssueQueryResult setPaging(Paging paging){
+    this.paging = paging;
+    return this;
+  }
+
+  @Override
+  public List<Issue> issues() {
+    return issues;
+  }
+
+  @Override
+  public Issue first() {
+    return issues != null && !issues.isEmpty() ? issues.get(0) : null;
+  }
+
+  @Override
+  public Rule rule(Issue issue) {
+    return rulesByKey.get(issue.ruleKey());
+  }
+
+  @Override
+  public Collection<Rule> rules() {
+    return rulesByKey.values();
+  }
+
+  @Override
+  public Component component(Issue issue) {
+    return componentsByKey.get(issue.componentKey());
+  }
+
+  @Override
+  public Collection<Component> components() {
+    return componentsByKey.values();
+  }
+
+  @Override
+  public Component project(Issue issue) {
+    return projectsByKey.get(issue.projectKey());
+  }
+
+  @Override
+  public Collection<Component> projects() {
+    return projectsByKey.values();
+  }
+
+  @Override
+  public ActionPlan actionPlan(Issue issue) {
+    return actionPlansByKey.get(issue.actionPlanKey());
+  }
+
+  @Override
+  public Collection<ActionPlan> actionPlans() {
+    return actionPlansByKey.values();
+  }
+
+  @Override
+  public Collection<User> users() {
+    return usersByLogin.values();
+  }
+
+  @Override
+  @CheckForNull
+  public User user(String login) {
+    return usersByLogin.get(login);
+  }
+
+  @Override
+  public boolean maxResultsReached() {
+    return maxResultsReached;
+  }
+
+  @Override
+  public Paging paging() {
+    return paging;
+  }
+
+
+}
index c3241d569c681fe74e4bbbfc50e7f280dc52fcf5..b1018bd62a87f6270339173b31e14616aba75ad0 100644 (file)
@@ -23,18 +23,19 @@ import org.junit.Test;
 import org.sonar.api.issue.Issue;
 
 import java.util.Arrays;
+import java.util.Collections;
 
 import static org.fest.assertions.Assertions.assertThat;
 
 public class DefaultIssueQueryResultTest {
   @Test
   public void test_first_issue() {
-    DefaultIssueQueryResult result = new DefaultIssueQueryResult();
+    DefaultIssueQueryResult result = new DefaultIssueQueryResult(Collections.<Issue>emptyList());
     assertThat(result.first()).isNull();
 
     Issue first = new DefaultIssue();
     Issue second = new DefaultIssue();
-    result.setIssues(Arrays.asList(first, second));
+    result = new DefaultIssueQueryResult(Arrays.asList(first, second));
     assertThat(result.first()).isSameAs(first);
   }
 }
index 42c404ada638780930f0f5317fcbffd4c3aa88d3..34789bb72ce2f0c7b37cf1fa1cbce5c201e033f3 100644 (file)
@@ -76,8 +76,7 @@ public class IssueNotificationsTest {
       .setFieldDiff(context, "status", "OPEN", "RESOLVED")
       .setComponentKey("struts:Action")
       .setProjectKey("struts");
-    DefaultIssueQueryResult queryResult = new DefaultIssueQueryResult();
-    queryResult.setIssues(Arrays.<Issue>asList(issue));
+    DefaultIssueQueryResult queryResult = new DefaultIssueQueryResult(Arrays.<Issue>asList(issue));
     queryResult.addProjects(Arrays.<Component>asList(new Project("struts")));
 
     Notification notification = issueNotifications.sendChanges(issue, context, queryResult);
index fcdf4e5dbd6082f425ccb470edf2228de9a4c2bd..0f099d0f2590bf774cbbe3eb762b1f760447b9dd 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.api.user.UserFinder;
 import org.sonar.api.utils.Paging;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.core.issue.DefaultIssueComment;
+import org.sonar.core.issue.DefaultIssueQueryResult;
 import org.sonar.core.issue.db.IssueChangeDao;
 import org.sonar.core.issue.db.IssueDao;
 import org.sonar.core.issue.db.IssueDto;
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueQueryResult.java b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueQueryResult.java
deleted file mode 100644 (file)
index 18b6860..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.issue;
-
-import com.google.common.collect.Maps;
-import org.sonar.api.component.Component;
-import org.sonar.api.issue.ActionPlan;
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.IssueQueryResult;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.user.User;
-import org.sonar.api.utils.Paging;
-
-import javax.annotation.CheckForNull;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-public class DefaultIssueQueryResult implements IssueQueryResult {
-
-  private List<Issue> issues;
-  private final Map<RuleKey, Rule> rulesByKey = Maps.newHashMap();
-  private final Map<String, Component> componentsByKey = Maps.newHashMap();
-  private final Map<String, Component> projectsByKey = Maps.newHashMap();
-  private final Map<String, ActionPlan> actionPlansByKey = Maps.newHashMap();
-  private final Map<String, User> usersByLogin = Maps.newHashMap();
-  private boolean maxResultsReached;
-  private Paging paging;
-
-  public DefaultIssueQueryResult(List<Issue> issues){
-    this.issues = issues;
-  }
-
-  public DefaultIssueQueryResult addRules(Collection<Rule> rules){
-    for (Rule rule : rules) {
-      rulesByKey.put(rule.ruleKey(), rule);
-    }
-    return this;
-  }
-
-  public DefaultIssueQueryResult addComponents(Collection<Component> components){
-    for (Component component : components) {
-      componentsByKey.put(component.key(), component);
-    }
-    return this;
-  }
-
-  public DefaultIssueQueryResult addProjects(Collection<Component> projects){
-    for (Component project : projects) {
-      projectsByKey.put(project.key(), project);
-    }
-    return this;
-  }
-
-  public DefaultIssueQueryResult addActionPlans(Collection<ActionPlan> actionPlans){
-    for (ActionPlan actionPlan : actionPlans) {
-      actionPlansByKey.put(actionPlan.key(), actionPlan);
-    }
-    return this;
-  }
-
-  public DefaultIssueQueryResult addUsers(Collection<User> users){
-    for (User user : users) {
-      usersByLogin.put(user.login(), user);
-    }
-    return this;
-  }
-
-  public DefaultIssueQueryResult setMaxResultsReached(boolean maxResultsReached){
-    this.maxResultsReached = maxResultsReached;
-    return this;
-  }
-
-  public DefaultIssueQueryResult setPaging(Paging paging){
-    this.paging = paging;
-    return this;
-  }
-
-  @Override
-  public List<Issue> issues() {
-    return issues;
-  }
-
-  @Override
-  public Issue first() {
-    return issues != null && !issues.isEmpty() ? issues.get(0) : null;
-  }
-
-  @Override
-  public Rule rule(Issue issue) {
-    return rulesByKey.get(issue.ruleKey());
-  }
-
-  @Override
-  public Collection<Rule> rules() {
-    return rulesByKey.values();
-  }
-
-  @Override
-  public Component component(Issue issue) {
-    return componentsByKey.get(issue.componentKey());
-  }
-
-  @Override
-  public Collection<Component> components() {
-    return componentsByKey.values();
-  }
-
-  @Override
-  public Component project(Issue issue) {
-    return projectsByKey.get(issue.projectKey());
-  }
-
-  @Override
-  public Collection<Component> projects() {
-    return projectsByKey.values();
-  }
-
-  @Override
-  public ActionPlan actionPlan(Issue issue) {
-    return actionPlansByKey.get(issue.actionPlanKey());
-  }
-
-  @Override
-  public Collection<ActionPlan> actionPlans() {
-    return actionPlansByKey.values();
-  }
-
-  @Override
-  public Collection<User> users() {
-    return usersByLogin.values();
-  }
-
-  @Override
-  @CheckForNull
-  public User user(String login) {
-    return usersByLogin.get(login);
-  }
-
-  @Override
-  public boolean maxResultsReached() {
-    return maxResultsReached;
-  }
-
-  @Override
-  public Paging paging() {
-    return paging;
-  }
-
-
-}