diff options
author | Pierre <pierre.guillot@sonarsource.com> | 2020-06-25 10:58:50 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-06-26 20:04:58 +0000 |
commit | 96af2bcbe7c02a427bd783f8688a1bba775b4006 (patch) | |
tree | 36bfcee48a41a7fc8a39c7690e77c89b59bd9378 /server/sonar-webserver-core | |
parent | 379a7845d2ebaa6ad77e6de027e4aa6300dd0d59 (diff) | |
download | sonarqube-96af2bcbe7c02a427bd783f8688a1bba775b4006.tar.gz sonarqube-96af2bcbe7c02a427bd783f8688a1bba775b4006.zip |
SONAR-13444 fix logs verbosity and code smells
Diffstat (limited to 'server/sonar-webserver-core')
2 files changed, 5 insertions, 9 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java index 3539180eacd..8fd541c78f3 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java @@ -69,16 +69,13 @@ public class AsyncIssueIndexingImpl implements AsyncIssueIndexing { dbClient.branchDao().updateAllNeedIssueSync(dbSession); List<BranchDto> branchInNeedOfIssueSync = dbClient.branchDao().selectBranchNeedingIssueSync(dbSession); + LOG.info("{} branch found in need of issue sync.", branchInNeedOfIssueSync.size()); if (branchInNeedOfIssueSync.isEmpty()) { - LOG.info("No branch found in need of issue sync"); return; } - String branchListForDisplay = branchInNeedOfIssueSync.stream().map(BranchDto::toString).collect(Collectors.joining(", ")); - LOG.info("{} branch found in need of issue sync : {}", branchInNeedOfIssueSync.size(), branchListForDisplay); - - List<String> projectUuids = new ArrayList<>(branchInNeedOfIssueSync.stream().map(BranchDto::getProjectUuid).collect(Collectors.toSet())); + List<String> projectUuids = branchInNeedOfIssueSync.stream().map(BranchDto::getProjectUuid).distinct().collect(Collectors.toList()); LOG.info("{} projects found in need of issue sync.", projectUuids.size()); sortProjectUuids(dbSession, projectUuids); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java index 39af2271744..c8c25d23fbe 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java @@ -94,15 +94,14 @@ public class AsyncIssueIndexingImplTest { verify(ceQueue, times(1)).prepareSubmit(); verify(ceQueue, times(1)).massSubmit(anyCollection()); assertThat(logTester.logs(LoggerLevel.INFO)) - .contains("1 branch found in need of issue sync : BranchDto{uuid='branch_uuid', projectUuid='project_uuid'," + - " kee='branchName', keyType=BRANCH, branchType=BRANCH, mergeBranchUuid='null', excludeFromPurge=false, needIssueSync=true}"); + .contains("1 branch found in need of issue sync."); } @Test public void triggerOnIndexCreation_no_branch() { underTest.triggerOnIndexCreation(); - assertThat(logTester.logs(LoggerLevel.INFO)).contains("No branch found in need of issue sync"); + assertThat(logTester.logs(LoggerLevel.INFO)).contains("0 branch found in need of issue sync."); } @Test @@ -134,7 +133,7 @@ public class AsyncIssueIndexingImplTest { assertThat(dbClient.ceActivityDao().selectByTaskType(dbTester.getSession(), REPORT)).hasSize(1); - assertThat(dbClient.ceTaskCharacteristicsDao().selectByTaskUuids(dbTester.getSession(), new HashSet<>(Arrays.asList("uuid_2")))).hasSize(0); + assertThat(dbClient.ceTaskCharacteristicsDao().selectByTaskUuids(dbTester.getSession(), new HashSet<>(Arrays.asList("uuid_2")))).isEmpty(); assertThat(logTester.logs(LoggerLevel.INFO)) .contains( |