aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/it/java
diff options
context:
space:
mode:
authorHavoc Pennington <havoc.pennington@sonarsource.com>2025-03-16 18:12:14 -0400
committerMatteo Mara <matteo.mara@sonarsource.com>2025-03-17 22:23:55 +0100
commit31f65a470ecec5e36a3f97cf0125a43420d6047b (patch)
treefb7152d758016ed99df73120eb853f17251f854f /server/sonar-db-dao/src/it/java
parentfe7c7277eaeb56e8668c81fd294f612516325c36 (diff)
downloadsonarqube-31f65a470ecec5e36a3f97cf0125a43420d6047b.tar.gz
sonarqube-31f65a470ecec5e36a3f97cf0125a43420d6047b.zip
SCA-131 store sca_dependencies.production_scope and add to endpoints (#13191)
Diffstat (limited to 'server/sonar-db-dao/src/it/java')
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java4
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaDependenciesDaoIT.java20
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaIssuesReleasesDetailsDaoIT.java54
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDaoIT.java49
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDependenciesDaoIT.java2
5 files changed, 94 insertions, 35 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java
index a01c48130d9..7f3905764e1 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java
@@ -1975,8 +1975,8 @@ oldCreationDate));
var release2 = scaReleasesDbTester.insertScaRelease(branch2.getUuid(), "2");
ScaDependenciesDbTester scaDependenciesDbTester = new ScaDependenciesDbTester(db);
- scaDependenciesDbTester.insertScaDependency(branch1.getUuid(), release1.uuid(), "1",false);
- scaDependenciesDbTester.insertScaDependency(branch2.getUuid(), release2.uuid(), "2", false);
+ scaDependenciesDbTester.insertScaDependency(release1.uuid(), "1");
+ scaDependenciesDbTester.insertScaDependency(release2.uuid(), "2");
ScaIssueReleaseDto issueRelease1 = new ScaIssueReleaseDto.Builder().setUuid("foo1").setScaIssueUuid("baz").setSeverity(ScaSeverity.LOW).setScaReleaseUuid(release1.uuid()).build();
ScaIssueReleaseDto issueRelease2 = new ScaIssueReleaseDto.Builder().setUuid("foo2").setScaIssueUuid("baz").setSeverity(ScaSeverity.LOW).setScaReleaseUuid(release2.uuid()).build();
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaDependenciesDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaDependenciesDaoIT.java
index f122c8eefb8..c5bd44b7414 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaDependenciesDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaDependenciesDaoIT.java
@@ -42,7 +42,7 @@ class ScaDependenciesDaoIT {
@Test
void insert_shouldPersistScaDependencies() {
ComponentDto componentDto = prepareComponentDto();
- ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), "scaReleaseUuid", "1", true);
+ ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency("scaReleaseUuid", "1");
List<Map<String, Object>> select = db.select(db.getSession(), "select * from sca_dependencies");
assertThat(select).hasSize(1);
@@ -57,6 +57,7 @@ class ScaDependenciesDaoIT {
Map.entry("lockfile_dependency_file_path", scaDependencyDto.lockfileDependencyFilePath()),
Map.entry("chains", scaDependencyDto.getChainsJson()),
Map.entry("new_in_pull_request", scaDependencyDto.newInPullRequest()),
+ Map.entry("production_scope", scaDependencyDto.productionScope()),
Map.entry("created_at", scaDependencyDto.createdAt()),
Map.entry("updated_at", scaDependencyDto.updatedAt())));
}
@@ -64,7 +65,7 @@ class ScaDependenciesDaoIT {
@Test
void deleteByUuid_shouldDeleteScaDependencies() {
ComponentDto componentDto = prepareComponentDto();
- ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), "scaReleaseUuid", "1", true);
+ ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency("scaReleaseUuid", "1");
List<Map<String, Object>> select = db.select(db.getSession(), "select * from sca_dependencies");
assertThat(select).isNotEmpty();
@@ -78,7 +79,7 @@ class ScaDependenciesDaoIT {
@Test
void selectByUuid_shouldLoadScaDependency() {
ComponentDto componentDto = prepareComponentDto();
- ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), "scaReleaseUuid", "1", true);
+ ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency("scaReleaseUuid", "1");
var loadedOptional = scaDependenciesDao.selectByUuid(db.getSession(), scaDependencyDto.uuid());
@@ -90,7 +91,7 @@ class ScaDependenciesDaoIT {
ComponentDto componentDto = prepareComponentDto();
ScaDependencyDto scaDependencyDto1a = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "1a", true, PackageManager.MAVEN, "foo.bar1");
// same release, different dependency
- ScaDependencyDto scaDependencyDto1b = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), scaDependencyDto1a.scaReleaseUuid(), "1b", false);
+ ScaDependencyDto scaDependencyDto1b = db.getScaDependenciesDbTester().insertScaDependency(scaDependencyDto1a.scaReleaseUuid(), "1b", false);
ScaDependencyDto scaDependencyDto2 = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "2", true, PackageManager.MAVEN, "foo.bar2");
ScaDependencyDto scaDependencyDto3 = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "3", true, PackageManager.MAVEN, "foo.bar3");
@@ -106,7 +107,7 @@ class ScaDependenciesDaoIT {
ComponentDto componentDto = prepareComponentDto();
ScaDependencyDto scaDependencyDto1 = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "1", true, PackageManager.MAVEN, "foo.bar");
// same release, different dependency
- ScaDependencyDto scaDependencyDto2 = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), scaDependencyDto1.scaReleaseUuid(), "2", false);
+ ScaDependencyDto scaDependencyDto2 = db.getScaDependenciesDbTester().insertScaDependency(scaDependencyDto1.scaReleaseUuid(), "2", false);
ScaDependenciesQuery scaDependenciesQuery = new ScaDependenciesQuery(componentDto.branchUuid(), null, null, null);
List<ScaDependencyDto> results = scaDependenciesDao.selectByQuery(db.getSession(), scaDependenciesQuery, Pagination.all());
@@ -202,8 +203,12 @@ class ScaDependenciesDaoIT {
@Test
void update_shouldUpdateScaDependency() {
ComponentDto componentDto = prepareComponentDto();
- ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), "scaReleaseUuid", "1", true);
- ScaDependencyDto updatedScaDependency = scaDependencyDto.toBuilder().setUpdatedAt(scaDependencyDto.updatedAt() + 1).setDirect(false).setLockfileDependencyFilePath("lockfile2")
+ ScaDependencyDto scaDependencyDto = db.getScaDependenciesDbTester().insertScaDependency("scaReleaseUuid", "1", true);
+ ScaDependencyDto updatedScaDependency = scaDependencyDto.toBuilder()
+ .setUpdatedAt(scaDependencyDto.updatedAt() + 1)
+ .setDirect(!scaDependencyDto.direct())
+ .setLockfileDependencyFilePath("lockfile2")
+ .setProductionScope(!scaDependencyDto.productionScope())
.build();
scaDependenciesDao.update(db.getSession(), updatedScaDependency);
@@ -221,6 +226,7 @@ class ScaDependenciesDaoIT {
Map.entry("lockfile_dependency_file_path", updatedScaDependency.lockfileDependencyFilePath()),
Map.entry("chains", updatedScaDependency.getChainsJson()),
Map.entry("new_in_pull_request", updatedScaDependency.newInPullRequest()),
+ Map.entry("production_scope", updatedScaDependency.productionScope()),
Map.entry("created_at", updatedScaDependency.createdAt()),
Map.entry("updated_at", updatedScaDependency.updatedAt())));
}
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaIssuesReleasesDetailsDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaIssuesReleasesDetailsDaoIT.java
index 7b5c5b36ba8..c023fbce2f1 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaIssuesReleasesDetailsDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaIssuesReleasesDetailsDaoIT.java
@@ -363,6 +363,23 @@ class ScaIssuesReleasesDetailsDaoIT {
}
@Test
+ void withQueryFilteredByProductionScope_shouldReturnExpectedItems() {
+ QueryTestData testData = createQueryTestData();
+ var expectedProduction = testData.productionIssues();
+ var expectedNotProduction = testData.notProductionIssues();
+
+ executeQueryTest(testData,
+ queryBuilder -> queryBuilder.setProductionScope(true),
+ expectedProduction,
+ "Only production issues should be returned");
+
+ executeQueryTest(testData,
+ queryBuilder -> queryBuilder.setProductionScope(false),
+ expectedNotProduction,
+ "Only the non-production issues should be returned");
+ }
+
+ @Test
void withQueryMultipleFiltersNonDefaultSort_shouldReturnExpectedItems() {
QueryTestData testData = createQueryTestData();
var expectedPackageManagerMaven = testData.expectedIssuesWithPackageManager(PackageManager.MAVEN);
@@ -460,22 +477,35 @@ class ScaIssuesReleasesDetailsDaoIT {
scaIssueReleaseDto -> scaIssueReleaseDto.toBuilder().setSeverity(ScaSeverity.INFO).build());
// issue 1 weirdly has no dependency, issues 2-3 are direct, issues 4-6 are transitive
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue2.releaseUuid(), "2", true);
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue3.releaseUuid(), "3", true);
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue4.releaseUuid(), "4", false);
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue5.releaseUuid(), "5", false);
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue6.releaseUuid(), "6", false);
-
- // make issue3 and issue4 BOTH direct and transitive
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue3.releaseUuid(), "7", false);
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), issue4.releaseUuid(), "8", true);
+ // issues 2 and 4 are production, 3,5,6 are not production
+ db.getScaDependenciesDbTester().insertScaDependency(issue2.releaseUuid(), "2",
+ builder -> builder.setDirect(true).setProductionScope(true));
+ var dep3 = db.getScaDependenciesDbTester().insertScaDependency(issue3.releaseUuid(), "3",
+ builder -> builder.setDirect(true).setProductionScope(false));
+ var dep4 = db.getScaDependenciesDbTester().insertScaDependency(issue4.releaseUuid(), "4",
+ builder -> builder.setDirect(false).setProductionScope(true));
+ var dep5 = db.getScaDependenciesDbTester().insertScaDependency(issue5.releaseUuid(), "5",
+ builder -> builder.setDirect(false).setProductionScope(false));
+ db.getScaDependenciesDbTester().insertScaDependency(issue6.releaseUuid(), "6",
+ builder -> builder.setDirect(false).setProductionScope(false));
+
+ // make issue3 and issue4 BOTH direct and transitive,
+ // issue4 and issue5 are BOTH production and not
+ db.getScaDependenciesDbTester().insertScaDependency(issue3.releaseUuid(), "7",
+ builder -> builder.setDirect(!dep3.direct()).setProductionScope(dep3.productionScope()));
+ db.getScaDependenciesDbTester().insertScaDependency(issue4.releaseUuid(), "8",
+ builder -> builder.setDirect(!dep4.direct()).setProductionScope(!dep4.productionScope()));
+ db.getScaDependenciesDbTester().insertScaDependency(issue5.releaseUuid(), "9",
+ builder -> builder.setDirect(dep5.direct()).setProductionScope(!dep5.productionScope()));
var directIssues = List.of(issue2, issue3, issue4).stream().sorted(identityComparator()).toList();
var transitiveIssues = List.of(issue3, issue4, issue5, issue6).stream().sorted(identityComparator()).toList();
+ var productionIssues = List.of(issue2, issue4, issue5).stream().sorted(identityComparator()).toList();
+ var notProductionIssues = List.of(issue3, issue4, issue5, issue6).stream().sorted(identityComparator()).toList();
return new QueryTestData(projectData, componentDto,
List.of(issue1, issue2, issue3, issue4, issue5, issue6),
- directIssues, transitiveIssues);
+ directIssues, transitiveIssues, productionIssues, notProductionIssues);
}
@Test
@@ -498,7 +528,9 @@ class ScaIssuesReleasesDetailsDaoIT {
ComponentDto componentDto,
List<ScaIssueReleaseDetailsDto> expectedIssues,
List<ScaIssueReleaseDetailsDto> directIssues,
- List<ScaIssueReleaseDetailsDto> transitiveIssues) {
+ List<ScaIssueReleaseDetailsDto> transitiveIssues,
+ List<ScaIssueReleaseDetailsDto> productionIssues,
+ List<ScaIssueReleaseDetailsDto> notProductionIssues) {
private static Comparator<ScaIssueReleaseDetailsDto> cvssScoreComparator() {
return Comparator.comparing(ScaIssueReleaseDetailsDto::cvssScore,
// we treat null cvss as a score of 0.0
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDaoIT.java
index e29c0f54521..a9f59d2267f 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDaoIT.java
@@ -121,7 +121,7 @@ class ScaReleasesDaoIT {
ScaReleaseDto scaReleaseDto = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "1");
System.out.println("componentDto = " + componentDto);
- ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, null);
+ ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, null, null);
List<ScaReleaseDto> results = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesQuery, Pagination.all());
assertThat(results).hasSize(1);
@@ -136,7 +136,7 @@ class ScaReleasesDaoIT {
ScaReleaseDto scaReleaseDto3 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "3");
ScaReleaseDto scaReleaseDto4 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "4");
- ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, null);
+ ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, null, null);
List<ScaReleaseDto> page1Results = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesQuery, Pagination.forPage(1).andSize(2));
List<ScaReleaseDto> page2Results = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesQuery, Pagination.forPage(2).andSize(2));
@@ -151,8 +151,8 @@ class ScaReleasesDaoIT {
void selectByQuery_shouldPartiallyMatchPackageName_whenQueriedByText() {
ComponentDto componentDto = prepareComponentDto();
ScaReleaseDto scaReleaseDto1 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "1", PackageManager.MAVEN, "foo.bar");
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), scaReleaseDto1, "1", true);
- db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), scaReleaseDto1, "2", false);
+ db.getScaDependenciesDbTester().insertScaDependency(scaReleaseDto1, "1", true);
+ db.getScaDependenciesDbTester().insertScaDependency(scaReleaseDto1, "2", false);
var log = LoggerFactory.getLogger("");
List<Map<String, Object>> temp = db.select(db.getSession(), "select * from sca_releases");
log.warn("sca_releases: {}", temp.stream().count());
@@ -171,14 +171,14 @@ class ScaReleasesDaoIT {
@SuppressWarnings("unused")
ScaReleaseDto scaReleaseDto4 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "4", PackageManager.MAVEN, "some.foo.bar");
- ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, "foo");
+ ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, null, "foo");
List<ScaReleaseDto> results = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesQuery, Pagination.all());
assertThat(results).hasSize(3);
assertThat(results.get(0)).usingRecursiveComparison().isEqualTo(scaReleaseDto1);
assertThat(results.get(1)).usingRecursiveComparison().isEqualTo(scaReleaseDto3);
- ScaReleasesQuery scaReleasesCaseInsensitiveQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, "Foo.Bar");
+ ScaReleasesQuery scaReleasesCaseInsensitiveQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, null, null, "Foo.Bar");
List<ScaReleaseDto> resultsCaseInsensitive = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesCaseInsensitiveQuery, Pagination.all());
assertThat(resultsCaseInsensitive).hasSize(3);
@@ -192,13 +192,13 @@ class ScaReleasesDaoIT {
ScaReleaseDto scaReleaseDto1 = db.getScaReleasesDbTester().insertScaReleaseWithDependency(componentDto.uuid(), "1", 2, true, PackageManager.MAVEN, "foo.bar");
ScaReleaseDto scaReleaseDto2 = db.getScaReleasesDbTester().insertScaReleaseWithDependency(componentDto.uuid(), "2", 3, false, PackageManager.MAVEN, "foo.bar");
- ScaReleasesQuery scaReleasesDirectQuery = new ScaReleasesQuery(componentDto.branchUuid(), true, null, null, null);
+ ScaReleasesQuery scaReleasesDirectQuery = new ScaReleasesQuery(componentDto.branchUuid(), true, null, null, null, null);
List<ScaReleaseDto> resultsDirect = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesDirectQuery, Pagination.all());
assertThat(resultsDirect).hasSize(1);
assertThat(resultsDirect.get(0)).usingRecursiveComparison().isEqualTo(scaReleaseDto1);
- ScaReleasesQuery scaReleasesNoDirectQuery = new ScaReleasesQuery(componentDto.branchUuid(), false, null, null, null);
+ ScaReleasesQuery scaReleasesNoDirectQuery = new ScaReleasesQuery(componentDto.branchUuid(), false, null, null, null, null);
List<ScaReleaseDto> resultsNoDirect = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesNoDirectQuery, Pagination.all());
assertThat(resultsNoDirect).hasSize(1);
@@ -206,19 +206,40 @@ class ScaReleasesDaoIT {
}
@Test
+ void selectByQuery_shouldReturnScaReleases_whenQueryByProductionScope() {
+ ComponentDto componentDto = prepareComponentDto();
+ ScaReleaseDto scaReleaseDto1 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "1");
+ ScaReleaseDto scaReleaseDto2 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "2");
+ db.getScaDependenciesDbTester().insertScaDependency(scaReleaseDto1, "1", builder -> builder.setProductionScope(true));
+ db.getScaDependenciesDbTester().insertScaDependency(scaReleaseDto2, "2", builder -> builder.setProductionScope(false));
+
+ ScaReleasesQuery scaReleasesProductionScopeQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, true, null, null, null);
+ List<ScaReleaseDto> resultsProductionScope = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesProductionScopeQuery, Pagination.all());
+
+ assertThat(resultsProductionScope).hasSize(1);
+ assertThat(resultsProductionScope.get(0)).usingRecursiveComparison().isEqualTo(scaReleaseDto1);
+
+ ScaReleasesQuery scaReleasesNoProductionScopeQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, false, null, null, null);
+ List<ScaReleaseDto> resultsNoProductionScope = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesNoProductionScopeQuery, Pagination.all());
+
+ assertThat(resultsNoProductionScope).hasSize(1);
+ assertThat(resultsNoProductionScope.get(0)).usingRecursiveComparison().isEqualTo(scaReleaseDto2);
+ }
+
+ @Test
void selectByQuery_shouldReturnScaReleases_whenQueryByPackageManager() {
ComponentDto componentDto = prepareComponentDto();
ScaReleaseDto scaReleaseDto1 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "1", PackageManager.MAVEN, "foo.bar");
ScaReleaseDto scaReleaseDto2 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "2", PackageManager.NPM, "foo.bar");
ScaReleaseDto scaReleaseDto3 = db.getScaReleasesDbTester().insertScaRelease(componentDto.uuid(), "3", PackageManager.CARGO, "foo.bar");
- ScaReleasesQuery scaReleasesMavenQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, List.of(PackageManager.MAVEN.name()), null, null);
+ ScaReleasesQuery scaReleasesMavenQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null, List.of(PackageManager.MAVEN.name()), null, null);
List<ScaReleaseDto> resultsMaven = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesMavenQuery, Pagination.all());
assertThat(resultsMaven).hasSize(1);
assertThat(resultsMaven.get(0)).usingRecursiveComparison().isEqualTo(scaReleaseDto1);
- ScaReleasesQuery scaReleasesNpmAndCargoQuery = new ScaReleasesQuery(componentDto.branchUuid(), null,
+ ScaReleasesQuery scaReleasesNpmAndCargoQuery = new ScaReleasesQuery(componentDto.branchUuid(), null, null,
List.of(PackageManager.NPM.name(), PackageManager.CARGO.name()), null, null);
List<ScaReleaseDto> resultsNpm = scaReleasesDao.selectByQuery(db.getSession(), scaReleasesNpmAndCargoQuery, Pagination.all());
@@ -260,11 +281,11 @@ class ScaReleasesDaoIT {
db.getScaReleasesDbTester().insertScaReleaseWithDependency(componentDto1.uuid(), "2", 2, true, PackageManager.MAVEN, "foo.bar.mee");
db.getScaReleasesDbTester().insertScaReleaseWithDependency(componentDto1.uuid(), "3", 3, true, PackageManager.MAVEN, "bar.fo");
- ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto1.branchUuid(), null, null, null, "foo");
+ ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto1.branchUuid(), null, null, null, null, "foo");
assertThat(scaReleasesDao.countByQuery(db.getSession(), scaReleasesQuery)).isEqualTo(2);
- assertThat(scaReleasesDao.countByQuery(db.getSession(), new ScaReleasesQuery(componentDto1.branchUuid(), null, null, null, null))).isEqualTo(3);
- assertThat(scaReleasesDao.countByQuery(db.getSession(), new ScaReleasesQuery("another_branch_uuid", null, null, null, null))).isZero();
+ assertThat(scaReleasesDao.countByQuery(db.getSession(), new ScaReleasesQuery(componentDto1.branchUuid(), null, null, null, null, null))).isEqualTo(3);
+ assertThat(scaReleasesDao.countByQuery(db.getSession(), new ScaReleasesQuery("another_branch_uuid", null, null, null, null, null))).isZero();
}
private ComponentDto prepareComponentDto() {
@@ -280,7 +301,7 @@ class ScaReleasesDaoIT {
db.getScaReleasesDbTester().insertScaReleaseWithDependency(componentDto1.uuid(), "3", 3, true, PackageManager.MAVEN, "bar.foo");
db.getScaReleasesDbTester().insertScaReleaseWithDependency(componentDto1.uuid(), "4", 4, true, PackageManager.PYPI, "bar.foo");
- ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto1.branchUuid(), null, null, null, null);
+ ScaReleasesQuery scaReleasesQuery = new ScaReleasesQuery(componentDto1.branchUuid(), null, null, null, null, null);
List<ScaReleaseByPackageManagerCountDto> releaseCounts = scaReleasesDao.countReleasesByPackageManager(db.getSession(), scaReleasesQuery);
assertThat(releaseCounts).hasSize(3);
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDependenciesDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDependenciesDaoIT.java
index b8c39227b37..e8384f05a0c 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDependenciesDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/sca/ScaReleasesDependenciesDaoIT.java
@@ -45,7 +45,7 @@ class ScaReleasesDependenciesDaoIT {
ScaDependencyDto scaDependencyDto1a = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "1a", true, PackageManager.MAVEN, "foo.bar1");
// same release, different dependency
- ScaDependencyDto scaDependencyDto1b = db.getScaDependenciesDbTester().insertScaDependency(componentDto.uuid(), scaDependencyDto1a.scaReleaseUuid(), "1b", false);
+ ScaDependencyDto scaDependencyDto1b = db.getScaDependenciesDbTester().insertScaDependency(scaDependencyDto1a.scaReleaseUuid(), "1b", false);
ScaDependencyDto scaDependencyDto2 = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "2", true, PackageManager.MAVEN, "foo.bar2");
ScaDependencyDto scaDependencyDto3 = db.getScaDependenciesDbTester().insertScaDependencyWithRelease(componentDto.uuid(), "3", true, PackageManager.MAVEN, "foo.bar3");