]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8221 Add IT on search projects action
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 20 Oct 2016 13:03:19 +0000 (15:03 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 20 Oct 2016 14:01:03 +0000 (16:01 +0200)
it/it-tests/src/test/java/it/Category4Suite.java
it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/component/es/ProjectMeasuresResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupTest.java [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupTest/shared.xml [new file with mode: 0644]
sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchProjectsRequest.java

index d32ea11c17c24e6c2a34305e30954a07296d15db..fe2aa8342cf0f5f547e2bdce78e5a7c0fef3fe3f 100644 (file)
@@ -34,6 +34,7 @@ import it.duplication.NewDuplicationsTest;
 import it.http.HttpHeadersTest;
 import it.projectComparison.ProjectComparisonTest;
 import it.projectEvent.EventTest;
+import it.projectSearch.SearchProjectsTest;
 import it.qualityProfile.QualityProfilesPageTest;
 import it.serverSystem.LogsTest;
 import it.serverSystem.ServerSystemTest;
@@ -87,6 +88,8 @@ import static util.ItUtils.xooPlugin;
   DashboardTest.class,
   // project comparison
   ProjectComparisonTest.class,
+  // project search
+  SearchProjectsTest.class,
   // component search
   AllProjectsTest.class,
   // http
diff --git a/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java b/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java
new file mode 100644 (file)
index 0000000..7790ae1
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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 it.projectSearch;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import it.Category4Suite;
+import java.io.IOException;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.WsComponents.Component;
+import org.sonarqube.ws.WsComponents.SearchProjectsWsResponse;
+import org.sonarqube.ws.client.component.SearchProjectsRequest;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.projectDir;
+
+public class SearchProjectsTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+
+  @Before
+  public void setUp() throws Exception {
+    orchestrator.resetData();
+  }
+
+  @Test
+  public void search_projects_with_filter_having_one_criterion() throws Exception {
+    orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
+
+    SearchProjectsWsResponse response = searchProjects("ncloc > 1");
+
+    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("sample");
+  }
+
+  @Test
+  public void return_project_even_without_analysis() throws Exception {
+    orchestrator.getServer().provisionProject("sample", "sample");
+
+    SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().build());
+
+    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("sample");
+  }
+
+  private SearchProjectsWsResponse searchProjects(String filter) throws IOException {
+    return searchProjects(SearchProjectsRequest.builder().setFilter(filter).build());
+  }
+
+  private SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) throws IOException {
+    return newAdminWsClient(orchestrator).components().searchProjects(request);
+  }
+}
index fe6798aa8f2f416a2024a665499b772a0509eadd..2e9c1c1daa54ca20546152bc00d2fcb4b19225c0 100644 (file)
@@ -141,7 +141,7 @@ public class ProjectMeasuresResultSetIterator extends ResultSetIterator<ProjectM
     return doc;
   }
 
