]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 29 May 2013 20:02:23 +0000 (22:02 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 29 May 2013 20:02:23 +0000 (22:02 +0200)
25 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingResult.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/security/ApplyProjectRolesDecorator.java
plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java
sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java
sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataCache.java
sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataPersister.java
sonar-batch/src/main/java/org/sonar/batch/index/SnapshotCache.java
sonar-batch/src/test/java/org/sonar/batch/index/ComponentDataPersisterTest.java
sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanMapper.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeConfiguration.java
sonar-core/src/main/java/org/sonar/core/source/jdbc/SnapshotDataDao.java
sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java
sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java
sonar-plugin-api/src/main/java/org/sonar/api/component/Component.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueFinder.java
sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeUtils.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/TimeUtilsTest.java [new file with mode: 0644]
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/DefaultIssueClient.java
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueJsonParser.java [new file with mode: 0644]
sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueParser.java [deleted file]
sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueJsonParserTest.java [new file with mode: 0644]
sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueParserTest.java [deleted file]
sonar-ws-client/src/test/java/org/sonar/wsclient/user/UserQueryTest.java

index 08e8c39b51ca37f452ae89cb21868f8ce846939b..fda029a616e89ea4f5e1dba359e914bc714742bf 100644 (file)
@@ -28,11 +28,11 @@ import org.sonar.core.issue.DefaultIssue;
 import org.sonar.core.issue.db.IssueDto;
 
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.IdentityHashMap;
+import java.util.Set;
 
 class IssueTrackingResult {
-  private final HashSet<IssueDto> unmatched = Sets.newHashSet();
+  private final Set<IssueDto> unmatched = Sets.newHashSet();
   private final Multimap<RuleKey, IssueDto> unmatchedByRule = LinkedHashMultimap.create();
   private final IdentityHashMap<DefaultIssue, IssueDto> matched = Maps.newIdentityHashMap();
 
index 20186ee91ff146a3603eb0b847eb91aa2e9f768d..2d8e5a391209069f3b04cd6a368ad525131828cc 100644 (file)
@@ -34,8 +34,8 @@ import java.util.Set;
 @DryRunIncompatible
 public class ApplyProjectRolesDecorator implements Decorator {
 
+  private static final Set<String> QUALIFIERS = ImmutableSet.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.SUBVIEW);
   private final ResourcePermissions resourcePermissions;
-  private final Set<String> QUALIFIERS = ImmutableSet.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.SUBVIEW);
 
   public ApplyProjectRolesDecorator(ResourcePermissions resourcePermissions) {
     this.resourcePermissions = resourcePermissions;
index 5009626fd1371973f3902610b40aa153a506c832..afafdb93a2a711fa2f4df7ceb7aa37e2b3905d8c 100644 (file)
@@ -22,9 +22,6 @@ package org.sonar.plugins.dbcleaner;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-import org.sonar.api.PropertyType;
 import org.sonar.api.config.Settings;
 import org.sonar.api.resources.Scopes;
 import org.sonar.api.utils.TimeUtils;
@@ -91,9 +88,9 @@ public class DefaultPurgeTask implements PurgeTask {
   }
 
   private PurgeConfiguration newConf(long resourceId) {
-    String[] scopes = new String[] {Scopes.FILE};
+    String[] scopes = new String[]{Scopes.FILE};
     if (settings.getBoolean(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY)) {
-      scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE};
+      scopes = new String[]{Scopes.DIRECTORY, Scopes.FILE};
     }
     return new PurgeConfiguration(resourceId, scopes, settings.getInt(DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES));
   }
index 606ec6a8a14229c3f466e98c4999b0a30707c132..dfc5ecf1b827e9a887b4e78e4d15a32fb468230e 100644 (file)
@@ -84,10 +84,10 @@ public class PastSnapshotFinder implements BatchExtension {
         break;
       case 4:
         defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4;
-        break; // NOSONAR false-positive: constant 4 is the same than 5 (empty string)
+        break;
       case 5:
         defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5;
-        break; // NOSONAR false-positive: constant 5 is the same than 4 (empty string)
+        break;
     }
     return conf.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + index, defaultValue);
   }
index a341f7337f0abb3b48dda8e3d2df59728cf4e676..02c0264c94644507b0b786f752ecd66d7b6d265b 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Qualifiers;
 
 import javax.persistence.Query;
-
 import java.util.Date;
 import java.util.List;
 
