From: Eric Hartmann Date: Mon, 11 Sep 2017 12:45:59 +0000 (+0200) Subject: Fix quality flaws X-Git-Tag: 6.6-RC1~388 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1c0c2b62fbd3f21bc510abac4ccb0eb379bd6145;p=sonarqube.git Fix quality flaws --- 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 index 00000000000..180600a5ecb --- /dev/null +++ b/server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java @@ -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"); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java index 3afcdabadd5..f6e699fbe78 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java @@ -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 { 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); }