-  private Measures selectMeasures(String projectUuid, String analysisUuid) {
+  private Measures selectMeasures(String projectUuid, @Nullable String analysisUuid) {
     Measures measures = new Measures();
     try (PreparedStatement stmt = createMeasuresStatement(projectUuid, analysisUuid);
       ResultSet rs = stmt.executeQuery()) {
index 2fc63bbb302b28d99615c870b4e8f4eead4459a2..bb5ba51b32ea36944114cddece555262ef307c1d 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.api.utils.log.Loggers;
 import org.sonar.db.DbSession;
 import org.sonar.db.MyBatis;
 import org.sonar.db.version.DatabaseVersion;
+import org.sonar.server.component.es.ProjectMeasuresIndexDefinition;
 import org.sonar.server.es.BulkIndexer;
 import org.sonar.server.es.EsClient;
 import org.sonar.server.issue.index.IssueIndexDefinition;
@@ -56,7 +57,7 @@ public class BackendCleanup {
     "organizations", BackendCleanup::truncateOrganizations,
     "users", BackendCleanup::truncateUsers,
     "internal_properties", BackendCleanup::truncateInternalProperties,
-      "schema_migrations", BackendCleanup::truncateSchemaMigrations);
+    "schema_migrations", BackendCleanup::truncateSchemaMigrations);
 
   private final EsClient esClient;
   private final MyBatis myBatis;
@@ -125,6 +126,7 @@ public class BackendCleanup {
 
       clearIndex(IssueIndexDefinition.INDEX);
       clearIndex(ViewIndexDefinition.INDEX);
+      clearIndex(ProjectMeasuresIndexDefinition.INDEX_PROJECT_MEASURES);
 
     } catch (SQLException e) {
       throw new IllegalStateException("Fail to reset data", e);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java
deleted file mode 100644 (file)
index df1bf2c..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.platform;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.db.rule.RuleTesting;
-import org.sonar.server.es.EsTester;
-import org.sonar.server.issue.IssueTesting;
-import org.sonar.server.issue.index.IssueIndexDefinition;
-import org.sonar.server.rule.index.RuleDoc;
-import org.sonar.server.rule.index.RuleIndexDefinition;
-import org.sonar.server.view.index.ViewDoc;
-import org.sonar.server.view.index.ViewIndexDefinition;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class BackendCleanupMediumTest {
-
-  @Rule
-  public EsTester esTester = new EsTester(
-    new RuleIndexDefinition(new MapSettings()),
-    new IssueIndexDefinition(new MapSettings()),
-    new ViewIndexDefinition(new MapSettings())
-    );
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  BackendCleanup backendCleanup = new BackendCleanup(esTester.client(), dbTester.myBatis());
-
-  @Test
-  public void clear_db() {
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-
-    backendCleanup.clearDb();
-
-    assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(0);
-    assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(0);
-    assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(0);
-    assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0);
-  }
-
-  @Test
-  public void clear_indexes() throws Exception {
-    esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc());
-    esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc());
-
-    backendCleanup.clearIndexes();
-
-    assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isEqualTo(0);
-  }
-
-  @Test
-  public void clear_all() throws Exception {
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc());
-    esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc());
-
-    backendCleanup.clearAll();
-
-    assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isEqualTo(0);
-    assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isEqualTo(0);
-
-    assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(0);
-    assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(0);
-    assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(0);
-    assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0);
-  }
-
-  @Test
-  public void reset_data() throws Exception {
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc());
-    esTester.putDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, new ViewDoc().setUuid("CDEF").setProjects(newArrayList("DEFG")));
-    esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc());
-
-    backendCleanup.resetData();
-
-    assertThat(dbTester.countRowsOfTable("projects")).isZero();
-    assertThat(dbTester.countRowsOfTable("snapshots")).isZero();
-    assertThat(dbTester.countRowsOfTable("properties")).isZero();
-    assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isZero();
-    assertThat(esTester.countDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW)).isZero();
-
-    // Rules should not be removed
-    assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(1);
-    assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isEqualTo(1);
-  }
-
-  private static RuleDoc newRuleDoc() {
-    return new RuleDoc().setKey(RuleTesting.XOO_X1.toString()).setRepository(RuleTesting.XOO_X1.repository());
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupTest.java
new file mode 100644 (file)
index 0000000..de33e8a
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.platform;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.config.MapSettings;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.db.rule.RuleTesting;
+import org.sonar.server.component.es.ProjectMeasuresDoc;
+import org.sonar.server.component.es.ProjectMeasuresIndexDefinition;
+import org.sonar.server.es.EsTester;
+import org.sonar.server.issue.IssueTesting;
+import org.sonar.server.issue.index.IssueIndexDefinition;
+import org.sonar.server.rule.index.RuleDoc;
+import org.sonar.server.rule.index.RuleIndexDefinition;
+import org.sonar.server.view.index.ViewDoc;
+import org.sonar.server.view.index.ViewIndexDefinition;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class BackendCleanupTest {
+
+  @Rule
+  public EsTester esTester = new EsTester(
+    new RuleIndexDefinition(new MapSettings()),
+    new IssueIndexDefinition(new MapSettings()),
+    new ViewIndexDefinition(new MapSettings()),
+    new ProjectMeasuresIndexDefinition(new MapSettings()));
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  BackendCleanup backendCleanup = new BackendCleanup(esTester.client(), dbTester.myBatis());
+
+  @Test
+  public void clear_db() {
+    dbTester.prepareDbUnit(getClass(), "shared.xml");
+
+    backendCleanup.clearDb();
+
+    assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(0);
+    assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(0);
+    assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(0);
+    assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0);
+  }
+
+  @Test
+  public void clear_indexes() throws Exception {
+    esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc());
+    esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc());
+
+    backendCleanup.clearIndexes();
+
+    assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isEqualTo(0);
+  }
+
+  @Test
+  public void clear_all() throws Exception {
+    dbTester.prepareDbUnit(getClass(), "shared.xml");
+    esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc());
+    esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc());
+
+    backendCleanup.clearAll();
+
+    assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isEqualTo(0);
+    assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isEqualTo(0);
+
+    assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(0);
+    assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(0);
+    assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(0);
+    assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0);
+  }
+
+  @Test
+  public void reset_data() throws Exception {
+    dbTester.prepareDbUnit(getClass(), "shared.xml");
+    esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc());
+    esTester.putDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, new ViewDoc().setUuid("CDEF").setProjects(newArrayList("DEFG")));
+    esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc());
+    esTester.putDocuments(ProjectMeasuresIndexDefinition.INDEX_PROJECT_MEASURES, ProjectMeasuresIndexDefinition.TYPE_PROJECT_MEASURES, new ProjectMeasuresDoc()
+      .setId("PROJECT")
+      .setKey("Key")
+      .setName("Name"));
+
+    backendCleanup.resetData();
+
+    assertThat(dbTester.countRowsOfTable("projects")).isZero();
+    assertThat(dbTester.countRowsOfTable("snapshots")).isZero();
+    assertThat(dbTester.countRowsOfTable("properties")).isZero();
+    assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isZero();
+    assertThat(esTester.countDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW)).isZero();
+    assertThat(esTester.countDocuments(ProjectMeasuresIndexDefinition.INDEX_PROJECT_MEASURES, ProjectMeasuresIndexDefinition.TYPE_PROJECT_MEASURES)).isZero();
+
+    // Rules should not be removed
+    assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(1);
+    assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isEqualTo(1);
+  }
+
+  private static RuleDoc newRuleDoc() {
+    return new RuleDoc().setKey(RuleTesting.XOO_X1.toString()).setRepository(RuleTesting.XOO_X1.repository());
+  }
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml
deleted file mode 100644 (file)
index c34799a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<dataset>
-
-  <projects uuid="JKLM"
-            uuid_path="NOT_USED"
-            root_uuid="JKLM"
-            project_uuid="JKLM"
-            module_uuid="[null]"
-            module_uuid_path="."
-            enabled="[true]"
-            path="[null]"
-            id="100"
-            scope="PRJ"
-            qualifier="TRK"
-            kee="org.struts:struts"
-            name="Struts"/>
-
-  <snapshots id="100"
-             uuid="u100"
-             component_uuid="JKLM"
-             status="P"
-             islast="[true]"
-             purge_status="[null]"
-             version="[null]"
-  />
-
-  <rules tags="[null]"
-         system_tags="[null]"
-         id="1"
-         plugin_rule_key="NewRuleKey"
-         plugin_name="plugin"
-         name="new name"
-         description="new description"
-         status="DEPRECATED"
-         plugin_config_key="NewConfigKey"
-         priority="0"
-         is_template="[true]"
-         language="dart"
-         template_id="3"
-         note_data="[null]"
-         note_user_login="[null]"
-         note_created_at="[null]"
-         note_updated_at="[null]"
-         remediation_function="LINEAR"
-         def_remediation_function="LINEAR_OFFSET"
-         remediation_gap_mult="1h"
-         def_remediation_gap_mult="5d"
-         remediation_base_effort="5min"
-         def_remediation_base_effort="10h"
-         gap_description="squid.S115.effortToFix"
-         description_format="MARKDOWN"
-         created_at="150000"
-         updated_at="150000"
-  />
-
-  <properties id="1"
-              prop_key="sonar.profile.java"
-              resource_id="1"
-              user_id="[null]"
-              is_empty="[true]"
-              text_value="Sonar Way"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupTest/shared.xml
new file mode 100644 (file)
index 0000000..c34799a
--- /dev/null
@@ -0,0 +1,62 @@
+<dataset>
+
+  <projects uuid="JKLM"
+            uuid_path="NOT_USED"
+            root_uuid="JKLM"
+            project_uuid="JKLM"
+            module_uuid="[null]"
+            module_uuid_path="."
+            enabled="[true]"
+            path="[null]"
+            id="100"
+            scope="PRJ"
+            qualifier="TRK"
+            kee="org.struts:struts"
+            name="Struts"/>
+
+  <snapshots id="100"
+             uuid="u100"
+             component_uuid="JKLM"
+             status="P"
+             islast="[true]"
+             purge_status="[null]"
+             version="[null]"
+  />
+
+  <rules tags="[null]"
+         system_tags="[null]"
+         id="1"
+         plugin_rule_key="NewRuleKey"
+         plugin_name="plugin"
+         name="new name"
+         description="new description"
+         status="DEPRECATED"
+         plugin_config_key="NewConfigKey"
+         priority="0"
+         is_template="[true]"
+         language="dart"
+         template_id="3"
+         note_data="[null]"
+         note_user_login="[null]"
+         note_created_at="[null]"
+         note_updated_at="[null]"
+         remediation_function="LINEAR"
+         def_remediation_function="LINEAR_OFFSET"
+         remediation_gap_mult="1h"
+         def_remediation_gap_mult="5d"
+         remediation_base_effort="5min"
+         def_remediation_base_effort="10h"
+         gap_description="squid.S115.effortToFix"
+         description_format="MARKDOWN"
+         created_at="150000"
+         updated_at="150000"
+  />
+
+  <properties id="1"
+              prop_key="sonar.profile.java"
+              resource_id="1"
+              user_id="[null]"
+              is_empty="[true]"
+              text_value="Sonar Way"/>
+
+</dataset>
index b4f0d23f6e1e35a5ea78dfc5e81b6c746045bab2..8ae6cb22d8e45ebb3348be34f7bf3e1e997a1c6c 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.sonarqube.ws.client.component;
 
+import javax.annotation.CheckForNull;
+
 import static com.google.common.base.Preconditions.checkArgument;
 
 public class SearchProjectsRequest {
@@ -36,6 +38,7 @@ public class SearchProjectsRequest {
     this.filter = builder.filter;
   }
 
+  @CheckForNull
   public String getFilter() {
     return filter;
   }
@@ -83,12 +86,7 @@ public class SearchProjectsRequest {
       if (pageSize == null) {
         pageSize = DEFAULT_PAGE_SIZE;
       }
-      if (filter == null) {
-        filter = "";
-      }
-
       checkArgument(pageSize <= MAX_PAGE_SIZE, "Page size must not be greater than %s", MAX_PAGE_SIZE);
-
       return new SearchProjectsRequest(this);
     }
   }