diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-22 15:33:34 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-22 16:17:41 +0200 |
commit | a41640c8e68447aa849b4449332c709ab2149bc3 (patch) | |
tree | 242c4a7417670b773ae68208bf2c76deaf5e244d | |
parent | c06ca182fe2eced095c12dd2de0bc02f0627122d (diff) | |
download | sonarqube-a41640c8e68447aa849b4449332c709ab2149bc3.tar.gz sonarqube-a41640c8e68447aa849b4449332c709ab2149bc3.zip |
Move MetricDao to sonar-db
25 files changed, 33 insertions, 69 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java b/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java index 59f01efabf0..f52b3906c51 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java @@ -23,7 +23,6 @@ import java.util.Map; import org.sonar.db.Dao; import org.sonar.db.Database; import org.sonar.db.MyBatis; -import org.sonar.server.metric.persistence.MetricDao; import org.sonar.server.qualityprofile.db.ActiveRuleDao; import org.sonar.server.rule.db.RuleDao; import org.sonar.server.user.db.GroupDao; @@ -37,7 +36,6 @@ public class DbClient extends org.sonar.db.DbClient { private ActiveRuleDao activeRuleDao; private GroupDao groupDao; - private MetricDao metricDao; private RuleDao ruleDao; private UserDao userDao; @@ -49,7 +47,6 @@ public class DbClient extends org.sonar.db.DbClient { protected void doOnLoad(Map<Class, Dao> daoByClass) { this.activeRuleDao = (ActiveRuleDao) daoByClass.get(ActiveRuleDao.class); this.groupDao = (GroupDao) daoByClass.get(GroupDao.class); - this.metricDao = (MetricDao) daoByClass.get(MetricDao.class); this.ruleDao = (RuleDao) daoByClass.get(RuleDao.class); this.userDao = (UserDao) daoByClass.get(UserDao.class); } @@ -62,10 +59,6 @@ public class DbClient extends org.sonar.db.DbClient { return groupDao; } - public MetricDao metricDao() { - return metricDao; - } - public RuleDao ruleDao() { return ruleDao; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/persistence/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/metric/persistence/package-info.java deleted file mode 100644 index 2b47d5bda85..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/persistence/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.server.metric.persistence; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java index 810169750ab..83f174a272e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/SearchAction.java @@ -92,7 +92,7 @@ public class SearchAction implements MetricsWsAction { Boolean isCustom = request.paramAsBoolean(PARAM_IS_CUSTOM); DbSession dbSession = dbClient.openSession(false); try { - List<MetricDto> metrics = dbClient.metricDao().selectEnabled(dbSession, isCustom, searchOptions); + List<MetricDto> metrics = dbClient.metricDao().selectEnabled(dbSession, isCustom, searchOptions.getOffset(), searchOptions.getLimit()); int nbMetrics = dbClient.metricDao().countEnabled(dbSession, isCustom); JsonWriter json = response.newJsonWriter(); json.beginObject(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java index 131128ee86d..1553ca676ff 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java @@ -37,7 +37,7 @@ import org.sonar.db.version.MigrationStepModule; import org.sonar.server.db.DbClient; import org.sonar.server.db.EmbeddedDatabaseFactory; import org.sonar.server.issue.index.IssueIndex; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.platform.DatabaseServerCompatibility; import org.sonar.server.platform.DefaultServerFileSystem; import org.sonar.server.platform.Platform; diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalActionTest.java index d6e20f479a5..6834adcbd79 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/GlobalActionTest.java @@ -34,7 +34,7 @@ import org.sonar.db.property.PropertiesDao; import org.sonar.db.property.PropertyDto; import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.ForbiddenException; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.WsTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java index d5d704afd3a..7a0e5eff21f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java @@ -55,7 +55,7 @@ import org.sonar.server.computation.metric.MetricImpl; import org.sonar.server.computation.metric.MetricRepository; import org.sonar.server.computation.metric.ReportMetricValidator; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import static com.google.common.collect.FluentIterable.from; import static java.lang.String.format; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/metric/MetricRepositoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/metric/MetricRepositoryImplTest.java index df55b7bc335..bdd86092384 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/metric/MetricRepositoryImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/metric/MetricRepositoryImplTest.java @@ -27,7 +27,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.test.DbTests; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java index 3bdaae42e14..a117734529d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java @@ -40,7 +40,7 @@ import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.DbIdsRepository; import org.sonar.server.computation.component.DumbComponent; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.test.DbTests; import static com.google.common.collect.Lists.newArrayList; diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java index 1fc4fb5b97d..d6652bd2c32 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java @@ -51,7 +51,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.ServerException; import org.sonar.db.measure.custom.CustomMeasureDao; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.metric.ws.MetricTesting; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.index.UserDoc; @@ -361,7 +361,7 @@ public class CreateActionTest { dbClient.componentDao().insert(dbSession, ComponentTesting.newProjectDto(DEFAULT_PROJECT_UUID)); dbSession.commit(); - expectedException.expect(ServerException.class); + expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Metric id '42' not found"); newRequest() diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java index 89aecef33a0..474e30302b3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/MetricsActionTest.java @@ -45,7 +45,7 @@ import org.sonar.server.db.DbClient; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.db.measure.custom.CustomMeasureDao; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.index.UserDoc; import org.sonar.server.user.index.UserIndexDefinition; diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java index 479e4e29a66..000738435e9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java @@ -51,7 +51,7 @@ import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.db.measure.custom.CustomMeasureDao; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.index.UserDoc; import org.sonar.server.user.index.UserIndex; diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java index bce9042fdf8..1d6b7cf3899 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java @@ -45,7 +45,7 @@ import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.ServerException; import org.sonar.server.exceptions.UnauthorizedException; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.metric.ws.MetricTesting; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.index.UserDoc; diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/DefaultMetricFinderTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/DefaultMetricFinderTest.java index b377ee0eb46..ed50d7009ec 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/DefaultMetricFinderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/DefaultMetricFinderTest.java @@ -27,7 +27,7 @@ import org.junit.experimental.categories.Category; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.test.DbTests; import static org.hamcrest.core.Is.is; diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java index f488261e05b..bf9090c3acd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java @@ -37,7 +37,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.ServerException; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.db.measure.custom.CustomMeasureTesting; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.ruby.RubyBridge; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.WsTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java index 35fcaad6b28..c0b49db50df 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java @@ -38,7 +38,7 @@ import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.db.measure.custom.CustomMeasureTesting; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.ruby.RubyBridge; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.WsTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java index dd8d0b9e5bb..6281ef4e273 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java @@ -30,7 +30,7 @@ import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.metric.MetricDto; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.ws.WsTester; import org.sonar.test.DbTests; import org.sonar.test.JsonAssert; diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java index dc1a55dd207..c2add0c926e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java @@ -32,7 +32,7 @@ import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.metric.MetricDto; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.ws.WsTester; import org.sonar.test.DbTests; diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java index c4c3f717188..0461721139d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java @@ -36,7 +36,7 @@ import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.ServerException; import org.sonar.db.measure.custom.CustomMeasureDao; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.server.ruby.RubyBridge; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.WsTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java index 7a797c27bf4..5dac3d40396 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java @@ -31,7 +31,7 @@ import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.qualitygate.QualityGateConditionDao; import org.sonar.server.db.DbClient; -import org.sonar.server.metric.persistence.MetricDao; +import org.sonar.db.metric.MetricDao; import org.sonar.test.DbTests; import static java.util.Arrays.asList; diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java index 4ef128b94ec..fba496c2f90 100644 --- a/sonar-db/src/main/java/org/sonar/db/DbClient.java +++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java @@ -47,6 +47,7 @@ import org.sonar.db.loadedtemplate.LoadedTemplateDao; import org.sonar.db.measure.MeasureDao; import org.sonar.db.measure.MeasureFilterDao; import org.sonar.db.measure.custom.CustomMeasureDao; +import org.sonar.db.metric.MetricDao; import org.sonar.db.notification.NotificationQueueDao; import org.sonar.db.permission.PermissionDao; import org.sonar.db.permission.PermissionTemplateDao; @@ -109,8 +110,9 @@ public class DbClient { private final DuplicationDao duplicationDao; private final NotificationQueueDao notificationQueueDao; private final CustomMeasureDao customMeasureDao; + private final MetricDao metricDao; - public DbClient(Database database, MyBatis myBatis, Dao ... daos) { + public DbClient(Database database, MyBatis myBatis, Dao... daos) { this.database = database; this.myBatis = myBatis; @@ -159,6 +161,7 @@ public class DbClient { duplicationDao = getDao(map, DuplicationDao.class); notificationQueueDao = getDao(map, NotificationQueueDao.class); customMeasureDao = getDao(map, CustomMeasureDao.class); + metricDao = getDao(map, MetricDao.class); doOnLoad(map); } @@ -343,6 +346,10 @@ public class DbClient { return customMeasureDao; } + public MetricDao metricDao() { + return metricDao; + } + protected <K extends Dao> K getDao(Map<Class, Dao> map, Class<K> clazz) { return (K) map.get(clazz); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/persistence/MetricDao.java b/sonar-db/src/main/java/org/sonar/db/metric/MetricDao.java index 3e04c9685c9..453096efb85 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/persistence/MetricDao.java +++ b/sonar-db/src/main/java/org/sonar/db/metric/MetricDao.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.metric.persistence; +package org.sonar.db.metric; import com.google.common.base.Function; import com.google.common.base.Predicate; @@ -37,10 +37,6 @@ import org.apache.ibatis.session.RowBounds; import org.sonar.db.Dao; import org.sonar.db.DatabaseUtils; import org.sonar.db.DbSession; -import org.sonar.db.metric.MetricDto; -import org.sonar.db.metric.MetricMapper; -import org.sonar.server.es.SearchOptions; -import org.sonar.server.exceptions.NotFoundException; import static com.google.common.collect.Lists.newArrayList; @@ -63,7 +59,7 @@ public class MetricDao implements Dao { public MetricDto selectByKey(DbSession session, String key) { MetricDto metric = selectNullableByKey(session, key); if (metric == null) { - throw new NotFoundException(String.format("Metric key '%s' not found", key)); + throw new IllegalStateException(String.format("Metric key '%s' not found", key)); } return metric; } @@ -72,13 +68,13 @@ public class MetricDao implements Dao { return mapper(session).selectAllEnabled(); } - public List<MetricDto> selectEnabled(DbSession session, @Nullable Boolean isCustom, SearchOptions searchOptions) { + public List<MetricDto> selectEnabled(DbSession session, @Nullable Boolean isCustom, int offset, int limit) { Map<String, Object> properties = Maps.newHashMapWithExpectedSize(1); if (isCustom != null) { properties.put("isCustom", isCustom); } - return mapper(session).selectAllEnabled(properties, new RowBounds(searchOptions.getOffset(), searchOptions.getLimit())); + return mapper(session).selectAllEnabled(properties, new RowBounds(offset, limit)); } public int countEnabled(DbSession session, @Nullable Boolean isCustom) { @@ -107,10 +103,6 @@ public class MetricDao implements Dao { return mapper(session).selectAvailableCustomMetricsByComponentUuid(projectUuid); } - public List<MetricDto> selectAvailableCustomMetricsByComponentKey(DbSession session, String projectKey) { - return mapper(session).selectAvailableCustomMetricsByComponentUuid(projectKey); - } - public List<MetricDto> selectByIds(final DbSession session, Set<Integer> idsSet) { List<Integer> ids = new ArrayList<>(idsSet); return DatabaseUtils.executeLargeInputs(ids, new Function<List<Integer>, List<MetricDto>>() { @@ -158,7 +150,7 @@ public class MetricDao implements Dao { public MetricDto selectById(DbSession session, int id) { MetricDto metric = mapper(session).selectById(id); if (metric == null) { - throw new NotFoundException(String.format("Metric id '%d' not found", id)); + throw new IllegalStateException(String.format("Metric id '%d' not found", id)); } return metric; } diff --git a/sonar-db/src/main/java/org/sonar/db/metric/MetricMapper.java b/sonar-db/src/main/java/org/sonar/db/metric/MetricMapper.java index 68ff2ccf0b4..fb5bafdce52 100644 --- a/sonar-db/src/main/java/org/sonar/db/metric/MetricMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/metric/MetricMapper.java @@ -53,6 +53,4 @@ public interface MetricMapper { void update(MetricDto metric); List<MetricDto> selectAvailableCustomMetricsByComponentUuid(String projectUuid); - - List<MetricDto> selectAvailableCustomMetricsByComponentKey(String projectKey); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/persistence/MetricDaoTest.java b/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java index f8cf592bfb2..162cb647e50 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/persistence/MetricDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.metric.persistence; +package org.sonar.db.metric; import org.junit.After; import org.junit.Before; @@ -28,8 +28,6 @@ import org.junit.experimental.categories.Category; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.metric.MetricDto; -import org.sonar.server.exceptions.NotFoundException; import org.sonar.test.DbTests; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +81,7 @@ public class MetricDaoTest { assertThat(result.isEnabled()).isFalse(); } - @Test(expected = NotFoundException.class) + @Test(expected = IllegalStateException.class) public void get_nullable_by_key() { dao.selectByKey(session, "unknown"); } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/metric/persistence/MetricDaoTest/manual_metric.xml b/sonar-db/src/test/resources/org/sonar/db/metric/MetricDaoTest/manual_metric.xml index 325a5a71661..325a5a71661 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/metric/persistence/MetricDaoTest/manual_metric.xml +++ b/sonar-db/src/test/resources/org/sonar/db/metric/MetricDaoTest/manual_metric.xml diff --git a/server/sonar-server/src/test/resources/org/sonar/server/metric/persistence/MetricDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/metric/MetricDaoTest/shared.xml index dda5d3bbb88..dda5d3bbb88 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/metric/persistence/MetricDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/metric/MetricDaoTest/shared.xml |