From 7c792fd39a2e67f2688e9f5b9aa8fce5488efb61 Mon Sep 17 00:00:00 2001 From: Steve Marion Date: Thu, 29 Aug 2024 15:16:42 +0200 Subject: [PATCH] SONAR-22891 add file sources to the database populator --- .../src/test/java/org/sonar/db/createdb/PopulateDb.java | 8 ++++++-- .../java/org/sonar/db/source/FileSourceTester.java | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/PopulateDb.java b/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/PopulateDb.java index b77c4bcb869..6730b2862fc 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/PopulateDb.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/PopulateDb.java @@ -98,7 +98,7 @@ public class PopulateDb { executorService.shutdown(); executorService.awaitTermination(100, TimeUnit.DAYS); - createUsers(sqContext, 100_000); + createUsers(sqContext, 100); allPortfolios = new ArrayList<>(dbTester.getDbClient().portfolioDao().selectAll(initSession)); allPortfolios.addAll(createPortfolios(sqContext, new PortfolioGenerationSettings(allPortfolios.size(), 100, 10))); @@ -222,9 +222,13 @@ public class PopulateDb { // for every file in branch for (int file = 0; file < pj.filePerBranch; file++) { ComponentDto fileComponentDto = sqContext.dbTester.components().insertFile(branchAndComponentDto.compo); + sqContext.dbTester.fileSources().insertFileSource(fileComponentDto, pj.issuePerFile, + fs -> fs.setSourceData(fs.getSourceData())); // for every issue in file for (int issue = 0; issue < pj.issuePerFile; issue++) { - IssueDto issueDto = sqContext.dbTester.issues().insertIssue(sqContext.findNotSecurityHotspotRule(), branchAndComponentDto.compo, fileComponentDto); + final int issueLine = issue + 1; + IssueDto issueDto = sqContext.dbTester.issues().insertIssue(sqContext.findNotSecurityHotspotRule(), branchAndComponentDto.compo, fileComponentDto, + iDto -> iDto.setLine(issueLine)); // for every issue change in issue for (int issueChange = 0; issueChange < pj.issueChangePerIssue; issueChange++) { sqContext.dbTester.issues().insertChange(issueDto); 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 7f612fdb82b..9e2bb1000a3 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 @@ -92,8 +92,6 @@ public class FileSourceTester { .setLineHits(RandomUtils.nextInt(4)) .setConditions(RandomUtils.nextInt(4)) .setCoveredConditions(RandomUtils.nextInt(4)) - .setHighlighting(randomAlphanumeric(40)) - .setSymbols(randomAlphanumeric(30)) .addAllDuplication(Arrays.asList(RandomUtils.nextInt(200), RandomUtils.nextInt(200))) .build(); } -- 2.39.5