aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-23 23:18:13 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-24 09:39:42 +0100
commit23b6f858b1813d4d399ba9a1808fb880f9b96ce8 (patch)
treeb0705dad0914e05dad9198e3def9b8fe4535f003
parentf56bbf1c3941c66393ac66ebe638f36347e9cc76 (diff)
downloadsonarqube-23b6f858b1813d4d399ba9a1808fb880f9b96ce8.tar.gz
sonarqube-23b6f858b1813d4d399ba9a1808fb880f9b96ce8.zip
Replace some Guava usages by Java 8 functions
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java24
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java11
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/source/ws/HashAction.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/SnapshotDtoFunctions.java43
-rw-r--r--sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDtoFunctions.java49
-rw-r--r--sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoFunctions.java40
-rw-r--r--sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java58
-rw-r--r--sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileProjectCount.java8
-rw-r--r--sonar-db/src/main/java/org/sonar/db/rule/RuleDtoFunctions.java43
-rw-r--r--sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java8
13 files changed, 22 insertions, 280 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java
index d4447f6563c..8e66e5389d8 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java
@@ -19,10 +19,8 @@
*/
package org.sonar.server.metric.ws;
-import com.google.common.base.Function;
import com.google.common.collect.Lists;
import java.util.List;
-import javax.annotation.Nonnull;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
@@ -37,8 +35,8 @@ import org.sonar.server.user.UserSession;
import static com.google.common.base.Preconditions.checkArgument;
public class DeleteAction implements MetricsWsAction {
- public static final String PARAM_IDS = "ids";
- public static final String PARAM_KEYS = "keys";
+ private static final String PARAM_IDS = "ids";
+ private static final String PARAM_KEYS = "keys";
private final DbClient dbClient;
private final UserSession userSession;
@@ -90,25 +88,11 @@ public class DeleteAction implements MetricsWsAction {
checkArgument(idsAsStrings != null || keys != null, "Ids or keys must be provided.");
List<Integer> ids = null;
if (idsAsStrings != null) {
- ids = Lists.transform(idsAsStrings, new StringToIntegerFunction());
+ ids = Lists.transform(idsAsStrings, Integer::valueOf);
} else if (keys != null) {
- ids = Lists.transform(dbClient.metricDao().selectByKeys(dbSession, keys), new MetricDtoToIdFunction());
+ ids = Lists.transform(dbClient.metricDao().selectByKeys(dbSession, keys), MetricDto::getId);
}
return ids;
}
-
- private static class StringToIntegerFunction implements Function<String, Integer> {
- @Override
- public Integer apply(String id) {
- return Integer.valueOf(id);
- }
- }
-
- private static class MetricDtoToIdFunction implements Function<MetricDto, Integer> {
- @Override
- public Integer apply(@Nonnull MetricDto input) {
- return input.getId();
- }
- }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
index f277e9a7a54..983d30edfd3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
@@ -44,8 +44,6 @@ import org.sonar.api.utils.ValidationMessages;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.ActiveRuleDto;
-import org.sonar.db.qualityprofile.ActiveRuleDtoFunctions.ActiveRuleDtoToId;
-import org.sonar.db.qualityprofile.ActiveRuleDtoFunctions.ActiveRuleParamDtoToActiveRuleId;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.server.exceptions.BadRequestException;
@@ -129,8 +127,8 @@ public class QProfileExporters {
RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage());
try {
List<ActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfileKey(dbSession, profile.getKey());
- List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDtoToId.INSTANCE));
- ListMultimap<Integer, ActiveRuleParamDto> activeRuleParamsByActiveRuleId = FluentIterable.from(activeRuleParamDtos).index(ActiveRuleParamDtoToActiveRuleId.INSTANCE);
+ List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDto::getId));
+ ListMultimap<Integer, ActiveRuleParamDto> activeRuleParamsByActiveRuleId = FluentIterable.from(activeRuleParamDtos).index(ActiveRuleParamDto::getActiveRuleId);
for (ActiveRuleDto activeRule : activeRuleDtos) {
// TODO all rules should be loaded by using one query with all active rule keys as parameter
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
index 8e3a2c1d6fd..71b9f29336b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
@@ -120,7 +120,7 @@ public class QProfileFactory {
db.activeRuleDao().delete(session, activeRule.getKey());
changes.add(ActiveRuleChange.createFor(DEACTIVATED, activeRule.getKey()));
}
- db.qualityProfileDao().delete(session, profile);
+ db.qualityProfileDao().delete(session, profile.getId());
return changes;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
index 667930f127e..db72cc68de3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
@@ -24,6 +24,7 @@ import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Collections;
@@ -42,7 +43,6 @@ import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.ActiveRuleDto;
-import org.sonar.db.qualityprofile.ActiveRuleDtoFunctions.ActiveRuleDtoToId;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.RuleParamDto;
@@ -51,7 +51,6 @@ import org.sonar.server.user.UserSession;
import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.Lists.newArrayList;
-import static org.sonar.db.qualityprofile.ActiveRuleParamDtoFunctions.ActiveRuleDtoParamToKey;
@ServerSide
public class RuleUpdater {
@@ -253,10 +252,8 @@ public class RuleUpdater {
private Multimap<ActiveRuleDto, ActiveRuleParamDto> getActiveRuleParamsByActiveRule(DbSession dbSession, RuleDto customRule) {
List<ActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByRuleId(dbSession, customRule.getId());
- Map<Integer, ActiveRuleDto> activeRuleById = from(activeRuleDtos).uniqueIndex(ActiveRuleDtoToId.INSTANCE);
- List<Integer> activeRuleIds = from(activeRuleDtos)
- .transform(ActiveRuleDtoToId.INSTANCE)
- .toList();
+ Map<Integer, ActiveRuleDto> activeRuleById = from(activeRuleDtos).uniqueIndex(ActiveRuleDto::getId);
+ List<Integer> activeRuleIds = Lists.transform(activeRuleDtos, ActiveRuleDto::getId);
List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, activeRuleIds);
return from(activeRuleParamDtos)
.index(new ActiveRuleParamToActiveRule(activeRuleById));
@@ -324,7 +321,7 @@ public class RuleUpdater {
@Override
public boolean apply(@Nonnull ActiveRuleDto activeRuleDto) {
Map<String, ActiveRuleParamDto> activeRuleParamByKey = from(activeRuleParams.get(activeRuleDto))
- .uniqueIndex(ActiveRuleDtoParamToKey.INSTANCE);
+ .uniqueIndex(ActiveRuleParamDto::getKey);
ActiveRuleParamDto activeRuleParamDto = activeRuleParamByKey.get(ruleParamDto.getName());
if (activeRuleParamDto != null) {
dbClient.activeRuleDao().updateParam(dbSession, activeRuleDto, activeRuleParamDto.setValue(ruleParamDto.getDefaultValue()));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java
index 1a2a3122825..5638e2251c8 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java
@@ -40,12 +40,10 @@ import org.sonar.api.utils.log.Loggers;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.ActiveRuleDto;
-import org.sonar.db.qualityprofile.ActiveRuleDtoFunctions.ActiveRuleDtoToId;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.db.rule.RuleDto;
-import org.sonar.db.rule.RuleDtoFunctions;
import org.sonar.server.qualityprofile.ActiveRule;
import org.sonar.server.qualityprofile.QProfileLoader;
import org.sonar.server.rule.index.RuleQuery;
@@ -101,7 +99,7 @@ public class ActiveRuleCompleter {
}
} else {
// Load details of all active rules
- List<ActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByRuleIds(dbSession, Lists.transform(rules, RuleDtoFunctions.toId()));
+ List<ActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByRuleIds(dbSession, Lists.transform(rules, RuleDto::getId));
Multimap<RuleKey, ActiveRuleDto> activeRulesByRuleKey = from(activeRuleDtos).index(ActiveRuleToRuleKey.INSTANCE);
ListMultimap<ActiveRuleKey, ActiveRuleParamDto> activeRuleParamsByActiveRuleKey = activeRuleDtosToActiveRuleParamDtos(dbSession, activeRuleDtos);
for (RuleDto rule : rules) {
@@ -132,7 +130,7 @@ public class ActiveRuleCompleter {
for (ActiveRuleDto activeRuleDto : activeRuleDtos) {
activeRuleIdsByKey.put(activeRuleDto.getId(), activeRuleDto.getKey());
}
- List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDtoToId.INSTANCE));
+ List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDto::getId));
ListMultimap<ActiveRuleKey, ActiveRuleParamDto> activeRuleParamsByActiveRuleKey = ArrayListMultimap.create(activeRuleDtos.size(), 10);
for (ActiveRuleParamDto activeRuleParamDto : activeRuleParamDtos) {
ActiveRuleKey activeRuleKey = activeRuleIdsByKey.get(activeRuleParamDto.getActiveRuleId());
@@ -149,7 +147,7 @@ public class ActiveRuleCompleter {
activeRuleIdsByKey.put(activeRuleDto.getId(), activeRuleDto.getKey());
}
- List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDtoToId.INSTANCE));
+ List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDto::getId));
ListMultimap<ActiveRuleKey, ActiveRuleParamDto> activeRuleParamsByActiveRuleKey = ArrayListMultimap.create(activeRuleDtos.size(), 10);
for (ActiveRuleParamDto activeRuleParamDto : activeRuleParamDtos) {
ActiveRuleKey activeRuleKey = activeRuleIdsByKey.get(activeRuleParamDto.getActiveRuleId());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/ws/HashAction.java b/server/sonar-server/src/main/java/org/sonar/server/source/ws/HashAction.java
index bf1fcecac58..d68548fe9fb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/source/ws/HashAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/source/ws/HashAction.java
@@ -19,13 +19,13 @@
*/
package org.sonar.server.source.ws;
-import com.google.common.base.Function;
import com.google.common.io.CharStreams;
import com.google.common.io.Resources;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
+import java.util.function.Function;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDtoFunctions.java
deleted file mode 100644
index 3e79e7b7f05..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDtoFunctions.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.component;
-
-import com.google.common.base.Function;
-import javax.annotation.Nonnull;
-
-public class SnapshotDtoFunctions {
- public static Function<SnapshotDto, Long> toId() {
- return ToId.INSTANCE;
- }
-
- public static Function<SnapshotDto, String> toComponentUuid() {
- return SnapshotDto::getComponentUuid;
- }
-
- private enum ToId implements Function<SnapshotDto, Long> {
- INSTANCE;
-
- @Override
- public Long apply(@Nonnull SnapshotDto input) {
- return input.getId();
- }
- }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDtoFunctions.java
deleted file mode 100644
index a7830fbe10f..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDtoFunctions.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.qualityprofile;
-
-import com.google.common.base.Function;
-import javax.annotation.Nonnull;
-
-public class ActiveRuleDtoFunctions {
-
- private ActiveRuleDtoFunctions() {
- // Only static methods
- }
-
- public enum ActiveRuleDtoToId implements Function<ActiveRuleDto, Integer> {
- INSTANCE;
-
- @Override
- public Integer apply(@Nonnull ActiveRuleDto input) {
- return input.getId();
- }
- }
-
- public enum ActiveRuleParamDtoToActiveRuleId implements Function<ActiveRuleParamDto, Integer> {
- INSTANCE;
-
- @Override
- public Integer apply(@Nonnull ActiveRuleParamDto input) {
- return input.getActiveRuleId();
- }
- }
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoFunctions.java
deleted file mode 100644
index b77279ea656..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoFunctions.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.qualityprofile;
-
-import com.google.common.base.Function;
-import javax.annotation.Nonnull;
-
-public class ActiveRuleParamDtoFunctions {
-
- private ActiveRuleParamDtoFunctions() {
- // Only static methods
- }
-
- public enum ActiveRuleDtoParamToKey implements Function<ActiveRuleParamDto, String> {
- INSTANCE;
-
- @Override
- public String apply(@Nonnull ActiveRuleParamDto input) {
- return input.getKey();
- }
- }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
index 64e98ccf061..01156c059bc 100644
--- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
@@ -113,53 +113,9 @@ public class QualityProfileDao implements Dao {
mapper.update(profile);
}
- /**
- * @deprecated use {@link #update(DbSession, QualityProfileDto, QualityProfileDto...)}
- */
- @Deprecated
- public void update(QualityProfileDto dto) {
- DbSession session = mybatis.openSession(false);
- try {
- update(session, dto);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public void delete(DbSession session, QualityProfileDto profile, QualityProfileDto... otherProfiles) {
+ public void delete(DbSession session, int profileId) {
QualityProfileMapper mapper = mapper(session);
- doDelete(mapper, profile);
- for (QualityProfileDto otherProfile : otherProfiles) {
- doDelete(mapper, otherProfile);
- }
- }
-
- private void doDelete(QualityProfileMapper mapper, QualityProfileDto profile) {
- Preconditions.checkNotNull(profile.getId(), "Quality profile is not persisted");
- mapper.delete(profile.getId());
- }
-
- /**
- * @deprecated use {@link #delete(DbSession, QualityProfileDto, QualityProfileDto...)}
- */
- @Deprecated
- public void delete(int id, DbSession session) {
- mapper(session).delete(id);
- }
-
- /**
- * @deprecated use {@link #delete(DbSession, QualityProfileDto, QualityProfileDto...)}
- */
- @Deprecated
- public void delete(int id) {
- DbSession session = mybatis.openSession(false);
- try {
- delete(id, session);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
+ mapper.delete(profileId);
}
/**
@@ -242,16 +198,6 @@ public class QualityProfileDao implements Dao {
return mapper(session).selectParentById(childId);
}
- @CheckForNull
- public QualityProfileDto selectParentById(int childId) {
- DbSession session = mybatis.openSession(false);
- try {
- return selectParentById(session, childId);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
public List<QualityProfileDto> selectChildren(DbSession session, String key) {
return mapper(session).selectChildren(key);
}
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileProjectCount.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileProjectCount.java
index c96cf3615e7..591fa79aa3c 100644
--- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileProjectCount.java
+++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileProjectCount.java
@@ -28,15 +28,7 @@ public class QualityProfileProjectCount {
return profileKey;
}
- public void setProfileKey(String profileKey) {
- this.profileKey = profileKey;
- }
-
public Long getProjectCount() {
return projectCount;
}
-
- public void setProjectCount(Long projectCount) {
- this.projectCount = projectCount;
- }
}
diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleDtoFunctions.java
deleted file mode 100644
index 85ec0d6f1c3..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/rule/RuleDtoFunctions.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.rule;
-
-import com.google.common.base.Function;
-import javax.annotation.Nonnull;
-
-public class RuleDtoFunctions {
- private RuleDtoFunctions() {
- // prevent instantiation
- }
-
- public static Function<RuleDto, Integer> toId() {
- return ToId.INSTANCE;
- }
-
- private enum ToId implements Function<RuleDto, Integer> {
- INSTANCE;
-
- @Override
- public Integer apply(@Nonnull RuleDto rule) {
- return rule.getId();
- }
- }
-}
diff --git a/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
index 110e4045282..6ff569a7eb0 100644
--- a/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
@@ -84,7 +84,8 @@ public class QualityProfileDaoTest {
.setParentKee("fghij")
.setDefault(false);
- underTest.update(dto);
+ underTest.update(dbSession, dto);
+ dbSession.commit();
dbTester.assertDbUnit(getClass(), "update-result.xml", new String[]{"created_at", "updated_at", "rules_updated_at"}, "rules_profiles");
}
@@ -93,7 +94,8 @@ public class QualityProfileDaoTest {
public void delete() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- underTest.delete(1);
+ underTest.delete(dbSession, 1);
+ dbSession.commit();
dbTester.assertDbUnit(getClass(), "delete-result.xml", "rules_profiles");
}
@@ -211,7 +213,7 @@ public class QualityProfileDaoTest {
public void get_parent_by_id() {
dbTester.prepareDbUnit(getClass(), "inheritance.xml");
- QualityProfileDto dto = underTest.selectParentById(1);
+ QualityProfileDto dto = underTest.selectParentById(dbSession, 1);
assertThat(dto.getId()).isEqualTo(3);
}