@@ -22,7 +22,6 @@ package org.sonar.ce.queue; | |||
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.Nullable; | |||
import org.junit.Rule; | |||
@@ -398,7 +397,7 @@ public class CeQueueImplIT { | |||
.contains(dto1.getUuid()) | |||
.contains(uuids3) | |||
.contains(dto5.getUuid()) | |||
.containsAll(tasks.stream().map(CeTask::getUuid).collect(Collectors.toList())); | |||
.containsAll(tasks.stream().map(CeTask::getUuid).toList()); | |||
} | |||
@Test |
@@ -190,7 +190,7 @@ public class MetricRepositoryImplIT { | |||
public void getMetricsByType_givenRatingTypeAndWantedMilisecType_returnEmptyList() { | |||
IntStream.range(0, 1 + new Random().nextInt(12)) | |||
.mapToObj(i -> dbTester.measures().insertMetric(t -> t.setKey("key_enabled_" + i).setEnabled(true).setValueType("RATING"))) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
underTest.start(); | |||
assertThat(underTest.getMetricsByType(Metric.MetricType.MILLISEC)).isEmpty(); |
@@ -164,6 +164,6 @@ public class UpdateQualityProfilesLastUsedDateStepIT { | |||
return QPMeasureData.toJson(new QPMeasureData( | |||
Arrays.stream(keys) | |||
.map(key -> new QualityProfile(key, key, key, new Date())) | |||
.collect(Collectors.toList()))); | |||
.toList())); | |||
} | |||
} |
@@ -213,7 +213,7 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor | |||
private static Collection<QualityGate.Condition> convert(Set<Condition> conditions, Map<Condition, ConditionStatus> statusPerConditions) { | |||
return conditions.stream() | |||
.map(new ConditionToCondition(statusPerConditions)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static class ProjectAnalysisImpl implements PostProjectAnalysisTask.ProjectAnalysis { |
@@ -27,7 +27,6 @@ import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.function.Function; | |||
import java.util.function.UnaryOperator; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.io.FilenameUtils; | |||
@@ -252,7 +251,7 @@ public class ComponentTreeBuilder { | |||
return component.getChildren().stream() | |||
.map(ComponentTreeBuilder::buildChangedComponentTree) | |||
.filter(Objects::nonNull) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static ComponentImpl.Builder changedComponentBuilder(Component component, String newShortName) { |
@@ -23,7 +23,6 @@ import java.util.Collection; | |||
import java.util.LinkedList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import org.sonar.ce.task.projectanalysis.component.Component; | |||
import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit; | |||
@@ -113,7 +112,7 @@ public class IntegrateIssuesVisitor extends TypeAwareVisitorAdapter { | |||
private List<DefaultIssue> fillNewOpenIssues(Component component, Stream<DefaultIssue> newIssues, Input<DefaultIssue> rawInput) { | |||
List<DefaultIssue> newIssuesList = newIssues | |||
.peek(issueLifecycle::initNewOpenIssue) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
if (newIssuesList.isEmpty()) { | |||
return newIssuesList; |
@@ -78,7 +78,7 @@ public class SiblingsIssuesLoader { | |||
List<DefaultIssue> issues = dbClient.issueDao().selectByKeys(session, issuesByKey.keySet()) | |||
.stream() | |||
.map(IssueDto::toDefaultIssue) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
componentIssuesLoader.loadChanges(session, issues); | |||
return issues.stream() | |||
.collect(uniqueIndex(i -> issuesByKey.get(i.key()), i -> i, issues.size())); |
@@ -69,7 +69,7 @@ public class QualityGateServiceImpl implements QualityGateService { | |||
.map(metric -> new Condition(metric, input.getOperator(), input.getErrorThreshold())) | |||
.orElse(null)) | |||
.filter(Objects::nonNull) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
return new QualityGate(qualityGateDto.getUuid(), qualityGateDto.getName(), conditions); | |||
} |
@@ -155,7 +155,7 @@ public class PersistIssuesStep implements ComputationStep { | |||
}); | |||
// retrieve those of the updatedIssues which have not been updated and apply conflictResolver on them | |||
List<String> updatedIssueKeys = updatedIssues.stream().map(DefaultIssue::key).collect(Collectors.toList()); | |||
List<String> updatedIssueKeys = updatedIssues.stream().map(DefaultIssue::key).toList(); | |||
List<IssueDto> conflictIssueKeys = mapper.selectByKeysIfNotUpdatedAt(updatedIssueKeys, now); | |||
if (!conflictIssueKeys.isEmpty()) { | |||
Map<String, DefaultIssue> issuesByKeys = updatedIssues.stream().collect(uniqueIndex(DefaultIssue::key, updatedIssues.size())); |
@@ -54,7 +54,7 @@ public class LoadProjectStep implements ComputationStep { | |||
.orElseThrow(() -> MessageException.of(format("Project with key [%s] does not exist", descriptor.getKey()))); | |||
definitionHolder.setProjectDto(project); | |||
List<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, project).stream().collect(Collectors.toList()); | |||
List<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, project).stream().toList(); | |||
definitionHolder.setBranches(branches); | |||
} | |||
} |
@@ -22,7 +22,6 @@ package org.sonar.ce.task.projectanalysis.component; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.NoSuchElementException; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.StreamSupport; | |||
import static com.google.common.base.Preconditions.checkArgument; | |||
@@ -85,7 +84,7 @@ class CallRecorderPathAwareVisitor extends PathAwareVisitorAdapter<Integer> { | |||
} | |||
private static List<Integer> toValueList(Path<Integer> path) { | |||
return StreamSupport.stream(path.getCurrentPath().spliterator(), false).map(PathElement::element).collect(Collectors.toList()); | |||
return StreamSupport.stream(path.getCurrentPath().spliterator(), false).map(PathElement::element).toList(); | |||
} | |||
private static Integer getParent(Path<Integer> path) { |
@@ -118,7 +118,7 @@ public class SourceSimilarityImplTest { | |||
* Creates a list of {@code numberOfElements} int values as String, starting with zero. | |||
*/ | |||
private static List<String> listOf(int numberOfElements) { | |||
return IntStream.range(0, numberOfElements).mapToObj(String::valueOf).collect(Collectors.toList()); | |||
return IntStream.range(0, numberOfElements).mapToObj(String::valueOf).toList(); | |||
} | |||
@Test |
@@ -22,7 +22,6 @@ package org.sonar.ce.task.projectanalysis.issue; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.Nullable; | |||
import org.assertj.core.data.MapEntry; | |||
import org.junit.Rule; | |||
@@ -356,7 +355,7 @@ public class IssueCounterTest { | |||
private final void assertMeasures(Component componentRef, Map.Entry<String, Integer>... entries) { | |||
List<MeasureRepoEntry> expected = stream(entries) | |||
.map(e -> entryOf(e.getKey(), newMeasureBuilder().create(e.getValue()))) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
assertThat(measureRepository.getRawMeasures(componentRef).entrySet().stream().map(e -> entryOf(e.getKey(), e.getValue()))) | |||
.containsAll(expected); |
@@ -23,7 +23,6 @@ import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Random; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.IntStream; | |||
import java.util.stream.Stream; | |||
import org.junit.Rule; | |||
@@ -132,7 +131,7 @@ public class CeTaskMessagesImplIT { | |||
} | |||
}); | |||
underTest.addAll(Arrays.stream(messages).collect(Collectors.toList())); | |||
underTest.addAll(Arrays.stream(messages).toList()); | |||
assertThat(dbTester.select("select uuid as \"UUID\", task_uuid as \"TASK_UUID\", message as \"MESSAGE\", created_at as \"CREATED_AT\" from ce_task_message")) | |||
.extracting(t -> t.get("UUID"), t -> t.get("TASK_UUID"), t -> t.get("MESSAGE"), t -> t.get("CREATED_AT")) |
@@ -123,7 +123,7 @@ public class CeTasksMBeanImplTest { | |||
List<String> workerUuids = underTest.getWorkerUuids(); | |||
assertThat(workerUuids). | |||
isEqualTo(WORKERS.stream().map(CeWorker::getUUID).sorted().collect(Collectors.toList())) | |||
isEqualTo(WORKERS.stream().map(CeWorker::getUUID).sorted().toList()) | |||
// ImmutableSet can not be serialized | |||
.isNotInstanceOf(ImmutableSet.class); | |||
} | |||
@@ -146,7 +146,7 @@ public class CeTasksMBeanImplTest { | |||
List<String> enabledWorkerUuids = underTest.getEnabledWorkerUuids(); | |||
assertThat(enabledWorkerUuids) | |||
.isEqualTo(Stream.of(enabledWorkers).map(CeWorker::getUUID).sorted().collect(Collectors.toList())) | |||
.isEqualTo(Stream.of(enabledWorkers).map(CeWorker::getUUID).sorted().toList()) | |||
// ImmutableSet can not be serialized | |||
.isNotInstanceOf(ImmutableSet.class); | |||
} |
@@ -33,13 +33,12 @@ import java.util.Objects; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
import java.util.function.Function; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.Nullable; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.slf4j.LoggerFactory; | |||
import org.slf4j.event.Level; | |||
import org.sonar.api.testfixtures.log.LogTester; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.db.dialect.Oracle; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -59,10 +58,10 @@ import static org.mockito.Mockito.when; | |||
import static org.sonar.db.DatabaseUtils.ORACLE_DRIVER_NAME; | |||
import static org.sonar.db.DatabaseUtils.checkThatNotTooManyConditions; | |||
import static org.sonar.db.DatabaseUtils.closeQuietly; | |||
import static org.sonar.db.DatabaseUtils.getColumnMetadata; | |||
import static org.sonar.db.DatabaseUtils.getDriver; | |||
import static org.sonar.db.DatabaseUtils.log; | |||
import static org.sonar.db.DatabaseUtils.tableColumnExists; | |||
import static org.sonar.db.DatabaseUtils.getColumnMetadata; | |||
import static org.sonar.db.DatabaseUtils.tableExists; | |||
import static org.sonar.db.DatabaseUtils.toUniqueAndSortedList; | |||
@@ -354,7 +353,7 @@ public class DatabaseUtilsIT { | |||
List<String> outputs = DatabaseUtils.executeLargeInputs(inputs, input -> { | |||
// Check that each partition is only done on 1000 elements max | |||
assertThat(input).hasSizeLessThanOrEqualTo(1000); | |||
return input.stream().map(String::valueOf).collect(Collectors.toList()); | |||
return input.stream().map(String::valueOf).toList(); | |||
}); | |||
assertThat(outputs).isEqualTo(expectedOutputs); |
@@ -44,7 +44,6 @@ 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.apache.commons.dbutils.QueryRunner; | |||
@@ -391,7 +390,7 @@ public class AbstractDbTester<T extends TestDb> extends ExternalResource { | |||
columnNames.stream() | |||
.sorted(PkColumn.ORDERING_BY_INDEX) | |||
.map(PkColumn::getName) | |||
.collect(Collectors.toList())); | |||
.toList()); | |||
} | |||
} | |||
@@ -30,7 +30,6 @@ 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; | |||
@@ -918,7 +917,7 @@ public class CeActivityDaoIT { | |||
private List<String> selectPageOfUuids(Pagination pagination) { | |||
return underTest.selectByQuery(db.getSession(), new CeTaskQuery(), pagination).stream() | |||
.map(CeActivityToUuid.INSTANCE::apply) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private enum CeActivityToUuid implements Function<CeActivityDto, String> { |
@@ -29,7 +29,6 @@ import java.util.Map; | |||
import java.util.Optional; | |||
import java.util.Random; | |||
import java.util.function.Consumer; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import javax.annotation.Nullable; | |||
import org.junit.Rule; | |||
@@ -793,7 +792,7 @@ public class CeQueueDaoIT { | |||
} | |||
return res; | |||
} | |||
}).collect(Collectors.toList()); | |||
}).toList(); | |||
} | |||
private void verifyCeQueueStatuses(String[] taskUuids, CeQueueDto.Status[] statuses) { |
@@ -23,6 +23,7 @@ import com.google.common.collect.Sets; | |||
import com.tngtech.java.junit.dataprovider.DataProvider; | |||
import com.tngtech.java.junit.dataprovider.DataProviderRunner; | |||
import com.tngtech.java.junit.dataprovider.UseDataProvider; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
@@ -826,7 +827,7 @@ public class BranchDaoIT { | |||
public void doAnyOfComponentsNeedIssueSync_test_more_than_1000() { | |||
List<String> componentKeys = IntStream.range(0, 1100).mapToObj(value -> db.components().insertPrivateProject().getMainBranchComponent()) | |||
.map(ComponentDto::getKey) | |||
.collect(Collectors.toList()); | |||
.collect(Collectors.toCollection(ArrayList::new)); | |||
assertThat(underTest.doAnyOfComponentsNeedIssueSync(dbSession, componentKeys)).isFalse(); | |||
@@ -1390,7 +1390,7 @@ public class ComponentDaoIT { | |||
return underTest.selectByQuery(dbSession, builder.build(), 0, 5) | |||
.stream() | |||
.map(ComponentDto::uuid) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Test |
@@ -25,7 +25,6 @@ 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; | |||
@@ -1010,7 +1009,7 @@ public class GroupPermissionDaoIT { | |||
.stream() | |||
.flatMap(map -> map.entrySet().stream()) | |||
.map(entry -> (String) entry.getValue()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private ProjectData randomPublicOrPrivateProject() { |
@@ -160,7 +160,7 @@ public class ProjectDaoIT { | |||
applicationsId.add(x.getKey()); | |||
return tuple(x.getKey(), x.getName(), x.getUuid(), x.getDescription(), x.isPrivate()); | |||
}) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
List<ProjectDto> selectedApplications = projectDao.selectApplicationsByKeys(db.getSession(), applicationsId); | |||
@@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import java.time.ZoneOffset; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
@@ -1621,7 +1622,7 @@ public class PurgeDaoIT { | |||
private void verifyNoEffect(ComponentDto firstRoot, ComponentDto... otherRoots) { | |||
DbSession dbSession = mock(DbSession.class); | |||
List<ComponentDto> componentDtos = Stream.concat(Stream.of(firstRoot), Arrays.stream(otherRoots)).collect(Collectors.toList()); | |||
List<ComponentDto> componentDtos = Stream.concat(Stream.of(firstRoot), Arrays.stream(otherRoots)).collect(Collectors.toCollection(ArrayList::new)); | |||
Collections.shuffle(componentDtos); // order of collection must not matter | |||
underTest.deleteNonRootComponentsInView(dbSession, componentDtos); | |||
@@ -1940,7 +1941,7 @@ public class PurgeDaoIT { | |||
.setTaskUuid(uuid) | |||
.setKey("key_" + uuid.hashCode() + i) | |||
.setValue("value_" + uuid.hashCode() + i)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.ceTaskCharacteristicsDao().insert(dbSession, dtos); | |||
dbSession.commit(); | |||
} |
@@ -201,7 +201,7 @@ public class QualityProfileExportDaoIT { | |||
return IntStream.range(0, numberOfParams) | |||
.mapToObj(value -> db.rules().insertRuleParam(firstRule, | |||
ruleParamDto -> ruleParamDto.setName("name_" + firstRule.getUuid() + "_" + value))) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private RuleDto createRule(String language) { | |||
@@ -224,7 +224,7 @@ public class QualityProfileExportDaoIT { | |||
private List<ActiveRuleDto> activate(QProfileDto profile, RuleDto... rules) { | |||
return Stream.of(rules) | |||
.map(ruleDefinitionDto -> db.qualityProfiles().activateRule(profile, ruleDefinitionDto)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private ActiveRuleDto activate(QProfileDto profile, RuleDto rule, Collection<RuleParamDto> params) { |
@@ -129,7 +129,7 @@ public class ScimUserDaoIT { | |||
private List<String> toScimUsersUuids(Collection<ScimUserDto> scimUserDtos) { | |||
return scimUserDtos.stream() | |||
.map(ScimUserDto::getScimUserUuid) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Test | |||
@@ -165,7 +165,7 @@ public class ScimUserDaoIT { | |||
private List<ScimUserTestData> generateScimUsers(int totalScimUsers) { | |||
List<String> userNames = IntStream.range(0, totalScimUsers) | |||
.mapToObj(i -> "username_" + i) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
return insertScimUsersWithUsers(userNames); | |||
} | |||
@@ -348,7 +348,7 @@ public class ScimUserDaoIT { | |||
private List<ScimUserTestData> insertScimUsersWithUsers(List<String> userLogins) { | |||
return IntStream.range(0, userLogins.size()) | |||
.mapToObj(i -> insertScimUserWithUser(userLogins.get(i), String.valueOf(i + 1))) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private ScimUserTestData insertScimUserWithUser(String userLogin, String scimUuid) { |
@@ -106,7 +106,7 @@ public class SnapshotDao implements Dao { | |||
String.valueOf(fromDates.size())); | |||
List<ProjectUuidFromDatePair> projectUuidFromDatePairs = IntStream.range(0, projectUuids.size()) | |||
.mapToObj(i -> new ProjectUuidFromDatePair(projectUuids.get(i), fromDates.get(i))) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
return executeLargeInputs(projectUuidFromDatePairs, partition -> mapper(dbSession).selectFinishedByProjectUuidsAndFromDates(partition), i -> i / 2); | |||
} |
@@ -22,7 +22,6 @@ package org.sonar.db.es; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.core.util.UuidFactory; | |||
import org.sonar.db.Dao; | |||
@@ -65,7 +64,7 @@ public class EsQueueDao implements Dao { | |||
List<String> uuids = items.stream() | |||
.map(EsQueueDto::getUuid) | |||
.filter(Objects::nonNull) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
executeLargeUpdates(uuids, mapper::delete); | |||
} | |||
@@ -23,7 +23,6 @@ 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.db.Dao; | |||
@@ -40,7 +39,7 @@ public class IssueChangeDao implements Dao { | |||
return selectByTypeAndIssueKeys(session, singletonList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE) | |||
.stream() | |||
.map(IssueChangeDto::toFieldDiffs) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public List<IssueChangeDto> selectByTypeAndIssueKeys(DbSession session, Collection<String> issueKeys, String changeType) { |
@@ -76,7 +76,7 @@ public class UserPermissionDao implements Dao { | |||
// Pagination is done in Java because it's too complex to use SQL pagination in Oracle and MsSQL with the distinct | |||
.skip(query.getPageOffset()) | |||
.limit(query.getPageSize()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public int countUsersByQuery(DbSession dbSession, PermissionQuery query) { |
@@ -67,7 +67,7 @@ public class DefaultPeriodCleaner { | |||
} | |||
purgeDao.deleteAnalyses( | |||
session, profiler, | |||
snapshots.stream().map(PurgeableAnalysisDto::getAnalysisUuid).collect(Collectors.toList())); | |||
snapshots.stream().map(PurgeableAnalysisDto::getAnalysisUuid).toList()); | |||
return snapshots; | |||
} | |||
@@ -22,9 +22,8 @@ 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.api.utils.DateUtils; | |||
import org.sonar.db.purge.PurgeableAnalysisDto; | |||
class KeepWithVersionFilter implements Filter { | |||
@@ -40,7 +39,7 @@ class KeepWithVersionFilter implements Filter { | |||
return history.stream() | |||
.filter(analysis -> analysis.getDate().before(before)) | |||
.filter(KeepWithVersionFilter::isDeletable) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Override |
@@ -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(Collectors.toList()), | |||
return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).toList(), | |||
partition -> mapper(dbSession).selectByQualityGateAndGroups(qualityGate.getUuid(), partition)) | |||
.isEmpty(); | |||
} |
@@ -20,7 +20,6 @@ | |||
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; | |||
@@ -34,7 +33,7 @@ public class ActiveRuleCountQuery { | |||
private final String inheritance; | |||
public ActiveRuleCountQuery(Builder builder) { | |||
this.profileUuids = builder.profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList()); | |||
this.profileUuids = builder.profiles.stream().map(QProfileDto::getKee).toList(); | |||
this.ruleStatus = builder.ruleStatus; | |||
this.inheritance = builder.inheritance; | |||
} |
@@ -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(Collectors.toList()), partition -> mapper(dbSession).selectByQProfileAndGroups(profile.getKee(), partition)) | |||
return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).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(Collectors.toList()), | |||
return DatabaseUtils.executeLargeInputs(groups.stream().map(GroupDto::getUuid).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(Collectors.toList())); | |||
.toList()); | |||
if (deletedRows > 0) { | |||
partitionedProfiles.forEach(p -> auditPersister.deleteQualityProfileEditor(dbSession, new GroupEditorNewValue(p))); |
@@ -78,7 +78,7 @@ public class QProfileEditUsersDao implements Dao { | |||
int deletedRows = mapper(dbSession).deleteByQProfiles(partitionedProfiles | |||
.stream() | |||
.map(QProfileDto::getKee) | |||
.collect(Collectors.toList())); | |||
.toList()); | |||
if (deletedRows > 0) { | |||
partitionedProfiles.forEach(p -> auditPersister.deleteQualityProfileEditor(dbSession, new UserEditorNewValue(p))); |
@@ -177,7 +177,7 @@ public class QualityProfileDao implements Dao { | |||
} | |||
public List<QProfileDto> selectChildren(DbSession dbSession, Collection<QProfileDto> profiles) { | |||
List<String> uuids = profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList()); | |||
List<String> uuids = profiles.stream().map(QProfileDto::getKee).toList(); | |||
return DatabaseUtils.executeLargeInputs(uuids, chunk -> mapper(dbSession).selectChildren(chunk)); | |||
} | |||
@@ -209,7 +209,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(Collectors.toList()); | |||
List<String> profileUuids = profiles.stream().map(QProfileDto::getKee).toList(); | |||
return KeyLongValue.toMap(executeLargeInputs(profileUuids, partition -> mapper(dbSession).countProjectsByProfiles(partition))); | |||
} | |||
@@ -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(Collectors.toList()), | |||
users.stream().map(UserDto::getUuid).toList(), | |||
input -> { | |||
List<UserTokenCount> userTokenCounts = mapper(dbSession).countTokensByUserUuids(input); | |||
for (UserTokenCount userTokenCount : userTokenCounts) { |
@@ -75,7 +75,7 @@ public class DBSessionsImplTest { | |||
.thenReturn(expected[3]) | |||
.thenThrow(oneCallTooMuch()); | |||
assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).collect(Collectors.toList())) | |||
assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).toList()) | |||
.containsExactly(expected); | |||
} | |||
@@ -89,7 +89,7 @@ public class DBSessionsImplTest { | |||
.thenReturn(expected[3]) | |||
.thenThrow(oneCallTooMuch()); | |||
assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).collect(Collectors.toList())) | |||
assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).toList()) | |||
.containsExactly(expected); | |||
} | |||
@@ -22,7 +22,6 @@ package org.sonar.db.purge.period; | |||
import java.util.Arrays; | |||
import java.util.Calendar; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.db.purge.DbCleanerTestUtils; | |||
@@ -33,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class KeepOneFilterTest { | |||
private static List<String> analysisUuids(List<PurgeableAnalysisDto> snapshotDtos) { | |||
return snapshotDtos.stream().map(PurgeableAnalysisDto::getAnalysisUuid).collect(Collectors.toList()); | |||
return snapshotDtos.stream().map(PurgeableAnalysisDto::getAnalysisUuid).toList(); | |||
} | |||
@Test |
@@ -107,7 +107,7 @@ public class ScimGroupDaoTest { | |||
private static List<String> toExpectedscimGroupUuids(List<String> expectedScimGroupUuidSuffixes) { | |||
return expectedScimGroupUuidSuffixes.stream() | |||
.map(expectedScimGroupUuidSuffix -> "scim_uuid_Scim Group" + expectedScimGroupUuidSuffix) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Test | |||
@@ -179,7 +179,7 @@ public class ScimGroupDaoTest { | |||
private static List<String> toScimGroupsUuids(Collection<ScimGroupDto> scimGroupDtos) { | |||
return scimGroupDtos.stream() | |||
.map(ScimGroupDto::getScimGroupUuid) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Test |
@@ -23,7 +23,6 @@ import com.google.common.base.Joiner; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Random; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.IntStream; | |||
import org.junit.Test; | |||
import org.sonar.db.protobuf.DbFileSources; | |||
@@ -109,7 +108,7 @@ public class FileSourceDtoTest { | |||
public void setLineHashes_sets_lineCount_to_size_of_list_and_rawLineHashes_to_join_by_line_return() { | |||
FileSourceDto underTest = new FileSourceDto(); | |||
int expected = 1 + new Random().nextInt(96); | |||
List<String> lineHashes = IntStream.range(0, expected).mapToObj(String::valueOf).collect(Collectors.toList()); | |||
List<String> lineHashes = IntStream.range(0, expected).mapToObj(String::valueOf).toList(); | |||
underTest.setLineHashes(lineHashes); | |||
assertThat(underTest.getLineCount()).isEqualTo(expected); |
@@ -49,7 +49,7 @@ public class NotificationDbTester { | |||
.setUserUuid(userUuid) | |||
.build(), dbSession).stream() | |||
.filter(prop -> project == null ? prop.getEntityUuid() == null : prop.getEntityUuid() != null) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
assertThat(result).hasSize(1); | |||
assertThat(result.get(0).getValue()).isEqualTo("true"); | |||
} |
@@ -23,7 +23,6 @@ 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; | |||
@@ -49,7 +48,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(Collectors.toList())) | |||
.setLineHashes(IntStream.range(0, new Random().nextInt(21)).mapToObj(String::valueOf).toList()) | |||
.setRevision(randomAlphanumeric(100)) | |||
.setSourceData(newRandomData(3).build()) | |||
.setCreatedAt(new Date().getTime()) | |||
@@ -69,7 +68,7 @@ public class FileSourceTester { | |||
.setFileUuid(file.uuid()) | |||
.setSrcHash(randomAlphanumeric(50)) | |||
.setDataHash(randomAlphanumeric(50)) | |||
.setLineHashes(IntStream.range(0, numLines).mapToObj(String::valueOf).collect(Collectors.toList())) | |||
.setLineHashes(IntStream.range(0, numLines).mapToObj(String::valueOf).toList()) | |||
.setRevision(randomAlphanumeric(100)) | |||
.setSourceData(newRandomData(numLines).build()) | |||
.setCreatedAt(new Date().getTime()) |
@@ -432,7 +432,7 @@ public class UserDbTester { | |||
return keys | |||
.stream() | |||
.map(GlobalPermission::fromKey) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
// USER TOKEN |
@@ -101,7 +101,7 @@ public class MigrationHistoryImpl implements MigrationHistory { | |||
} | |||
return res.stream() | |||
.sorted(Comparator.naturalOrder()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
} | |||
} |
@@ -27,7 +27,6 @@ import java.util.Collection; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.db.dialect.Dialect; | |||
@@ -68,7 +67,7 @@ public class CreateTableBuilder { | |||
checkState(!columnDefs.isEmpty() || !pkColumnDefs.isEmpty(), "at least one column must be specified"); | |||
return Stream.concat(of(createTableStatement()), createOracleAutoIncrementStatements()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public CreateTableBuilder addColumn(ColumnDef columnDef) { |
@@ -23,7 +23,6 @@ import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.sonar.db.dialect.Dialect; | |||
import org.sonar.db.dialect.H2; | |||
import org.sonar.db.dialect.MsSql; | |||
@@ -58,7 +57,7 @@ public class DropColumnsBuilder { | |||
case Oracle.ID: | |||
return Collections.singletonList(getOracleStatement()); | |||
case H2.ID: | |||
return Arrays.stream(columns).map(this::getMsSQLStatement).collect(Collectors.toList()); | |||
return Arrays.stream(columns).map(this::getMsSQLStatement).toList(); | |||
default: | |||
throw new IllegalStateException(String.format("Unsupported database '%s'", dialect.getId())); | |||
} |
@@ -54,7 +54,7 @@ public class MigrationStepRegistryImpl implements InternalMigrationStepRegistry | |||
return migrations.entrySet().stream() | |||
.sorted(Comparator.comparingLong(Map.Entry::getKey)) | |||
.map(Map.Entry::getValue) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
} |
@@ -77,7 +77,7 @@ public class MigrationHistoryMeddlerTest { | |||
when(migrationHistory.getLastMigrationNumber()).thenReturn(Optional.of(oldVersion)); | |||
List<RegisteredMigrationStep> stepsFromNewLastMigrationNumber = IntStream.range(0, 1 + new Random().nextInt(30)) | |||
.mapToObj(i -> new RegisteredMigrationStep(i, "desc_" + i, MigrationStep.class)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
when(migrationSteps.readFrom(expectedNewVersion)).thenReturn(stepsFromNewLastMigrationNumber); | |||
underTest.meddle(migrationHistory); |
@@ -228,7 +228,7 @@ public class PopulateInitialSchemaTest { | |||
"where u.login='admin'"); | |||
List<String> groupNames = rows.stream() | |||
.map(row -> (String) row.get("groupName")) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
assertThat(groupNames).containsOnly("sonar-administrators", "sonar-users"); | |||
} | |||
@@ -75,7 +75,7 @@ public class UpdateUserLocalValueInUsersTest { | |||
String selectSql = String.format("select USER_LOCAL from users where uuid='%s'", userUuid); | |||
assertThat(db.select(selectSql).stream() | |||
.map(row -> row.get("USER_LOCAL")) | |||
.collect(Collectors.toList())) | |||
.toList()) | |||
.containsExactlyInAnyOrder(expected); | |||
} | |||
@@ -79,7 +79,7 @@ public class UpdateIsMainColumnInProjectBranchesTest { | |||
String selectSql = String.format("select is_main from project_branches where uuid='%s'", branchUuid); | |||
assertThat(db.select(selectSql).stream() | |||
.map(row -> row.get("IS_MAIN")) | |||
.collect(Collectors.toList())) | |||
.toList()) | |||
.containsExactlyInAnyOrder(isMain); | |||
} | |||
@@ -26,7 +26,6 @@ import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import java.util.Properties; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.StringUtils; | |||
@@ -108,7 +107,7 @@ public class EsInstallation { | |||
String dataPath = props.nonNullValue(PATH_DATA.getKey()); | |||
return Stream.of("es", "es5", "es6", "es7") | |||
.map(t -> new File(dataPath, t)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static File buildDataDir(Props props) { |
@@ -26,7 +26,6 @@ import java.util.concurrent.ExecutionException; | |||
import java.util.concurrent.ScheduledExecutorService; | |||
import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.TimeoutException; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.IntStream; | |||
import org.junit.Test; | |||
@@ -40,7 +39,7 @@ public class DelegateHealthStateRefresherExecutorServiceTest { | |||
private Callable callable = mock(Callable.class); | |||
private Collection<Callable<Object>> callables = IntStream.range(0, random.nextInt(5)) | |||
.mapToObj(i -> (Callable<Object>) mock(Callable.class)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
private int initialDelay = random.nextInt(333); | |||
private int delay = random.nextInt(333); | |||
private int period = random.nextInt(333); |
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap; | |||
import com.tngtech.java.junit.dataprovider.DataProvider; | |||
import com.tngtech.java.junit.dataprovider.DataProviderRunner; | |||
import com.tngtech.java.junit.dataprovider.UseDataProvider; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
@@ -376,7 +377,7 @@ public class JvmOptionsTest { | |||
} | |||
private static Map<String, String> shuffleThenToMap(Stream<Option> stream) { | |||
List<Option> options = stream.collect(Collectors.toList()); | |||
List<Option> options = stream.collect(Collectors.toCollection(ArrayList::new)); | |||
Collections.shuffle(options); | |||
Map<String, String> res = new HashMap<>(options.size()); | |||
for (Option option : options) { |
@@ -66,7 +66,7 @@ public class LoggingRule extends ExternalResource { | |||
return TestLogbackAppender.events.stream() | |||
.filter(e -> e.getLoggerName().equals(loggerClass.getName())) | |||
.map(LoggingEvent::getFormattedMessage) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public List<String> getLogs(Level level) { | |||
@@ -74,7 +74,7 @@ public class LoggingRule extends ExternalResource { | |||
.filter(e -> e.getLoggerName().equals(loggerClass.getName())) | |||
.filter(e -> e.getLevel().levelStr.equals(level.name())) | |||
.map(LoggingEvent::getFormattedMessage) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public boolean hasLog(Level level, String message) { |
@@ -129,12 +129,12 @@ public class HazelcastMemberImplTest { | |||
.map(answer::getFailed) | |||
.filter(Optional::isPresent) | |||
.map(Optional::get) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static List<Boolean> extractTimeOuts(DistributedAnswer<Long> answer) { | |||
return answer.getMembers().stream() | |||
.map(answer::hasTimedOut) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
} |
@@ -22,7 +22,6 @@ package org.sonar.process.systeminfo; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.junit.Test; | |||
import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo; | |||
@@ -44,7 +43,7 @@ public class JvmPropertiesSectionTest { | |||
List<String> keys = section.getAttributesList() | |||
.stream() | |||
.map(ProtobufSystemInfo.Attribute::getKey) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
assertThat(keys).contains("java.vm.vendor", "os.name"); | |||
List<String> sortedKeys = new ArrayList<>(keys); |
@@ -53,7 +53,7 @@ public class SystemInfoUtilsTest { | |||
List<String> ordered = SystemInfoUtils.order(sections, "foo", "bar").stream() | |||
.map(Section::getName) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
assertThat(ordered).isEqualTo(asList("foo", "bar", "end1", "end2")); | |||
} | |||
@@ -26,7 +26,6 @@ import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.function.Predicate; | |||
import java.util.stream.Collectors; | |||
import org.assertj.core.api.Assertions; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.junit.Rule; | |||
@@ -638,7 +637,7 @@ public class IssueIndexerIT { | |||
private void assertThatDbHasOnly(IssueDto... expectedIssues) { | |||
try (DbSession otherSession = db.getDbClient().openSession(false)) { | |||
List<String> keys = Arrays.stream(expectedIssues).map(IssueDto::getKey).collect(Collectors.toList()); | |||
List<String> keys = Arrays.stream(expectedIssues).map(IssueDto::getKey).toList(); | |||
assertThat(db.getDbClient().issueDao().selectByKeys(otherSession, keys)).hasSize(expectedIssues.length); | |||
} | |||
} |
@@ -22,7 +22,6 @@ package org.sonar.server.qualityprofile.index; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.assertj.core.groups.Tuple; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
@@ -197,7 +196,7 @@ public class ActiveRuleIndexerIT { | |||
private void commitAndIndex(RuleDto rule, ActiveRuleDto... ar) { | |||
underTest.commitAndIndex(db.getSession(), stream(ar) | |||
.map(a -> new ActiveRuleChange(ActiveRuleChange.Type.ACTIVATED, a, rule)) | |||
.collect(Collectors.toList())); | |||
.toList()); | |||
} | |||
private void verifyOnlyIndexed(ActiveRuleDto... expected) { |
@@ -21,7 +21,6 @@ package org.sonar.server.component.index; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import java.util.stream.Collectors; | |||
import org.elasticsearch.common.text.Text; | |||
import org.elasticsearch.search.SearchHit; | |||
@@ -59,7 +58,7 @@ public class ComponentHit { | |||
public static List<ComponentHit> fromSearchHits(SearchHit... hits) { | |||
return stream(hits) | |||
.map(ComponentHit::new) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public Optional<String> getHighlightedText() { |
@@ -122,7 +122,7 @@ public class EntityDefinitionIndexer implements EventIndexer, AnalysisIndexer, N | |||
private static List<EsQueueDto> createEsQueueDtosFromEntities(Collection<String> entityUuids) { | |||
return entityUuids.stream() | |||
.map(entityUuid -> EsQueueDto.create(TYPE_COMPONENT.format(), entityUuid, null, entityUuid)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Override |
@@ -31,7 +31,6 @@ import java.util.NoSuchElementException; | |||
import java.util.Queue; | |||
import java.util.function.Function; | |||
import java.util.regex.Pattern; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.elasticsearch.action.search.SearchResponse; | |||
@@ -79,7 +78,7 @@ public class EsUtils { | |||
return terms.getBuckets() | |||
.stream() | |||
.map(Terms.Bucket::getKeyAsString) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@CheckForNull |
@@ -62,7 +62,7 @@ public class OneToOneResilientIndexingListener implements IndexingListener { | |||
.map(itemsById::get) | |||
.flatMap(Collection::stream) | |||
.filter(Objects::nonNull) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.esQueueDao().delete(dbSession, itemsToDelete); | |||
dbSession.commit(); | |||
} |
@@ -79,7 +79,7 @@ public class Sorting { | |||
boolean effectiveMissingLast = asc == field.missingLast; | |||
sortBuilder.missing(effectiveMissingLast ? "_last" : "_first"); | |||
return sortBuilder; | |||
}).collect(Collectors.toList()); | |||
}).toList(); | |||
} | |||
public static class Field { |
@@ -23,7 +23,6 @@ import java.util.List; | |||
import java.util.Locale; | |||
import java.util.Set; | |||
import java.util.concurrent.atomic.AtomicBoolean; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.elasticsearch.index.query.BoolQueryBuilder; | |||
@@ -71,7 +70,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF | |||
if (tokens.isEmpty()) { | |||
return Stream.empty(); | |||
} | |||
List<String> lowerCaseTokens = tokens.stream().map(t -> t.toLowerCase(Locale.ENGLISH)).collect(Collectors.toList()); | |||
List<String> lowerCaseTokens = tokens.stream().map(t -> t.toLowerCase(Locale.ENGLISH)).toList(); | |||
BoolQueryBuilder queryBuilder = prefixAndPartialQuery(lowerCaseTokens, query.getFieldName(), SEARCH_PREFIX_CASE_INSENSITIVE_ANALYZER) | |||
.boost(2F); | |||
return Stream.of(queryBuilder); |
@@ -21,7 +21,6 @@ package org.sonar.server.es.textsearch; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.server.es.newindex.DefaultIndexSettings; | |||
@@ -41,6 +40,6 @@ public class JavaTokenizer { | |||
queryText.split(DefaultIndexSettings.SEARCH_TERM_TOKENIZER_PATTERN)) | |||
.filter(StringUtils::isNotEmpty) | |||
.filter(s -> s.length() >= MINIMUM_NGRAM_LENGTH) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
} |
@@ -198,7 +198,7 @@ public class NewIssuesNotification extends Notification { | |||
.filter(i -> biggerCriteria.applyAsInt(i.getValue()) > 0) | |||
.sorted(comparator.reversed()) | |||
.limit(5) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public NewIssuesNotification setDebt(Duration debt) { |
@@ -25,7 +25,6 @@ import java.util.Date; | |||
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.server.es.BaseDoc; | |||
@@ -118,10 +117,10 @@ public class ProjectMeasuresDoc extends BaseDoc { | |||
public ProjectMeasuresDoc setMeasuresFromMap(Map<String, Double> measures) { | |||
setMeasures( | |||
measures.entrySet().stream() | |||
.map(entry -> ImmutableMap.<String, Object>of( | |||
.map(entry -> Map.<String, Object>of( | |||
SUB_FIELD_MEASURES_KEY, entry.getKey(), | |||
SUB_FIELD_MEASURES_VALUE, entry.getValue())) | |||
.collect(Collectors.toList())); | |||
.toList()); | |||
return this; | |||
} | |||
@@ -142,10 +141,10 @@ public class ProjectMeasuresDoc extends BaseDoc { | |||
public ProjectMeasuresDoc setNclocLanguageDistributionFromMap(Map<String, Integer> distribution) { | |||
setNclocLanguageDistribution( | |||
distribution.entrySet().stream() | |||
.map(entry -> ImmutableMap.<String, Object>of( | |||
.map(entry -> Map.<String, Object>of( | |||
SUB_FIELD_DISTRIB_LANGUAGE, entry.getKey(), | |||
SUB_FIELD_DISTRIB_NCLOC, entry.getValue())) | |||
.collect(Collectors.toList())); | |||
.toList()); | |||
return this; | |||
} | |||
@@ -23,7 +23,6 @@ import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
@@ -129,14 +128,14 @@ public class ProjectMeasuresIndexer implements EventIndexer, AnalysisIndexer, Ne | |||
private Collection<EsQueueDto> prepareForRecovery(DbSession dbSession, Collection<String> entityUuids) { | |||
List<EsQueueDto> items = entityUuids.stream() | |||
.map(entityUuid -> EsQueueDto.create(TYPE_PROJECT_MEASURES.format(), entityUuid, null, entityUuid)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
return dbClient.esQueueDao().insert(dbSession, items); | |||
} | |||
public IndexingResult commitAndIndex(DbSession dbSession, Collection<String> projectUuids) { | |||
List<EsQueueDto> items = projectUuids.stream() | |||
.map(projectUuid -> EsQueueDto.create(TYPE_PROJECT_MEASURES.format(), projectUuid, null, projectUuid)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.esQueueDao().insert(dbSession, items); | |||
dbSession.commit(); | |||
@@ -153,27 +152,26 @@ public class ProjectMeasuresIndexer implements EventIndexer, AnalysisIndexer, Ne | |||
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, listener); | |||
bulkIndexer.start(); | |||
List<String> projectUuids = items.stream().map(EsQueueDto::getDocId).collect(Collectors.toList()); | |||
Iterator<String> it = projectUuids.iterator(); | |||
while (it.hasNext()) { | |||
String projectUuid = it.next(); | |||
List<String> projectUuids = items.stream().map(EsQueueDto::getDocId).toList(); | |||
List<String> projectToDelete = new ArrayList<>(projectUuids); | |||
for (String projectUuid : projectUuids) { | |||
try (ProjectMeasuresIndexerIterator rowIt = ProjectMeasuresIndexerIterator.create(dbSession, projectUuid)) { | |||
while (rowIt.hasNext()) { | |||
bulkIndexer.add(toProjectMeasuresDoc(rowIt.next()).toIndexRequest()); | |||
it.remove(); | |||
projectToDelete.remove(projectUuid); | |||
} | |||
} | |||
} | |||
// the remaining uuids reference projects that don't exist in db. They must be deleted from index. | |||
projectUuids.forEach(projectUuid -> bulkIndexer.addDeletion(TYPE_PROJECT_MEASURES, projectUuid, AuthorizationDoc.idOf(projectUuid))); | |||
projectToDelete.forEach(projectUuid -> bulkIndexer.addDeletion(TYPE_PROJECT_MEASURES, projectUuid, AuthorizationDoc.idOf(projectUuid))); | |||
return bulkIndexer.stop(); | |||
} | |||
private void doIndex(Size size, @Nullable String branchUuid) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
String projectUuid = null; | |||
if (branchUuid != null) { |
@@ -97,7 +97,7 @@ public class ActiveRuleIndexer implements ResilientIndexer { | |||
List<EsQueueDto> items = changes.stream() | |||
.map(ActiveRuleChange::getActiveRule) | |||
.map(ar -> newQueueDto(docIdOf(ar.getUuid()), ID_TYPE_ACTIVE_RULE_UUID, ar.getRuleUuid())) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.esQueueDao().insert(dbSession, items); | |||
dbSession.commit(); | |||
@@ -109,7 +109,7 @@ public class ActiveRuleIndexer implements ResilientIndexer { | |||
.map(QProfileDto::getRulesProfileUuid) | |||
.distinct() | |||
.map(ruleProfileUuid -> newQueueDto(ruleProfileUuid, ID_TYPE_RULE_PROFILE_UUID, null)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.esQueueDao().insert(dbSession, items); | |||
dbSession.commit(); |
@@ -142,7 +142,7 @@ public class RuleIndex { | |||
public static final List<String> ALL_STATUSES_EXCEPT_REMOVED = Arrays.stream(RuleStatus.values()) | |||
.filter(status -> !RuleStatus.REMOVED.equals(status)) | |||
.map(RuleStatus::toString) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
private static final String AGGREGATION_NAME_FOR_TAGS = "tagsAggregation"; | |||
@@ -290,7 +290,7 @@ public class RuleIndex { | |||
Collection<RuleType> types = query.getTypes(); | |||
if (isNotEmpty(types)) { | |||
List<String> typeNames = types.stream().map(RuleType::toString).collect(Collectors.toList()); | |||
List<String> typeNames = types.stream().map(RuleType::toString).toList(); | |||
filters.put(FIELD_RULE_TYPE, | |||
QueryBuilders.termsQuery(FIELD_RULE_TYPE, typeNames)); | |||
} |
@@ -89,7 +89,7 @@ public class RuleIndexer implements ResilientIndexer { | |||
public void commitAndIndex(DbSession dbSession, Collection<String> ruleUuids) { | |||
List<EsQueueDto> items = ruleUuids.stream() | |||
.map(RuleIndexer::createQueueDtoForRule) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.esQueueDao().insert(dbSession, items); | |||
dbSession.commit(); |
@@ -392,7 +392,7 @@ public final class SecurityStandards { | |||
.stream() | |||
.filter(k -> cwe.stream().anyMatch(CWES_BY_SQ_CATEGORY.get(k)::contains)) | |||
.sorted(SQ_CATEGORY_ORDERING) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
return result.isEmpty() ? singletonList(SQCategory.OTHERS) : result; | |||
} | |||
@@ -170,7 +170,7 @@ public class ViewIndexer implements ResilientIndexer { | |||
public void delete(DbSession dbSession, Collection<String> viewUuids) { | |||
List<EsQueueDto> items = viewUuids.stream() | |||
.map(l -> EsQueueDto.create(TYPE_VIEW.format(), l)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.esQueueDao().insert(dbSession, items); | |||
dbSession.commit(); |
@@ -106,7 +106,7 @@ public class WebHooksImpl implements WebHooks { | |||
List<Webhook> webhooks = readWebHooksFrom(analysis.projectUuid(), taskLogStatistics) | |||
.map(dto -> new Webhook(dto.getUuid(), analysis.projectUuid(), analysis.ceTaskUuid(), analysis.analysisUuid(), | |||
dto.getName(), dto.getUrl(), dto.getSecret())) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
if (webhooks.isEmpty()) { | |||
return; | |||
} |
@@ -21,7 +21,6 @@ package org.sonar.server.es.searchrequest; | |||
import java.util.List; | |||
import java.util.Random; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.IntStream; | |||
import java.util.stream.Stream; | |||
import org.assertj.core.api.ThrowableAssert.ThrowingCallable; | |||
@@ -97,7 +96,7 @@ public class AllFiltersTest { | |||
allFilters.addFilter(name, mock(FilterScope.class), query) | |||
.addFilter(name2, mock(FilterScope.class), null); | |||
List<QueryBuilder> all = allFilters.stream().collect(Collectors.toList()); | |||
List<QueryBuilder> all = allFilters.stream().toList(); | |||
assertThat(all).hasSize(1); | |||
assertThat(all.iterator().next()).isSameAs(query); | |||
} |
@@ -26,7 +26,6 @@ import java.util.Calendar; | |||
import java.util.Collection; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.time.DateUtils; | |||
@@ -293,7 +292,7 @@ public class IssueWorkflowForSecurityHotspotsTest { | |||
} | |||
private Collection<String> keys(List<Transition> transitions) { | |||
return transitions.stream().map(Transition::key).collect(Collectors.toList()); | |||
return transitions.stream().map(Transition::key).toList(); | |||
} | |||
private static void setStatusPreviousToClosed(DefaultIssue hotspot, String previousStatus, @Nullable String previousResolution, @Nullable String newResolution) { |
@@ -57,7 +57,7 @@ public class NotificationServiceTest { | |||
NotificationHandler handler = getMockOfNotificationHandlerForType(Notification1.class); | |||
List<Notification> notifications = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification("i")) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
NotificationService underTest = new NotificationService(dbClient, new NotificationHandler[]{handler}); | |||
assertThatThrownBy(() -> underTest.deliverEmails(notifications)) | |||
@@ -69,7 +69,7 @@ public class NotificationServiceTest { | |||
public void deliverEmails_collection_has_no_effect_if_no_handler_nor_dispatcher() { | |||
List<Notification> notifications = IntStream.range(0, 10) | |||
.mapToObj(i -> mock(Notification.class)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
NotificationService underTest = new NotificationService(dbClient); | |||
assertThat(underTest.deliverEmails(notifications)).isZero(); | |||
@@ -81,7 +81,7 @@ public class NotificationServiceTest { | |||
NotificationDispatcher dispatcher = mock(NotificationDispatcher.class); | |||
List<Notification> notifications = IntStream.range(0, 10) | |||
.mapToObj(i -> mock(Notification.class)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
NotificationService underTest = new NotificationService(dbClient, new NotificationDispatcher[]{dispatcher}); | |||
assertThat(underTest.deliverEmails(notifications)).isZero(); | |||
@@ -106,10 +106,10 @@ public class NotificationServiceTest { | |||
NotificationHandler<Notification2> handler2 = getMockOfNotificationHandlerForType(Notification2.class); | |||
List<Notification1> notification1s = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification1()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
List<Notification2> notification2s = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification2()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
NotificationService noHandler = new NotificationService(dbClient); | |||
NotificationService onlyHandler1 = new NotificationService(dbClient, new NotificationHandler[]{handler1}); | |||
NotificationService onlyHandler2 = new NotificationService(dbClient, new NotificationHandler[]{handler2}); | |||
@@ -128,10 +128,10 @@ public class NotificationServiceTest { | |||
NotificationHandler<Notification2> handler2 = getMockOfNotificationHandlerForType(Notification2.class); | |||
List<Notification1> notification1s = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification1()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
List<Notification2> notification2s = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification2()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
NotificationService onlyHandler1 = new NotificationService(dbClient, new NotificationHandler[]{handler1}); | |||
NotificationService onlyHandler2 = new NotificationService(dbClient, new NotificationHandler[]{handler2}); | |||
NotificationService bothHandlers = new NotificationService(dbClient, new NotificationHandler[]{handler1, handler2}); | |||
@@ -169,10 +169,10 @@ public class NotificationServiceTest { | |||
List<Notification1> notification1s = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification1()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
List<Notification2> notification2s = IntStream.range(0, 10) | |||
.mapToObj(i -> new Notification2()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
NotificationService onlyHandler1A = new NotificationService(dbClient, new NotificationHandler[]{handler1A}); | |||
NotificationService onlyHandler1B = new NotificationService(dbClient, new NotificationHandler[]{handler1B}); | |||
NotificationService bothHandlers = new NotificationService(dbClient, new NotificationHandler[]{handler1A, handler1B}); |
@@ -127,14 +127,14 @@ public class SecurityStandardsTest { | |||
@Test | |||
public void pciDss_categories_check() { | |||
List<String> pciDssCategories = Arrays.stream(PciDss.values()).map(PciDss::category).collect(Collectors.toList()); | |||
List<String> pciDssCategories = Arrays.stream(PciDss.values()).map(PciDss::category).toList(); | |||
assertThat(pciDssCategories).hasSize(12).containsExactly("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"); | |||
} | |||
@Test | |||
public void owaspAsvs_categories_check() { | |||
List<String> owaspAsvsCategories = Arrays.stream(OwaspAsvs.values()).map(OwaspAsvs::category).collect(Collectors.toList()); | |||
List<String> owaspAsvsCategories = Arrays.stream(OwaspAsvs.values()).map(OwaspAsvs::category).toList(); | |||
assertThat(owaspAsvsCategories).hasSize(14).containsExactly("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"); | |||
} |
@@ -616,11 +616,11 @@ public class TelemetryDataJsonWriterTest { | |||
.mapToObj( | |||
i -> new UserTelemetryDto().setUuid("uuid-" + i).setActive(i % 2 == 0).setLastConnectionDate(1L) | |||
.setLastSonarlintConnectionDate(2L).setExternalIdentityProvider("gitlab").setScimUuid(i % 2 == 0 ? "scim-uuid-" + i : null)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static List<TelemetryData.Project> attachProjects() { | |||
return IntStream.range(0, 3).mapToObj(i -> new TelemetryData.Project("uuid-" + i, 1L, "lang-" + i, (i + 1L) * 2L)).collect(Collectors.toList()); | |||
return IntStream.range(0, 3).mapToObj(i -> new TelemetryData.Project("uuid-" + i, 1L, "lang-" + i, (i + 1L) * 2L)).toList(); | |||
} | |||
private static List<TelemetryData.ProjectStatistics> attachProjectStatsWithMetrics() { |
@@ -105,7 +105,7 @@ public class PluginDownloader implements Startable { | |||
return listPlugins(this.downloadDir) | |||
.stream() | |||
.map(PluginInfo::create) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public void download(String pluginKey, Version version) { |
@@ -99,7 +99,7 @@ public class PluginUninstaller implements Startable { | |||
public Collection<PluginInfo> getUninstalledPlugins() { | |||
return listJarFiles(fs.getUninstalledPluginsDir()).stream() | |||
.map(PluginInfo::create) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static Collection<File> listJarFiles(File dir) { |
@@ -29,7 +29,7 @@ public enum Visibility { | |||
PRIVATE(true, "private"), | |||
PUBLIC(false, "public"); | |||
private static final List<String> LABELS = stream(values()).map(Visibility::getLabel).collect(Collectors.toList()); | |||
private static final List<String> LABELS = stream(values()).map(Visibility::getLabel).toList(); | |||
private final boolean isPrivate; | |||
private final String label; |
@@ -125,7 +125,7 @@ public class CachingRuleFinder implements ServerRuleFinder { | |||
.filter(entry -> matchQuery(entry.getKey(), query)) | |||
.sorted(FIND_BY_QUERY_ORDER) | |||
.map(Map.Entry::getValue) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private static boolean matchQuery(RuleDto ruleDto, RuleQuery ruleQuery) { |
@@ -207,7 +207,7 @@ public class QGChangeEventListenersImplTest { | |||
Arrays.stream(component4Issues), | |||
Stream.of(component5Issue)) | |||
.flatMap(s -> s) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
List<DefaultIssue> changedIssues = randomizedList(issues); | |||
List<QGChangeEvent> qgChangeEvents = Stream.of( | |||
@@ -216,7 +216,7 @@ public class QGChangeEventListenersImplTest { | |||
Arrays.stream(component3QGChangeEvents), | |||
Arrays.stream(component4QGChangeEvents)) | |||
.flatMap(s -> s) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
underTest.broadcastOnIssueChange(changedIssues, randomizedList(qgChangeEvents), false); | |||
@@ -23,7 +23,6 @@ import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.web.UserRole; | |||
@@ -164,7 +163,7 @@ public abstract class AbstractUserSession implements UserSession { | |||
boolean allowPublicComponent = PUBLIC_PERMISSIONS.contains(permission); | |||
return components.stream() | |||
.filter(c -> (allowPublicComponent && !c.isPrivate()) || hasComponentPermission(permission, c)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
@Override |
@@ -374,7 +374,7 @@ public class ServerUserSession extends AbstractUserSession { | |||
return authorizedProjectUuids.contains(c.branchUuid()) || authorizedProjectUuids.contains( | |||
getEntityUuid(dbSession, c)); | |||
}) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
} | |||
@@ -403,7 +403,7 @@ public class UserUpdater { | |||
.map(Strings::emptyToNull) | |||
.filter(Objects::nonNull) | |||
.sorted(String::compareToIgnoreCase) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
return emptyList(); | |||
} |
@@ -23,7 +23,6 @@ import com.google.common.base.Joiner; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
@@ -380,7 +379,7 @@ public class AuthenticationEventImplTest { | |||
.thenReturn(Collections.enumeration( | |||
Arrays.stream(remoteIps) | |||
.map(Joiner.on(",")::join) | |||
.collect(Collectors.toList()))); | |||
.toList())); | |||
return res; | |||
} | |||
} |
@@ -239,7 +239,7 @@ public class WebhookQGChangeEventListenerIT { | |||
.setAnalysisUuid(snapshotUuid) | |||
.setKey(entry.getKey()) | |||
.setValue(entry.getValue())) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbTester.getDbClient().analysisPropertiesDao().insert(dbTester.getSession(), analysisProperties); | |||
dbTester.getSession().commit(); | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.server.platform; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
@@ -47,7 +48,7 @@ public class StandaloneSystemInfoWriter extends AbstractSystemInfoWriter { | |||
List<ProtobufSystemInfo.Section> sections = stream(systemInfoSections) | |||
.map(SystemInfoSection::toProtobuf) | |||
.collect(Collectors.toList()); | |||
.collect(Collectors.toCollection(ArrayList::new)); | |||
ceHttpClient.retrieveSystemInfo() | |||
.ifPresent(ce -> sections.addAll(ce.getSectionsList())); | |||
@@ -316,7 +316,7 @@ public class RegisterRules implements Startable { | |||
} | |||
private void persistRepositories(DbSession dbSession, List<RulesDefinition.Repository> repositories) { | |||
List<String> keys = repositories.stream().map(RulesDefinition.Repository::key).collect(Collectors.toList()); | |||
List<String> keys = repositories.stream().map(RulesDefinition.Repository::key).toList(); | |||
Set<String> existingKeys = dbClient.ruleRepositoryDao().selectAllKeys(dbSession); | |||
Map<Boolean, List<RuleRepositoryDto>> dtos = repositories.stream() | |||
@@ -637,7 +637,7 @@ public class RegisterRules implements Startable { | |||
// DeprecatedKeys that must be deleted | |||
List<String> uuidsToBeDeleted = difference(deprecatedRuleKeysFromDB, deprecatedRuleKeysFromDefinition).stream() | |||
.map(SingleDeprecatedRuleKey::getUuid) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
dbClient.ruleDao().deleteDeprecatedRuleKeys(dbSession, uuidsToBeDeleted); | |||
@@ -822,7 +822,7 @@ public class RegisterRules implements Startable { | |||
private static void verifyRuleKeyConsistency(List<RulesDefinition.Repository> repositories, RegisterRulesContext registerRulesContext) { | |||
List<RulesDefinition.Rule> definedRules = repositories.stream() | |||
.flatMap(r -> r.rules().stream()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
Set<RuleKey> definedRuleKeys = definedRules.stream() | |||
.map(r -> RuleKey.of(r.repository().key(), r.key())) | |||
@@ -830,7 +830,7 @@ public class RegisterRules implements Startable { | |||
List<RuleKey> definedDeprecatedRuleKeys = definedRules.stream() | |||
.flatMap(r -> r.deprecatedRuleKeys().stream()) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
// Find duplicates in declared deprecated rule keys | |||
Set<RuleKey> duplicates = findDuplicates(definedDeprecatedRuleKeys); |
@@ -81,7 +81,7 @@ public class SingleDeprecatedRuleKeyTest { | |||
.containsExactlyInAnyOrder( | |||
deprecatedRuleKeys.stream().map( | |||
r -> tuple(null, r.repository(), r.rule(), rule.repository().key(), rule.key(), RuleKey.of(r.repository(), r.rule()))) | |||
.collect(Collectors.toList()).toArray(new Tuple[deprecatedRuleKeys.size()])); | |||
.toList().toArray(new Tuple[deprecatedRuleKeys.size()])); | |||
} | |||
@Test |
@@ -332,7 +332,7 @@ public class TelemetryDataLoaderImplTest { | |||
.rangeClosed(1, count) | |||
.mapToObj(userConfigurator::apply) | |||
.map(userDbTester::insertUser) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private void assertDatabaseMetadata(TelemetryData.Database database) { |
@@ -1090,7 +1090,7 @@ public class IssueIndex { | |||
long lastIssueDate = (long) ((ParsedMax) branchBucket.getAggregations().get("maxFuncCreatedAt")).getValue(); | |||
return Stream.of(new ProjectStatistics(branchBucket.getKeyAsString(), count, lastIssueDate)); | |||
})) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
public List<SecurityStandardCategoryStatistics> getCweTop25Reports(String projectUuid, boolean isViewOrApp) { | |||
@@ -1175,21 +1175,21 @@ public class IssueIndex { | |||
return getSearchResponse(sourceBuilder) | |||
.getAggregations().asList().stream() | |||
.map(c -> processSecurityReportIssueSearchResultsWithLevelDistribution((ParsedFilter) c, version, level)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private List<SecurityStandardCategoryStatistics> searchWithDistribution(SearchSourceBuilder sourceBuilder, String version, @Nullable Integer level) { | |||
return getSearchResponse(sourceBuilder) | |||
.getAggregations().asList().stream() | |||
.map(c -> processSecurityReportIssueSearchResultsWithDistribution((ParsedFilter) c, version, level)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private List<SecurityStandardCategoryStatistics> search(SearchSourceBuilder sourceBuilder, boolean includeDistribution, @Nullable String version) { | |||
return getSearchResponse(sourceBuilder) | |||
.getAggregations().asList().stream() | |||
.map(c -> processSecurityReportIssueSearchResults((ParsedFilter) c, includeDistribution, version)) | |||
.collect(Collectors.toList()); | |||
.toList(); | |||
} | |||
private SearchResponse getSearchResponse(SearchSourceBuilder sourceBuilder) { |
@@ -275,7 +275,7 @@ public class IssueQueryFactory { | |||
SearchRequest request) { | |||
builder.onComponentOnly(onComponentOnly); | |||
if (onComponentOnly) { | |||
builder.componentUuids(components.stream().map(ComponentDto::uuid).collect(Collectors.toList())); | |||
builder.componentUuids(components.stream().map(ComponentDto::uuid).toList()); | |||
setBranch(builder, components.get(0), request.getBranch(), request.getPullRequest(), session); | |||
return; | |||
} | |||
@@ -330,7 +330,7 @@ public class IssueQueryFactory { | |||
addDirectories(builder, components); | |||
break; | |||
case Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE: | |||
builder.componentUuids(components.stream().map(ComponentDto::uuid).collect(Collectors.toList())); | |||
builder.componentUuids(components.stream().map(ComponentDto::uuid).toList()); | |||
break; | |||
default: | |||
throw new IllegalArgumentException("Unable to set search root context for components " + Joiner.on(',').join(components)); | |||
@@ -357,7 +357,7 @@ public class IssueQueryFactory { | |||
List<String> filteredViewUuids = viewOrSubViewUuids.stream() | |||
.filter(uuid -> userSession.hasComponentPermission(USER, uuid)) | |||
.map(ComponentDto::uuid) | |||
.collect(Collectors.toList()); | |||
.collect(Collectors.toCollection(ArrayList::new)); | |||
if (filteredViewUuids.isEmpty()) { | |||
filteredViewUuids.add(UNKNOWN); | |||
} |