diff options
Diffstat (limited to 'server/sonar-db-dao')
15 files changed, 33 insertions, 32 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java index bcd4c1160d7..0d6947cd48e 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java @@ -30,6 +30,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Random; +import java.util.stream.Collectors; import java.util.stream.IntStream; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -43,7 +44,6 @@ import org.junit.runner.RunWith; import org.sonar.api.impl.utils.TestSystem2; import org.sonar.core.util.CloseableIterator; import org.sonar.core.util.UuidFactoryFast; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.Pagination; @@ -918,7 +918,7 @@ public class CeActivityDaoIT { private List<String> selectPageOfUuids(Pagination pagination) { return underTest.selectByQuery(db.getSession(), new CeTaskQuery(), pagination).stream() .map(CeActivityToUuid.INSTANCE::apply) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private enum CeActivityToUuid implements Function<CeActivityDto, String> { diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java index 15cff865943..294c937a6dc 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java @@ -25,13 +25,13 @@ import java.util.Collections; import java.util.List; import java.util.Random; import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.audit.NoOpAuditPersister; @@ -1010,7 +1010,7 @@ public class GroupPermissionDaoIT { .stream() .flatMap(map -> map.entrySet().stream()) .map(entry -> (String) entry.getValue()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private ProjectData randomPublicOrPrivateProject() { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java index 425434c6392..c72e72c6347 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java @@ -23,9 +23,9 @@ import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; import org.apache.ibatis.session.ResultHandler; import org.sonar.core.issue.FieldDiffs; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -40,7 +40,7 @@ public class IssueChangeDao implements Dao { return selectByTypeAndIssueKeys(session, singletonList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE) .stream() .map(IssueChangeDto::toFieldDiffs) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public List<IssueChangeDto> selectByTypeAndIssueKeys(DbSession session, Collection<String> issueKeys, String changeType) { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java index fd90c0a4537..8fd1c9ed34c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -154,7 +154,7 @@ public class PurgeDao implements Dao { return mapper.selectPurgeableAnalyses(componentUuid).stream() .filter(new NewCodePeriodAnalysisFilter(mapper, componentUuid)) .sorted() - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public void purgeCeActivities(DbSession session, PurgeProfiler profiler) { @@ -307,7 +307,7 @@ public class PurgeDao implements Dao { List<String> subviewsOrProjectCopies = nonRootComponents.stream() .filter(PurgeDao::isSubview) .map(ComponentDto::uuid) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); purgeCommands.deleteByRootAndSubviews(subviewsOrProjectCopies); List<String> nonRootComponentUuids = nonRootComponents.stream().map(ComponentDto::uuid).collect(Collectors.toList()); purgeCommands.deleteComponentMeasures(nonRootComponentUuids); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java index d67686ed4c7..358767fbc2c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java @@ -22,9 +22,9 @@ package org.sonar.db.purge.period; import com.google.common.base.Strings; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.DateUtils; import org.slf4j.LoggerFactory; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.purge.PurgeableAnalysisDto; class KeepWithVersionFilter implements Filter { @@ -40,7 +40,7 @@ class KeepWithVersionFilter implements Filter { return history.stream() .filter(analysis -> analysis.getDate().before(before)) .filter(KeepWithVersionFilter::isDeletable) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } @Override diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java index e044ae25e21..4e5e135fa1e 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java @@ -21,6 +21,7 @@ package org.sonar.db.qualitygate; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.System2; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -31,7 +32,6 @@ import org.sonar.db.user.GroupDto; import org.sonar.db.user.SearchGroupMembershipDto; import org.sonar.db.user.SearchPermissionQuery; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeInputs; public class QualityGateGroupPermissionsDao implements Dao { @@ -52,7 +52,7 @@ public class QualityGateGroupPermissionsDao implements Dao { } public boolean exists(DbSession dbSession, QualityGateDto qualityGate, Collection<GroupDto> groups) { - return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(toList()), + return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(Collectors.toList()), partition -> mapper(dbSession).selectByQualityGateAndGroups(qualityGate.getUuid(), partition)) .isEmpty(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java index ce11257b517..fd5f2721fe2 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java @@ -20,10 +20,10 @@ package org.sonar.db.qualityprofile; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.rule.RuleStatus; -import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkState; @@ -34,7 +34,7 @@ public class ActiveRuleCountQuery { private final String inheritance; public ActiveRuleCountQuery(Builder builder) { - this.profileUuids = builder.profiles.stream().map(QProfileDto::getKee).collect(MoreCollectors.toList()); + this.profileUuids = builder.profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList()); this.ruleStatus = builder.ruleStatus; this.inheritance = builder.inheritance; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java index 580a73241f8..1c2398702c1 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java @@ -22,6 +22,7 @@ package org.sonar.db.qualityprofile; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.System2; import org.sonar.db.Dao; import org.sonar.db.DatabaseUtils; @@ -32,7 +33,6 @@ import org.sonar.db.audit.model.GroupEditorNewValue; import org.sonar.db.user.GroupDto; import org.sonar.db.user.SearchGroupMembershipDto; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeInputs; import static org.sonar.db.DatabaseUtils.executeLargeUpdates; @@ -51,7 +51,7 @@ public class QProfileEditGroupsDao implements Dao { } public boolean exists(DbSession dbSession, QProfileDto profile, Collection<GroupDto> groups) { - return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(toList()), partition -> mapper(dbSession).selectByQProfileAndGroups(profile.getKee(), partition)) + return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(Collectors.toList()), partition -> mapper(dbSession).selectByQProfileAndGroups(profile.getKee(), partition)) .isEmpty(); } @@ -64,7 +64,7 @@ public class QProfileEditGroupsDao implements Dao { } public List<String> selectQProfileUuidsByGroups(DbSession dbSession, Collection<GroupDto> groups) { - return DatabaseUtils.executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(toList()), + return DatabaseUtils.executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(Collectors.toList()), g -> mapper(dbSession).selectQProfileUuidsByGroups(g)); } @@ -88,7 +88,7 @@ public class QProfileEditGroupsDao implements Dao { int deletedRows = mapper(dbSession).deleteByQProfiles(partitionedProfiles .stream() .map(QProfileDto::getKee) - .collect(toList())); + .collect(Collectors.toList())); if (deletedRows > 0) { partitionedProfiles.forEach(p -> auditPersister.deleteQualityProfileEditor(dbSession, new GroupEditorNewValue(p))); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java index 437c02d10aa..f96c5d10d55 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java @@ -20,6 +20,7 @@ package org.sonar.db.qualityprofile; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.System2; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -29,7 +30,6 @@ import org.sonar.db.audit.model.UserEditorNewValue; import org.sonar.db.user.SearchUserMembershipDto; import org.sonar.db.user.UserDto; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeUpdates; public class QProfileEditUsersDao implements Dao { @@ -78,7 +78,7 @@ public class QProfileEditUsersDao implements Dao { int deletedRows = mapper(dbSession).deleteByQProfiles(partitionedProfiles .stream() .map(QProfileDto::getKee) - .collect(toList())); + .collect(Collectors.toList())); if (deletedRows > 0) { partitionedProfiles.forEach(p -> auditPersister.deleteQualityProfileEditor(dbSession, new UserEditorNewValue(p))); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index b3fd50293b5..4fb7dd38f1c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.utils.System2; @@ -209,7 +210,7 @@ public class QualityProfileDao implements Dao { } public Map<String, Long> countProjectsByProfiles(DbSession dbSession, List<QProfileDto> profiles) { - List<String> profileUuids = profiles.stream().map(QProfileDto::getKee).collect(MoreCollectors.toList()); + List<String> profileUuids = profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList()); return KeyLongValue.toMap(executeLargeInputs(profileUuids, partition -> mapper(dbSession).countProjectsByProfiles(partition))); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java index 589f3655614..c9090eaaebe 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.core.util.UuidFactory; @@ -33,7 +34,6 @@ import org.sonar.db.DbSession; import org.sonar.db.audit.AuditPersister; import org.sonar.db.audit.model.UserTokenNewValue; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeInputs; public class UserTokenDao implements Dao { @@ -82,7 +82,7 @@ public class UserTokenDao implements Dao { public Map<String, Integer> countTokensByUsers(DbSession dbSession, Collection<UserDto> users) { Map<String, Integer> result = new HashMap<>(users.size()); executeLargeInputs( - users.stream().map(UserDto::getUuid).collect(toList()), + users.stream().map(UserDto::getUuid).collect(Collectors.toList()), input -> { List<UserTokenCount> userTokenCounts = mapper(dbSession).countTokensByUserUuids(input); for (UserTokenCount userTokenCount : userTokenCounts) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java index 9fe5a6afc2b..a9b730f4644 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java @@ -76,7 +76,7 @@ public class DBSessionsImplTest { .thenReturn(expected[3]) .thenThrow(oneCallTooMuch()); - assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).collect(MoreCollectors.toList())) + assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).collect(Collectors.toList())) .containsExactly(expected); } @@ -90,7 +90,7 @@ public class DBSessionsImplTest { .thenReturn(expected[3]) .thenThrow(oneCallTooMuch()); - assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).collect(MoreCollectors.toList())) + assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).collect(Collectors.toList())) .containsExactly(expected); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java index 9f8d04071b8..4ce51bc9770 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java @@ -20,8 +20,8 @@ package org.sonar.db.notification; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -49,7 +49,7 @@ public class NotificationDbTester { .setUserUuid(userUuid) .build(), dbSession).stream() .filter(prop -> project == null ? prop.getEntityUuid() == null : prop.getEntityUuid() != null) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); assertThat(result).hasSize(1); assertThat(result.get(0).getValue()).isEqualTo("true"); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java index 0fdd3f2365f..7cb8bd12ceb 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java @@ -23,10 +23,10 @@ import java.util.Arrays; import java.util.Date; import java.util.Random; import java.util.function.Consumer; +import java.util.stream.Collectors; import java.util.stream.IntStream; import org.apache.commons.lang.math.RandomUtils; import org.sonar.core.util.Uuids; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.protobuf.DbFileSources; @@ -49,7 +49,7 @@ public class FileSourceTester { .setFileUuid(file.uuid()) .setSrcHash(randomAlphanumeric(50)) .setDataHash(randomAlphanumeric(50)) - .setLineHashes(IntStream.range(0, new Random().nextInt(21)).mapToObj(String::valueOf).collect(MoreCollectors.toList())) + .setLineHashes(IntStream.range(0, new Random().nextInt(21)).mapToObj(String::valueOf).collect(Collectors.toList())) .setRevision(randomAlphanumeric(100)) .setSourceData(newRandomData(3).build()) .setCreatedAt(new Date().getTime()) @@ -69,7 +69,7 @@ public class FileSourceTester { .setFileUuid(file.uuid()) .setSrcHash(randomAlphanumeric(50)) .setDataHash(randomAlphanumeric(50)) - .setLineHashes(IntStream.range(0, numLines).mapToObj(String::valueOf).collect(MoreCollectors.toList())) + .setLineHashes(IntStream.range(0, numLines).mapToObj(String::valueOf).collect(Collectors.toList())) .setRevision(randomAlphanumeric(100)) .setSourceData(newRandomData(numLines).build()) .setCreatedAt(new Date().getTime()) diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java index 8b3fb566691..02d0ef9e6a9 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java @@ -24,13 +24,13 @@ import java.util.List; import java.util.Optional; import java.util.Set; import java.util.function.Consumer; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.resources.Qualifiers; import org.sonar.api.security.DefaultGroups; import org.sonar.api.web.UserRole; import org.sonar.core.util.Uuids; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.ce.CeTaskMessageType; @@ -432,7 +432,7 @@ public class UserDbTester { return keys .stream() .map(GlobalPermission::fromKey) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } // USER TOKEN |