]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorEric Hartmann <hartmann.eric@gmail.com>
Mon, 11 Sep 2017 12:45:59 +0000 (14:45 +0200)
committerEric Hartmann <hartmann.eric@gmail.Com>
Mon, 11 Sep 2017 16:38:21 +0000 (18:38 +0200)
server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java

diff --git a/server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java b/server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java
new file mode 100644 (file)
index 0000000..180600a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info 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.process;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class NodeTypeTest {
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  @Test
+  public void test_parse() {
+    assertThat(NodeType.parse("application")).isEqualTo(NodeType.APPLICATION);
+    assertThat(NodeType.parse("search")).isEqualTo(NodeType.SEARCH);
+  }
+
+  @Test
+  public void parse_an_unknown_value_must_throw_IAE() {
+    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expectMessage("Invalid value for ");
+
+    NodeType.parse("XYZ");
+  }
+}
index 3afcdabadd5d707c30ad1cfb96c13f752f95a45c..f6e699fbe782470770202799b66cd01d67ea834f 100644 (file)
@@ -39,9 +39,9 @@ import org.sonar.db.ResultSetIterator;
 import org.sonar.db.protobuf.DbFileSources;
 import org.sonar.db.source.FileSourceDto;
 import org.sonar.server.es.EsUtils;
-import org.sonar.server.source.index.FileSourcesUpdaterHelper;
 import org.sonar.server.source.index.FileSourcesUpdaterHelper.Row;
 
+import static org.sonar.server.source.index.FileSourcesUpdaterHelper.preparedStatementToSelectFileSources;
 import static org.sonar.server.test.index.TestIndexDefinition.FIELD_COVERED_FILES;
 import static org.sonar.server.test.index.TestIndexDefinition.FIELD_COVERED_FILE_LINES;
 import static org.sonar.server.test.index.TestIndexDefinition.FIELD_COVERED_FILE_UUID;
@@ -68,7 +68,7 @@ public class TestResultSetIterator extends ResultSetIterator<Row> {
 
   public static TestResultSetIterator create(DbClient dbClient, DbSession session, @Nullable String projectUuid) {
     try {
-      return new TestResultSetIterator(FileSourcesUpdaterHelper.preparedStatementToSelectFileSources(dbClient, session, FileSourceDto.Type.TEST, projectUuid));
+      return new TestResultSetIterator(preparedStatementToSelectFileSources(dbClient, session, FileSourceDto.Type.TEST, projectUuid));
     } catch (SQLException e) {
       throw new IllegalStateException("Fail to prepare SQL request to select all tests", e);
     }