]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 Role required to find issues should be USER instead of CODE VIEWER
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 7 Jun 2013 15:53:48 +0000 (17:53 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 7 Jun 2013 15:53:48 +0000 (17:53 +0200)
sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java
sonar-server/src/main/java/org/sonar/server/issue/PublicRubyIssueService.java
sonar-server/src/test/java/org/sonar/server/issue/PublicRubyIssueServiceTest.java

index 761c2b8294fc7de2d2c8425ee09e0195132ce09f..5daf278f46a21b4d49cb9ca1f660170989ac7e31 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.api.web.UserRole;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+
 import java.util.Collection;
 import java.util.Date;
 import java.util.Set;
@@ -218,7 +219,7 @@ public class IssueQuery {
     private Boolean asc = false;
     private Integer pageSize;
     private Integer pageIndex;
-    private String requiredRole = UserRole.CODEVIEWER;
+    private String requiredRole = UserRole.USER;
 
     private Builder() {
     }
index 5792dc0f63a4b190c591362fb048820b90a93e0e..3ee45572a6c19f7621bc48138426c1fe819d641b 100644 (file)
@@ -52,7 +52,7 @@ public class IssueQueryTest {
       .sort(IssueQuery.SORT_BY_ASSIGNEE)
       .pageSize(10)
       .pageIndex(2)
-      .requiredRole(UserRole.CODEVIEWER)
+      .requiredRole(UserRole.USER)
       .build();
     assertThat(query.issueKeys()).containsOnly("ABCDE");
     assertThat(query.severities()).containsOnly(Severity.BLOCKER);
@@ -70,7 +70,7 @@ public class IssueQueryTest {
     assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_ASSIGNEE);
     assertThat(query.pageSize()).isEqualTo(10);
     assertThat(query.pageIndex()).isEqualTo(2);
-    assertThat(query.requiredRole()).isEqualTo(UserRole.CODEVIEWER);
+    assertThat(query.requiredRole()).isEqualTo(UserRole.USER);
   }
 
   @Test
index 2f12f8ce1f929b1dda40fbd35d499191532b287a..62e6763bc144cf8dd2ae95c1f714612431d1b4b1 100644 (file)
@@ -51,12 +51,20 @@ public class PublicRubyIssueService implements RubyIssueService {
     this.finder = f;
   }
 
+  /**
+   * Requires the role {@link org.sonar.api.web.UserRole#USER}
+   */
+  @Override
   public IssueQueryResult find(String issueKey) {
-    return finder.find(IssueQuery.builder().issueKeys(Arrays.asList(issueKey)).build());
+    return finder.find(
+      IssueQuery.builder()
+        .issueKeys(Arrays.asList(issueKey))
+        .requiredRole(UserRole.USER)
+        .build());
   }
 
   /**
-   * Requires the role {@link org.sonar.api.web.UserRole#CODEVIEWER}
+   * Requires the role {@link org.sonar.api.web.UserRole#USER}
    */
   @Override
   public IssueQueryResult find(Map<String, Object> params) {
@@ -64,25 +72,25 @@ public class PublicRubyIssueService implements RubyIssueService {
   }
 
   static IssueQuery toQuery(Map<String, Object> props) {
-    IssueQuery.Builder builder = IssueQuery.builder();
-    builder.requiredRole(UserRole.CODEVIEWER);
-    builder.issueKeys(RubyUtils.toStrings(props.get("issues")));
-    builder.severities(RubyUtils.toStrings(props.get("severities")));
-    builder.statuses(RubyUtils.toStrings(props.get("statuses")));
-    builder.resolutions(RubyUtils.toStrings(props.get("resolutions")));
-    builder.resolved(RubyUtils.toBoolean(props.get("resolved")));
-    builder.components(RubyUtils.toStrings(props.get("components")));
-    builder.componentRoots(RubyUtils.toStrings(props.get("componentRoots")));
-    builder.rules(toRules(props.get("rules")));
-    builder.actionPlans(RubyUtils.toStrings(props.get("actionPlans")));
-    builder.reporters(RubyUtils.toStrings(props.get("reporters")));
-    builder.assignees(RubyUtils.toStrings(props.get("assignees")));
-    builder.assigned(RubyUtils.toBoolean(props.get("assigned")));
-    builder.planned(RubyUtils.toBoolean(props.get("planned")));
-    builder.createdAfter(RubyUtils.toDate(props.get("createdAfter")));
-    builder.createdBefore(RubyUtils.toDate(props.get("createdBefore")));
-    builder.pageSize(RubyUtils.toInteger(props.get("pageSize")));
-    builder.pageIndex(RubyUtils.toInteger(props.get("pageIndex")));
+    IssueQuery.Builder builder = IssueQuery.builder()
+      .requiredRole(UserRole.USER)
+      .issueKeys(RubyUtils.toStrings(props.get("issues")))
+      .severities(RubyUtils.toStrings(props.get("severities")))
+      .statuses(RubyUtils.toStrings(props.get("statuses")))
+      .resolutions(RubyUtils.toStrings(props.get("resolutions")))
+      .resolved(RubyUtils.toBoolean(props.get("resolved")))
+      .components(RubyUtils.toStrings(props.get("components")))
+      .componentRoots(RubyUtils.toStrings(props.get("componentRoots")))
+      .rules(toRules(props.get("rules")))
+      .actionPlans(RubyUtils.toStrings(props.get("actionPlans")))
+      .reporters(RubyUtils.toStrings(props.get("reporters")))
+      .assignees(RubyUtils.toStrings(props.get("assignees")))
+      .assigned(RubyUtils.toBoolean(props.get("assigned")))
+      .planned(RubyUtils.toBoolean(props.get("planned")))
+      .createdAfter(RubyUtils.toDate(props.get("createdAfter")))
+      .createdBefore(RubyUtils.toDate(props.get("createdBefore")))
+      .pageSize(RubyUtils.toInteger(props.get("pageSize")))
+      .pageIndex(RubyUtils.toInteger(props.get("pageIndex")));
     String sort = (String) props.get("sort");
     if (sort != null) {
       builder.sort(sort);
index 8552facf9bbb5777429ebd724d21c500c91b42e6..3a99e736e438f0e38b038ee6ae9f14eccf11c57a 100644 (file)
@@ -44,13 +44,25 @@ public class PublicRubyIssueServiceTest {
   PublicRubyIssueService facade = new PublicRubyIssueService(finder);
 
   @Test
-  public void find() throws Exception {
+  public void find_by_issue_keys() throws Exception {
+    facade.find("ABCDE");
+    verify(finder).find(argThat(new ArgumentMatcher<IssueQuery>() {
+      @Override
+      public boolean matches(Object o) {
+        IssueQuery query = (IssueQuery) o;
+        return query.issueKeys().contains("ABCDE") && UserRole.USER.equals(query.requiredRole());
+      }
+    }));
+  }
+
+  @Test
+  public void find_by_params() throws Exception {
     facade.find(ImmutableMap.<String, Object>of("issues", Lists.newArrayList("ABCDE")));
     verify(finder).find(argThat(new ArgumentMatcher<IssueQuery>() {
       @Override
       public boolean matches(Object o) {
         IssueQuery query = (IssueQuery) o;
-        return query.issueKeys().contains("ABCDE") && UserRole.CODEVIEWER.equals(query.requiredRole());
+        return query.issueKeys().contains("ABCDE") && UserRole.USER.equals(query.requiredRole());
       }
     }));
   }