diff options
author | Eric Hartmann <hartmann.eric@gmail.com> | 2017-09-11 14:45:59 +0200 |
---|---|---|
committer | Eric Hartmann <hartmann.eric@gmail.Com> | 2017-09-11 18:38:21 +0200 |
commit | 1c0c2b62fbd3f21bc510abac4ccb0eb379bd6145 (patch) | |
tree | 1036f09b6e71a90e348778514ddac8c9e3742beb | |
parent | 7f6155b00a746e302950df3271104a180f50387a (diff) | |
download | sonarqube-1c0c2b62fbd3f21bc510abac4ccb0eb379bd6145.tar.gz sonarqube-1c0c2b62fbd3f21bc510abac4ccb0eb379bd6145.zip |
Fix quality flaws
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java | 47 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java | 4 |
2 files changed, 49 insertions, 2 deletions
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<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); } |