@@ -48,16 +47,16 @@ public class TimeMachineConfiguration implements BatchExtension {
   private DatabaseSession session;
 
   public TimeMachineConfiguration(DatabaseSession session, Project project, Settings settings,
-      PastSnapshotFinder pastSnapshotFinder) {
+                                  PastSnapshotFinder pastSnapshotFinder) {
     this.session = session;
     this.project = project;
     this.settings = settings;
     initPastSnapshots(pastSnapshotFinder, getRootProject(project).getQualifier());
   }
 
-  private Project getRootProject(Project project){
+  private Project getRootProject(Project project) {
     if (!project.isRoot()) {
-     return getRootProject(project.getRoot());
+      return getRootProject(project.getRoot());
     }
     return project;
   }
@@ -79,7 +78,7 @@ public class TimeMachineConfiguration implements BatchExtension {
 
   private Snapshot buildProjectSnapshot() {
     Query query = session
-        .createNativeQuery("select p.id from projects p where p.kee=:resourceKey and p.qualifier<>:lib and p.enabled=:enabled");
+      .createNativeQuery("select p.id from projects p where p.kee=:resourceKey and p.qualifier<>:lib and p.enabled=:enabled");
     query.setParameter("resourceKey", project.getKey());
     query.setParameter("lib", Qualifiers.LIBRARY);
     query.setParameter("enabled", Boolean.TRUE);
index f7b2b0f776affc1d97590b1c0044c19ba85362bd..c4cda7dc06e9ad7d6a208b5b3b78c68c6eef8b2e 100644 (file)
@@ -43,8 +43,8 @@ public class ComponentDataCache implements BatchComponent {
 
   public String getStringData(String componentKey, String dataType) {
     Data data = (Data) cache.get(componentKey, dataType);
-    return data==null ? null : ((StringData)data).data();
-    }
+    return data == null ? null : ((StringData) data).data();
+  }
 
   public <D extends Data> Iterable<Cache.Entry<D>> entries(String componentKey) {
     return cache.entries(componentKey);
index d0ef14aebeb61a895e316a657635029b98276ef8..7d7532b250394366ea273753ba85f63a0f8f8272 100644 (file)
@@ -20,6 +20,8 @@
 package org.sonar.batch.index;
 
 import org.sonar.api.database.model.Snapshot;
+import org.sonar.core.persistence.BatchSession;
+import org.sonar.core.persistence.MyBatis;
 import org.sonar.core.source.jdbc.SnapshotDataDao;
 import org.sonar.core.source.jdbc.SnapshotDataDto;
 
@@ -29,15 +31,19 @@ public class ComponentDataPersister implements ScanPersister {
   private final ComponentDataCache data;
   private final SnapshotCache snapshots;
   private final SnapshotDataDao dao;
+  private final MyBatis mybatis;
 
-  public ComponentDataPersister(ComponentDataCache data, SnapshotCache snapshots, SnapshotDataDao dao) {
+  public ComponentDataPersister(ComponentDataCache data, SnapshotCache snapshots,
+                                SnapshotDataDao dao, MyBatis mybatis) {
     this.data = data;
     this.snapshots = snapshots;
     this.dao = dao;
+    this.mybatis = mybatis;
   }
 
   @Override
   public void persist() {
+    BatchSession session = mybatis.openBatchSession();
     for (Map.Entry<String, Snapshot> componentEntry : snapshots.snapshots()) {
       String componentKey = componentEntry.getKey();
       Snapshot snapshot = componentEntry.getValue();
@@ -48,11 +54,10 @@ public class ComponentDataPersister implements ScanPersister {
           dto.setResourceId(snapshot.getResourceId());
           dto.setDataType(dataEntry.key());
           dto.setData(dataEntry.value().writeString());
-
-          // TODO bulk insert
-          dao.insert(dto);
+          dao.insert(session, dto);
         }
       }
     }
+    session.commit();
   }
 }
index 0fd37e1e1ed9e97ec5af88078a4721fbf5f7a316..e758b0420bbff2cc72e61cfffcc66f49acd5e461 100644 (file)
@@ -24,7 +24,6 @@ import com.google.common.collect.Maps;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.database.model.Snapshot;
 
-import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
index 27fb9db5e349471d783be2f7ef8ff8d5adeb229a..3910b0ca85b1d27a0154ae793cd126ae3a12cdfe 100644 (file)
@@ -56,7 +56,7 @@ public class ComponentDataPersisterTest extends AbstractDaoTestCase {
     data.setStringData("org/struts/Other.java", "SYMBOL", "unregistered component, should not be persisted");
 
     SnapshotDataDao dataDao = new SnapshotDataDao(getMyBatis());
-    ComponentDataPersister persister = new ComponentDataPersister(data, snapshots, dataDao);
+    ComponentDataPersister persister = new ComponentDataPersister(data, snapshots, dataDao, getMyBatis());
     persister.persist();
 
     checkTables("should_persist_component_data", new String[]{"id", "created_at", "updated_at"}, "snapshot_data");
index 8ca67acbaaaa0238ae995171e8fe512365eccb26..4ea956c9a9a5f907dc53b3c10471a2298f40e373 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.core.issue.db;
 
 import org.apache.ibatis.annotations.Param;
 
-import java.util.Collection;
 import java.util.List;
 
 /**
@@ -36,11 +35,11 @@ public interface ActionPlanMapper {
 
   void delete(@Param("key") String key);
 
-  List<ActionPlanDto> findByKeys(@Param("keys") List <List<String>> keys);
+  List<ActionPlanDto> findByKeys(@Param("keys") List<List<String>> keys);
 
   ActionPlanDto findByKey(@Param("key") String key);
 
   List<ActionPlanDto> findOpenByProjectId(@Param("projectId") Long projectId);
 
-  List<ActionPlanDto> findByNameAndProjectId(@Param("name")String name, @Param("projectId") Long projectId);
+  List<ActionPlanDto> findByNameAndProjectId(@Param("name") String name, @Param("projectId") Long projectId);
 }
index 6f00448d4d95b7281ba5e8d2225bb45ef23bb248..8a9b997f7f712f4bda4f865b252103ae015975cb 100644 (file)
@@ -27,8 +27,6 @@ import java.util.Date;
 
 public class PurgeConfiguration {
 
-  private static final int ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
-
   private final long rootProjectId;
   private final String[] scopesWithoutHistoricalData;
   private final int maxAgeInDaysOfClosedIssues;
index 370f6401938f79886db9dd5a049bda0b75144988..7b99f9bbcdf083d77c053b19fb9611d4c6e3ac42 100644 (file)
@@ -40,9 +40,7 @@ public class SnapshotDataDao implements BatchComponent, ServerComponent {
   }
 
   public Collection<SnapshotDataDto> selectSnapshotData(long snapshotId, List<String> dataTypes) {
-
     SqlSession session = mybatis.openSession();
-
     try {
       SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
       return mapper.selectSnapshotData(snapshotId, dataTypes);
@@ -52,16 +50,18 @@ public class SnapshotDataDao implements BatchComponent, ServerComponent {
     }
   }
 
-  public void insert(SnapshotDataDto snapshotData) {
-
-    SqlSession session = mybatis.openBatchSession();
-
+  void insert(SnapshotDataDto snapshotData) {
+    SqlSession session = mybatis.openSession();
     try {
-      SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
-      mapper.insert(snapshotData);
+      insert(session, snapshotData);
       session.commit();
     } finally {
       MyBatis.closeQuietly(session);
     }
   }
+
+  public void insert(SqlSession session, SnapshotDataDto snapshotData) {
+    SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
+    mapper.insert(snapshotData);
+  }
 }
index 3801d70d743e22ead804cfd857b7aca8568c7dd6..4fb4cabc6240e6e7315701ce603248244c828086 100644 (file)
@@ -93,4 +93,23 @@ public class DefaultIssueTest {
     issue.setMessage(null);
     assertThat(issue.message()).isNull();
   }
+
+  @Test
+  public void test_nullable_fields() throws Exception {
+    issue.setEffortToFix(null).setSeverity(null).setLine(null);
+    assertThat(issue.effortToFix()).isNull();
+    assertThat(issue.severity()).isNull();
+    assertThat(issue.line()).isNull();
+  }
+
+  @Test
+  public void test_equals_and_hashCode() throws Exception {
+    DefaultIssue a1 = new DefaultIssue().setKey("AAA");
+    DefaultIssue a2 = new DefaultIssue().setKey("AAA");
+    DefaultIssue b = new DefaultIssue().setKey("BBB");
+    assertThat(a1).isEqualTo(a1);
+    assertThat(a1).isEqualTo(a2);
+    assertThat(a1).isNotEqualTo(b);
+    assertThat(a1.hashCode()).isEqualTo(a1.hashCode());
+  }
 }
index ff05e226da80a5d854102a3fc1fad278178dcc2f..d44eef24e5a6dad5b5dc363bdd28b6f00399d7ba 100644 (file)
@@ -99,7 +99,7 @@ public class SourceCode {
   public static class StringCodeLoader extends CodeLoader {
     public static final String DEFAULT_NAME = "CODE_LOADED_FROM_STRING";
 
-    private String source_code;
+    private String sourceCode;
 
     private String name;
 
@@ -108,13 +108,13 @@ public class SourceCode {
     }
 
     public StringCodeLoader(String code, String name) {
-      this.source_code = code;
+      this.sourceCode = code;
       this.name = name;
     }
 
     @Override
     public Reader getReader() {
-      return new StringReader(source_code);
+      return new StringReader(sourceCode);
     }
 
     @Override
index 5b21a35f399abba4e3c0d2002adae6dc0d04376a..b658be87d190faa696c278ff9f9b060bddc0a4dd 100644 (file)
  */
 package org.sonar.api.component;
 
-public interface Component<CHILD extends Component> {
+public interface Component<C extends Component> {
   String key();
+
   String name();
+
   String longName();
+
   String qualifier();
 }
index 0260bffcd7d51a420d98f1cc87f97e113c46c0f9..85241153f7d0d4d996a9c8c160aadc6ab59d7bb5 100644 (file)
  * 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.api.issue;
 
 import org.sonar.api.ServerComponent;
-import org.sonar.api.component.Component;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.utils.Paging;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.List;
 
 /**
  * Search for issues. This component can be used only by server-side extensions. Batch extensions should
index 56b99f0cb565e428fb07ecf06736dcc0bc84e644..3a4e856e3e24056e3558533e7ff23388d6465a07 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.commons.lang.builder.ToStringStyle;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import java.io.Serializable;
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -34,13 +33,13 @@ import java.util.Map;
  * This class represents a notification that will be delivered to users. This is a general concept and it has no
  * knowledge of the possible ways to be delivered (see {@link NotificationChannel}) or of the users who should
  * receive it (see {@link NotificationDispatcher}).
- * </p> 
+ * </p>
  * <p>
- * When creating a new notification, it is strongly advised to give a default message that can be  used by channels 
- * that don't want to specifically format messages for different notification types. You can use 
+ * When creating a new notification, it is strongly advised to give a default message that can be  used by channels
+ * that don't want to specifically format messages for different notification types. You can use
  * {@link Notification#setDefaultMessage(String)} for that purpose.
  * </p>
- * 
+ *
  * @since 2.10
  */
 public class Notification implements Serializable {
@@ -55,7 +54,7 @@ public class Notification implements Serializable {
    * Create a new {@link Notification} of the given type.
    * </p>
    * Example: type = "new-violations"
-   * 
+   *
    * @param type the type of notification
    */
   public Notification(String type) {
@@ -64,7 +63,7 @@ public class Notification implements Serializable {
 
   /**
    * Returns the type of the notification
-   * 
+   *
    * @return the type
    */
   public String getType() {
@@ -73,14 +72,14 @@ public class Notification implements Serializable {
 
   /**
    * <p>
-   * When creating a new notification, it is strongly advised to give a default message that can be 
+   * When creating a new notification, it is strongly advised to give a default message that can be
    * used by channels that don't want to specifically format messages for different notification types.
    * </p>
    * <p>
-   * This method is equivalent to setting a value for the field {@link #DEFAULT_MESSAGE_KEY} with 
+   * This method is equivalent to setting a value for the field {@link #DEFAULT_MESSAGE_KEY} with
    * {@link #setFieldValue(String, String)}.
-   * </p> 
-   * 
+   * </p>
+   *
    * @since 3.5
    */
   public Notification setDefaultMessage(String value) {
@@ -101,7 +100,7 @@ public class Notification implements Serializable {
 
   /**
    * Adds a field (kind of property) to the notification
-   * 
+   *
    * @param field the name of the field (= the key)
    * @param value the value of the field
    * @return the notification itself
@@ -113,7 +112,7 @@ public class Notification implements Serializable {
 
   /**
    * Returns the value of a field.
-   * 
+   *
    * @param field the field
    * @return the value of the field
    */
index f425d3662e988c39dfdedff1c93a35e181be5bb4..952c05877960bc32e9367145c33409073a4ce704 100644 (file)
@@ -27,26 +27,33 @@ public final class TimeUtils {
   private TimeUtils() {
   }
 
+  /**
+   * Label for a duration, expressed in numbers of ms, seconds or minutes.
+   * <p/>
+   * Examples:
+   * <ul>
+   *   <li>10 -> "10ms"</li>
+   *   <li>100 -> "100ms"</li>
+   *   <li>10000 -> "10s"</li>
+   *   <li>100000 -> "1min 40s"</li>
+   * </ul>
+   */
   public static String formatDuration(long durationInMs) {
     if (durationInMs < 1000) {
       return String.format("%sms", durationInMs);
-    }
-    else {
+    } else {
       long sec = durationInMs / 1000;
       if (sec < 60) {
         return String.format("%ss", sec);
-      }
-      else {
+      } else {
         long min = sec / 60;
         long remainingSec = sec - (min * 60);
         if (remainingSec > 0) {
           return String.format("%smin %ss", min, remainingSec);
-        }
-        else {
+        } else {
           return String.format("%smin", min);
         }
       }
     }
   }
-
 }
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/TimeUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/TimeUtilsTest.java
new file mode 100644 (file)
index 0000000..308e926
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.api.utils;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class TimeUtilsTest {
+  @Test
+  public void formatDuration() throws Exception {
+    assertThat(TimeUtils.formatDuration(0)).isEqualTo("0ms");
+    assertThat(TimeUtils.formatDuration(100)).isEqualTo("100ms");
+    assertThat(TimeUtils.formatDuration(1000)).isEqualTo("1s");
+    assertThat(TimeUtils.formatDuration(10000)).isEqualTo("10s");
+    assertThat(TimeUtils.formatDuration(100000)).isEqualTo("1min 40s");
+    assertThat(TimeUtils.formatDuration(600000)).isEqualTo("10min");
+    assertThat(TimeUtils.formatDuration(1000000)).isEqualTo("16min 40s");
+    assertThat(TimeUtils.formatDuration(10000000)).isEqualTo("166min 40s");
+  }
+}
index ceef7fe98fcddcb580d7f875b4024cc2cca4146f..727a2e4c4097c0ea6b4289159ccc0476327faded 100644 (file)
@@ -35,14 +35,14 @@ import java.util.Map;
 public class DefaultIssueClient implements IssueClient {
 
   private final HttpRequestFactory requestFactory;
-  private final IssueParser parser;
+  private final IssueJsonParser parser;
 
   /**
    * For internal use. Use {@link org.sonar.wsclient.SonarClient} to get an instance.
    */
   public DefaultIssueClient(HttpRequestFactory requestFactory) {
     this.requestFactory = requestFactory;
-    this.parser = new IssueParser();
+    this.parser = new IssueJsonParser();
   }
 
   public Issues find(IssueQuery query) {
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueJsonParser.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueJsonParser.java
new file mode 100644 (file)
index 0000000..fc1b1fb
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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.wsclient.issue;
+
+import org.json.simple.JSONValue;
+import org.sonar.wsclient.component.Component;
+import org.sonar.wsclient.rule.Rule;
+import org.sonar.wsclient.unmarshallers.JsonUtils;
+import org.sonar.wsclient.user.User;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @since 3.6
+ */
+class IssueJsonParser {
+
+  Issues parseIssues(String json) {
+    Issues result = new Issues();
+    Map jsonRoot = (Map) JSONValue.parse(json);
+    List<Map> jsonIssues = (List) jsonRoot.get("issues");
+    if (jsonIssues != null) {
+      for (Map jsonIssue : jsonIssues) {
+        result.add(new Issue(jsonIssue));
+      }
+    }
+    parseRules(result, jsonRoot);
+    parseUsers(result, jsonRoot);
+    parseComponents(result, jsonRoot);
+    parseProjects(result, jsonRoot);
+    parsePaging(result, jsonRoot);
+    return result;
+  }
+
+  private void parsePaging(Issues result, Map jsonRoot) {
+    Map paging = (Map) jsonRoot.get("paging");
+    result.setPaging(new Paging(paging));
+    result.setMaxResultsReached(JsonUtils.getBoolean(jsonRoot, "maxResultsReached"));
+  }
+
+  private void parseProjects(Issues result, Map jsonRoot) {
+    List<Map> jsonProjects = (List) jsonRoot.get("projects");
+    if (jsonProjects != null) {
+      for (Map jsonProject : jsonProjects) {
+        result.addProject(new Component(jsonProject));
+      }
+    }
+  }
+
+  private void parseComponents(Issues result, Map jsonRoot) {
+    List<Map> jsonComponents = (List) jsonRoot.get("components");
+    if (jsonComponents != null) {
+      for (Map jsonComponent : jsonComponents) {
+        result.addComponent(new Component(jsonComponent));
+      }
+    }
+  }
+
+  private void parseUsers(Issues result, Map jsonRoot) {
+    List<Map> jsonUsers = (List) jsonRoot.get("users");
+    if (jsonUsers != null) {
+      for (Map jsonUser : jsonUsers) {
+        result.add(new User(jsonUser));
+      }
+    }
+  }
+
+  private void parseRules(Issues result, Map jsonRoot) {
+    List<Map> jsonRules = (List) jsonRoot.get("rules");
+    if (jsonRules != null) {
+      for (Map jsonRule : jsonRules) {
+        result.add(new Rule(jsonRule));
+      }
+    }
+  }
+
+  List<String> parseTransitions(String json) {
+    List<String> transitions = new ArrayList<String>();
+    Map jRoot = (Map) JSONValue.parse(json);
+    List<String> jTransitions = (List) jRoot.get("transitions");
+    for (String jTransition : jTransitions) {
+      transitions.add(jTransition);
+    }
+    return transitions;
+  }
+}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueParser.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueParser.java
deleted file mode 100644 (file)
index 855ad83..0000000
+++ /dev/null
@@ -1,90 +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.wsclient.issue;
-
-import org.json.simple.JSONValue;
-import org.sonar.wsclient.component.Component;
-import org.sonar.wsclient.rule.Rule;
-import org.sonar.wsclient.unmarshallers.JsonUtils;
-import org.sonar.wsclient.user.User;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @since 3.6
- */
-class IssueParser {
-
-  Issues parseIssues(String json) {
-    Issues result = new Issues();
-    Map jsonRoot = (Map) JSONValue.parse(json);
-    List<Map> jsonIssues = (List) jsonRoot.get("issues");
-    if (jsonIssues != null) {
-      for (Map jsonIssue : jsonIssues) {
-        result.add(new Issue(jsonIssue));
-      }
-    }
-
-    List<Map> jsonRules = (List) jsonRoot.get("rules");
-    if (jsonRules != null) {
-      for (Map jsonRule : jsonRules) {
-        result.add(new Rule(jsonRule));
-      }
-    }
-
-    List<Map> jsonUsers = (List) jsonRoot.get("users");
-    if (jsonUsers != null) {
-      for (Map jsonUser : jsonUsers) {
-        result.add(new User(jsonUser));
-      }
-    }
-
-    List<Map> jsonComponents = (List) jsonRoot.get("components");
-    if (jsonComponents != null) {
-      for (Map jsonComponent : jsonComponents) {
-        result.addComponent(new Component(jsonComponent));
-      }
-    }
-
-    List<Map> jsonProjects = (List) jsonRoot.get("projects");
-    if (jsonProjects != null) {
-      for (Map jsonProject : jsonProjects) {
-        result.addProject(new Component(jsonProject));
-      }
-    }
-
-    Map paging = (Map) jsonRoot.get("paging");
-    result.setPaging(new Paging(paging));
-    result.setMaxResultsReached(JsonUtils.getBoolean(jsonRoot, "maxResultsReached"));
-    return result;
-  }
-
-  List<String> parseTransitions(String json) {
-    List<String> transitions = new ArrayList<String>();
-    Map jRoot = (Map) JSONValue.parse(json);
-    List<String> jTransitions = (List) jRoot.get("transitions");
-    for (String jTransition : jTransitions) {
-      transitions.add(jTransition);
-    }
-    return transitions;
-  }
-}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueJsonParserTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueJsonParserTest.java
new file mode 100644 (file)
index 0000000..82c71f7
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * 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.wsclient.issue;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+import org.sonar.wsclient.component.Component;
+import org.sonar.wsclient.user.User;
+
+import java.util.List;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class IssueJsonParserTest {
+  @Test
+  public void test_GET_search() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/search.json"));
+    Issues issues = new IssueJsonParser().parseIssues(json);
+    assertThat(issues).isNotNull();
+    List<Issue> list = issues.list();
+    assertThat(list).hasSize(2);
+    Issue first = list.get(0);
+    assertThat(first.key()).isEqualTo("ABCDE");
+    assertThat(first.componentKey()).isEqualTo("Action.java");
+    assertThat(first.projectKey()).isEqualTo("struts");
+    assertThat(first.ruleKey()).isEqualTo("squid:CycleBetweenPackages");
+    assertThat(first.severity()).isEqualTo("CRITICAL");
+    assertThat(first.line()).isEqualTo(10);
+    assertThat(first.resolution()).isEqualTo("FIXED");
+    assertThat(first.status()).isEqualTo("OPEN");
+    assertThat(first.assignee()).isEqualTo("karadoc");
+    assertThat(first.message()).isEqualTo("the message");
+    assertThat(first.effortToFix()).isEqualTo(4.2);
+    assertThat(first.reporter()).isEqualTo("perceval");
+    assertThat(first.creationDate()).isNotNull();
+    assertThat(first.updateDate()).isNotNull();
+    assertThat(first.closeDate()).isNotNull();
+    assertThat(first.attribute("JIRA")).isEqualTo("FOO-1234");
+    assertThat(first.attribute("OTHER")).isNull();
+    assertThat(first.attributes()).hasSize(1);
+    assertThat(first.comments()).isEmpty();
+
+    Issue second = list.get(1);
+    assertThat(second.key()).isEqualTo("FGHIJ");
+    assertThat(second.line()).isNull();
+    assertThat(second.effortToFix()).isNull();
+    assertThat(second.reporter()).isNull();
+    assertThat(second.attribute("JIRA")).isNull();
+    assertThat(second.attributes()).isEmpty();
+    assertThat(second.comments()).isEmpty();
+
+    assertThat(issues.rules()).hasSize(2);
+    assertThat(issues.rule(first).key()).isEqualTo("squid:CycleBetweenPackages");
+    assertThat(issues.rule(first).name()).isEqualTo("Avoid cycle between java packages");
+    assertThat(issues.rule(first).description()).contains("When several packages");
+
+    assertThat(issues.paging()).isNotNull();
+    Paging paging = issues.paging();
+    assertThat(paging.pageIndex()).isEqualTo(1);
+    assertThat(paging.pageSize()).isEqualTo(100);
+    assertThat(paging.pages()).isEqualTo(1);
+    assertThat(paging.total()).isEqualTo(2);
+
+    assertThat(issues.maxResultsReached()).isTrue();
+  }
+
+  @Test
+  public void test_GET_empty_search() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/empty.json"));
+    Issues issues = new IssueJsonParser().parseIssues(json);
+    assertThat(issues).isNotNull();
+    assertThat(issues.list()).isEmpty();
+    assertThat(issues.rules()).isEmpty();
+    assertThat(issues.maxResultsReached()).isFalse();
+  }
+
+  @Test
+  public void test_GET_transitions() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/getTransitions.json"));
+    List<String> transitions = new IssueJsonParser().parseTransitions(json);
+
+    assertThat(transitions).isNotNull();
+    assertThat(transitions).hasSize(2);
+    assertThat(transitions).containsOnly("resolve", "falsepositive");
+  }
+
+  @Test
+  public void should_parse_comments() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-comments.json"));
+    Issues issues = new IssueJsonParser().parseIssues(json);
+    assertThat(issues.size()).isEqualTo(1);
+
+    Issue issue = issues.list().get(0);
+    assertThat(issue.comments()).hasSize(2);
+
+    IssueComment firstComment = issue.comments().get(0);
+    assertThat(firstComment.key()).isEqualTo("COMMENT-1");
+    assertThat(firstComment.login()).isEqualTo("morgan");
+    assertThat(firstComment.htmlText()).isEqualTo("the first comment");
+    assertThat(firstComment.createdAt().getDate()).isEqualTo(18);
+
+    IssueComment secondComment = issue.comments().get(1);
+    assertThat(secondComment.key()).isEqualTo("COMMENT-2");
+    assertThat(secondComment.login()).isEqualTo("arthur");
+    assertThat(secondComment.htmlText()).isEqualTo("the second comment");
+    assertThat(secondComment.createdAt().getDate()).isEqualTo(19);
+  }
+
+  @Test
+  public void should_parse_users() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-users.json"));
+    Issues issues = new IssueJsonParser().parseIssues(json);
+
+    assertThat(issues.users()).hasSize(2);
+
+    User morgan = issues.user("morgan");
+    assertThat(morgan.login()).isEqualTo("morgan");
+    assertThat(morgan.name()).isEqualTo("Morgan");
+    assertThat(morgan.active()).isTrue();
+    assertThat(morgan.email()).isEqualTo("mor@gan.bzh");
+
+    User arthur = issues.user("arthur");
+    assertThat(arthur.login()).isEqualTo("arthur");
+    assertThat(arthur.name()).isEqualTo("Arthur");
+    assertThat(arthur.active()).isFalse();
+    assertThat(arthur.email()).isEqualTo("ar@thur.bzh");
+  }
+
+  @Test
+  public void should_parse_components() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-components.json"));
+    Issues issues = new IssueJsonParser().parseIssues(json);
+
+    assertThat(issues.components()).hasSize(1);
+
+    Component component = issues.component(issues.list().get(0));
+    assertThat(component.key()).isEqualTo("struts:Action.java");
+    assertThat(component.qualifier()).isEqualTo("CLA");
+    assertThat(component.name()).isEqualTo("Action");
+    assertThat(component.longName()).isEqualTo("org.struts.Action");
+  }
+
+  @Test
+  public void should_parse_projects() throws Exception {
+    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-projects.json"));
+    Issues issues = new IssueJsonParser().parseIssues(json);
+
+    assertThat(issues.projects()).hasSize(1);
+
+    Component component = issues.project(issues.list().get(0));
+    assertThat(component.key()).isEqualTo("struts");
+    assertThat(component.qualifier()).isEqualTo("TRK");
+    assertThat(component.name()).isEqualTo("Struts");
+    assertThat(component.longName()).isEqualTo("org.struts");
+  }
+}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueParserTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueParserTest.java
deleted file mode 100644 (file)
index 7f0a76e..0000000
+++ /dev/null
@@ -1,173 +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.wsclient.issue;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.sonar.wsclient.component.Component;
-import org.sonar.wsclient.user.User;
-
-import java.util.List;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class IssueParserTest {
-  @Test
-  public void test_GET_search() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/search.json"));
-    Issues issues = new IssueParser().parseIssues(json);
-    assertThat(issues).isNotNull();
-    List<Issue> list = issues.list();
-    assertThat(list).hasSize(2);
-    Issue first = list.get(0);
-    assertThat(first.key()).isEqualTo("ABCDE");
-    assertThat(first.componentKey()).isEqualTo("Action.java");
-    assertThat(first.projectKey()).isEqualTo("struts");
-    assertThat(first.ruleKey()).isEqualTo("squid:CycleBetweenPackages");
-    assertThat(first.severity()).isEqualTo("CRITICAL");
-    assertThat(first.line()).isEqualTo(10);
-    assertThat(first.resolution()).isEqualTo("FIXED");
-    assertThat(first.status()).isEqualTo("OPEN");
-    assertThat(first.assignee()).isEqualTo("karadoc");
-    assertThat(first.message()).isEqualTo("the message");
-    assertThat(first.effortToFix()).isEqualTo(4.2);
-    assertThat(first.reporter()).isEqualTo("perceval");
-    assertThat(first.creationDate()).isNotNull();
-    assertThat(first.updateDate()).isNotNull();
-    assertThat(first.closeDate()).isNotNull();
-    assertThat(first.attribute("JIRA")).isEqualTo("FOO-1234");
-    assertThat(first.attribute("OTHER")).isNull();
-    assertThat(first.attributes()).hasSize(1);
-    assertThat(first.comments()).isEmpty();
-
-    Issue second = list.get(1);
-    assertThat(second.key()).isEqualTo("FGHIJ");
-    assertThat(second.line()).isNull();
-    assertThat(second.effortToFix()).isNull();
-    assertThat(second.reporter()).isNull();
-    assertThat(second.attribute("JIRA")).isNull();
-    assertThat(second.attributes()).isEmpty();
-    assertThat(second.comments()).isEmpty();
-
-    assertThat(issues.rules()).hasSize(2);
-    assertThat(issues.rule(first).key()).isEqualTo("squid:CycleBetweenPackages");
-    assertThat(issues.rule(first).name()).isEqualTo("Avoid cycle between java packages");
-    assertThat(issues.rule(first).description()).contains("When several packages");
-
-    assertThat(issues.paging()).isNotNull();
-    Paging paging = issues.paging();
-    assertThat(paging.pageIndex()).isEqualTo(1);
-    assertThat(paging.pageSize()).isEqualTo(100);
-    assertThat(paging.pages()).isEqualTo(1);
-    assertThat(paging.total()).isEqualTo(2);
-
-    assertThat(issues.maxResultsReached()).isTrue();
-  }
-
-  @Test
-  public void test_GET_empty_search() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/empty.json"));
-    Issues issues = new IssueParser().parseIssues(json);
-    assertThat(issues).isNotNull();
-    assertThat(issues.list()).isEmpty();
-    assertThat(issues.rules()).isEmpty();
-    assertThat(issues.maxResultsReached()).isFalse();
-  }
-
-  @Test
-  public void test_GET_transitions() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/getTransitions.json"));
-    List<String> transitions = new IssueParser().parseTransitions(json);
-
-    assertThat(transitions).isNotNull();
-    assertThat(transitions).hasSize(2);
-    assertThat(transitions).containsOnly("resolve", "falsepositive");
-  }
-
-  @Test
-  public void should_parse_comments() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-comments.json"));
-    Issues issues = new IssueParser().parseIssues(json);
-    assertThat(issues.size()).isEqualTo(1);
-
-    Issue issue = issues.list().get(0);
-    assertThat(issue.comments()).hasSize(2);
-
-    IssueComment firstComment = issue.comments().get(0);
-    assertThat(firstComment.key()).isEqualTo("COMMENT-1");
-    assertThat(firstComment.login()).isEqualTo("morgan");
-    assertThat(firstComment.htmlText()).isEqualTo("the first comment");
-    assertThat(firstComment.createdAt().getDate()).isEqualTo(18);
-
-    IssueComment secondComment = issue.comments().get(1);
-    assertThat(secondComment.key()).isEqualTo("COMMENT-2");
-    assertThat(secondComment.login()).isEqualTo("arthur");
-    assertThat(secondComment.htmlText()).isEqualTo("the second comment");
-    assertThat(secondComment.createdAt().getDate()).isEqualTo(19);
-  }
-
-  @Test
-  public void should_parse_users() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-users.json"));
-    Issues issues = new IssueParser().parseIssues(json);
-
-    assertThat(issues.users()).hasSize(2);
-
-    User morgan = issues.user("morgan");
-    assertThat(morgan.login()).isEqualTo("morgan");
-    assertThat(morgan.name()).isEqualTo("Morgan");
-    assertThat(morgan.active()).isTrue();
-    assertThat(morgan.email()).isEqualTo("mor@gan.bzh");
-
-    User arthur = issues.user("arthur");
-    assertThat(arthur.login()).isEqualTo("arthur");
-    assertThat(arthur.name()).isEqualTo("Arthur");
-    assertThat(arthur.active()).isFalse();
-    assertThat(arthur.email()).isEqualTo("ar@thur.bzh");
-  }
-
-  @Test
-  public void should_parse_components() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-components.json"));
-    Issues issues = new IssueParser().parseIssues(json);
-
-    assertThat(issues.components()).hasSize(1);
-
-    Component component = issues.component(issues.list().get(0));
-    assertThat(component.key()).isEqualTo("struts:Action.java");
-    assertThat(component.qualifier()).isEqualTo("CLA");
-    assertThat(component.name()).isEqualTo("Action");
-    assertThat(component.longName()).isEqualTo("org.struts.Action");
-  }
-
-  @Test
-  public void should_parse_projects() throws Exception {
-    String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/IssueParserTest/issue-with-projects.json"));
-    Issues issues = new IssueParser().parseIssues(json);
-
-    assertThat(issues.projects()).hasSize(1);
-
-    Component component = issues.project(issues.list().get(0));
-    assertThat(component.key()).isEqualTo("struts");
-    assertThat(component.qualifier()).isEqualTo("TRK");
-    assertThat(component.name()).isEqualTo("Struts");
-    assertThat(component.longName()).isEqualTo("org.struts");
-  }
-}
index 475e95c4f709921ecc0ad091e9a447b1fab4a878..d42a0256f081e2d9adc418aff9211caa6a23be85 100644 (file)
@@ -53,5 +53,8 @@ public class UserQueryTest {
   public void should_search_by_text() throws Exception {
     UserQuery query = UserQuery.create().searchText("sim");
     assertThat(query.urlParams().get("s")).isEqualTo("sim");
+
+    query = UserQuery.create().searchText("sim").searchText(null);
+    assertThat(query.urlParams().get("s")).isNull();
   }
 }