aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/test/java
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2025-03-22 02:47:45 -0400
committersonartech <sonartech@sonarsource.com>2025-03-26 20:03:12 +0000
commit2a843ab0326b7ba3d9f1d27e9487d77b0cdfcb06 (patch)
treef4fb4cdf9aab4eda26b703014d6bd00cba454131 /server/sonar-db-dao/src/test/java
parenta97c92eeb5a41e1c6b5035c92e0ab5f89ae6ede2 (diff)
downloadsonarqube-2a843ab0326b7ba3d9f1d27e9487d77b0cdfcb06.tar.gz
sonarqube-2a843ab0326b7ba3d9f1d27e9487d77b0cdfcb06.zip
SCA-182: core-extension-sca: move all sca db classes to sca-application
Diffstat (limited to 'server/sonar-db-dao/src/test/java')
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/DefaultScaIssueIdentityTest.java47
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/PackageManagerTest.java34
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependenciesQueryTest.java40
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyDtoTest.java123
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyReleaseDtoTest.java54
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueDtoTest.java69
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDetailsDtoTest.java126
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDtoTest.java56
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueTypeTest.java34
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssuesReleasesDetailsQueryTest.java55
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleaseDtoTest.java74
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleasesQueryTest.java33
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaSeverityTest.java57
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaVulnerabilityIssueDtoTest.java45
14 files changed, 0 insertions, 847 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/DefaultScaIssueIdentityTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/DefaultScaIssueIdentityTest.java
deleted file mode 100644
index 122e328a16b..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/DefaultScaIssueIdentityTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class DefaultScaIssueIdentityTest {
-
- @Test
- void test_constructWithValidValues() {
- var issueIdentity = new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", "spdxLicenseId");
- assertEquals(ScaIssueType.VULNERABILITY, issueIdentity.scaIssueType());
- assertEquals("packageUrl", issueIdentity.packageUrl());
- assertEquals("vulnerabilityId", issueIdentity.vulnerabilityId());
- assertEquals("spdxLicenseId", issueIdentity.spdxLicenseId());
- }
-
- @Test
- void test_throwsOnInvalidValues() {
- assertThrows(IllegalArgumentException.class, () -> new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "", "vulnerabilityId", "spdxLicenseId"));
- assertThrows(IllegalArgumentException.class, () -> new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, null, "vulnerabilityId", "spdxLicenseId"));
- assertThrows(IllegalArgumentException.class, () -> new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "packageUrl", "", "spdxLicenseId"));
- assertThrows(IllegalArgumentException.class, () -> new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "packageUrl", null, "spdxLicenseId"));
- assertThrows(IllegalArgumentException.class, () -> new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", ""));
- assertThrows(IllegalArgumentException.class, () -> new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", null));
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/PackageManagerTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/PackageManagerTest.java
deleted file mode 100644
index eed4dcfa2aa..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/PackageManagerTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class PackageManagerTest {
-
- @Test
- void test_namesAreShortEnough() {
- for (PackageManager packageManager : PackageManager.values()) {
- assertThat(packageManager.name().length()).isLessThanOrEqualTo(ScaReleaseDto.PACKAGE_MANAGER_MAX_LENGTH);
- }
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependenciesQueryTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependenciesQueryTest.java
deleted file mode 100644
index 7a88e9ba53a..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependenciesQueryTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-class ScaDependenciesQueryTest {
-
- @Test
- void testLikeQuery() {
- ScaDependenciesQuery scaDependenciesQuery = new ScaDependenciesQuery("branchUuid", null, null, "QUERY");
- assertEquals("query%", scaDependenciesQuery.likeQuery());
- }
-
- @Test
- void testLikeQueryWithNullQuery() {
- ScaDependenciesQuery scaDependenciesQuery = new ScaDependenciesQuery("branchUuid", null, null, null);
- assertNull(scaDependenciesQuery.likeQuery());
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyDtoTest.java
deleted file mode 100644
index 505a06d6f35..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyDtoTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.util.List;
-import javax.annotation.Nullable;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
-class ScaDependencyDtoTest {
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var scaDependencyDto = new ScaDependencyDto("scaDependencyUuid",
- "scaReleaseUuid",
- true,
- "compile",
- false,
- "some/path",
- "another/path",
- List.of(List.of("pkg:npm/fodo@1.0.0")),
- true,
- 1L,
- 2L);
- assertThat(scaDependencyDto.toBuilder().build()).isEqualTo(scaDependencyDto);
- }
-
- @Test
- void test_identity_shouldIgnoreUuidAndUpdatableFields() {
- var scaDependencyDto = new ScaDependencyDto("scaDependencyUuid",
- "scaReleaseUuid",
- true,
- "compile",
- false,
- "some/path",
- "another/path",
- List.of(List.of("pkg:npm/IGNORED@1.0.0")),
- false,
- 1L,
- 2L);
- var scaDependencyDtoDifferentButSameIdentity = new ScaDependencyDto("differentUuid",
- "scaReleaseUuid",
- true,
- "compile",
- true,
- "some/path",
- "another/path",
- List.of(List.of("pkg:npm/DIFFERENT_ALSO_IGNORED@1.0.0")),
- true,
- 42L,
- 57L);
- assertThat(scaDependencyDto.identity()).isEqualTo(scaDependencyDtoDifferentButSameIdentity.identity());
- assertThat(scaDependencyDto).isNotEqualTo(scaDependencyDtoDifferentButSameIdentity);
- }
-
- @Test
- void test_identity_changingScaReleaseUuid() {
- var scaDependencyDto = new ScaDependencyDto("scaDependencyUuid",
- "scaReleaseUuid",
- true,
- "compile",
- false,
- "some/path",
- "another/path",
- List.of(List.of("pkg:npm/IGNORED@1.0.0")),
- true,
- 1L,
- 2L);
- var scaDependencyDtoChangedReleaseUuid = new ScaDependencyDto("scaDependencyUuid",
- "scaReleaseUuidDifferent",
- true,
- "compile",
- false,
- "some/path",
- "another/path",
- List.of(List.of("pkg:npm/IGNORED@1.0.0")),
- false,
- 1L,
- 2L);
- assertThat(scaDependencyDto.identity()).isNotEqualTo(scaDependencyDtoChangedReleaseUuid.identity());
- assertThat(scaDependencyDto.identity().withScaReleaseUuid("scaReleaseUuidDifferent")).isEqualTo(scaDependencyDtoChangedReleaseUuid.identity());
- }
-
- @Test
- void test_primaryDependencyFilePath() {
- ScaDependencyDto withUserDependencyFilePath = newScaDependencyDto("manifest");
- assertThat(withUserDependencyFilePath.primaryDependencyFilePath()).isEqualTo("manifest");
- ScaDependencyDto withoutUserDependencyFilePath = newScaDependencyDto(null);
- assertThat(withoutUserDependencyFilePath.primaryDependencyFilePath()).isEqualTo("lockfileDependencyFilePath");
- }
-
- private ScaDependencyDto newScaDependencyDto(@Nullable String userDependencyFilePath) {
- return new ScaDependencyDto("dependencyUuid",
- "scaReleaseUuid",
- true,
- "compile",
- false,
- userDependencyFilePath,
- "lockfileDependencyFilePath",
- List.of(List.of("pkg:npm/foo@1.0.0")),
- false,
- 1L,
- 2L);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyReleaseDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyReleaseDtoTest.java
deleted file mode 100644
index a0be47c280f..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaDependencyReleaseDtoTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.util.List;
-import javax.annotation.Nullable;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class ScaDependencyReleaseDtoTest {
-
- @Test
- void test_primaryDependencyFilePath() {
- ScaDependencyReleaseDto withUserDependencyFilePath = newScaDependencyReleaseDto("manifest");
- assertEquals("manifest", withUserDependencyFilePath.primaryDependencyFilePath());
- ScaDependencyReleaseDto withoutUserDependencyFilePath = newScaDependencyReleaseDto(null);
- assertEquals("lockfileDependencyFilePath", withoutUserDependencyFilePath.primaryDependencyFilePath());
- }
-
- private ScaDependencyReleaseDto newScaDependencyReleaseDto(@Nullable String userDependencyFilePath) {
- return new ScaDependencyReleaseDto("dependencyUuid",
- "releaseUuid",
- "componentUuid",
- true,
- "scope",
- userDependencyFilePath,
- "lockfileDependencyFilePath",
- List.of(List.of("pkg:npm/foo@1.0.0")),
- "packageUrl",
- PackageManager.MAVEN,
- "packageName",
- "version",
- "licenseExpression",
- true);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueDtoTest.java
deleted file mode 100644
index da9eb91dddf..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueDtoTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class ScaIssueDtoTest {
-
- @Test
- void test_constructWithValidValues() {
- var dto = new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", "spdxLicenseId", 1L, 2L);
- assertEquals("uuid", dto.uuid());
- assertEquals(ScaIssueType.VULNERABILITY, dto.scaIssueType());
- assertEquals("packageUrl", dto.packageUrl());
- assertEquals("vulnerabilityId", dto.vulnerabilityId());
- assertEquals("spdxLicenseId", dto.spdxLicenseId());
- assertEquals(1L, dto.createdAt());
- assertEquals(2L, dto.updatedAt());
- }
-
- @Test
- void test_throwsOnInvalidValues() {
- assertThrows(IllegalArgumentException.class, () -> new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "", "vulnerabilityId", "spdxLicenseId", 1L, 2L));
- assertThrows(IllegalArgumentException.class, () -> new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, null, "vulnerabilityId", "spdxLicenseId", 1L, 2L));
- assertThrows(IllegalArgumentException.class, () -> new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "packageUrl", "", "spdxLicenseId", 1L, 2L));
- assertThrows(IllegalArgumentException.class, () -> new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "packageUrl", null, "spdxLicenseId", 1L, 2L));
- assertThrows(IllegalArgumentException.class, () -> new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", "", 1L, 2L));
- assertThrows(IllegalArgumentException.class, () -> new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", null, 1L, 2L));
- }
-
- @Test
- void test_constructFromIdentity() {
- var identity = new DefaultScaIssueIdentity(ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", "spdxLicenseId");
- var dto = new ScaIssueDto("uuid", identity, 1L, 2L);
- assertEquals("uuid", dto.uuid());
- assertEquals(ScaIssueType.VULNERABILITY, dto.scaIssueType());
- assertEquals("packageUrl", dto.packageUrl());
- assertEquals("vulnerabilityId", dto.vulnerabilityId());
- assertEquals("spdxLicenseId", dto.spdxLicenseId());
- assertEquals(1L, dto.createdAt());
- assertEquals(2L, dto.updatedAt());
- }
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var dto = new ScaIssueDto("uuid", ScaIssueType.VULNERABILITY, "packageUrl", "vulnerabilityId", "spdxLicenseId", 1L, 2L);
- assertEquals(dto.toBuilder().build(), dto);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDetailsDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDetailsDtoTest.java
deleted file mode 100644
index a5e62a7d417..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDetailsDtoTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.math.BigDecimal;
-import java.util.List;
-import org.assertj.core.api.ThrowableAssert;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-
-class ScaIssueReleaseDetailsDtoTest {
- private static ScaIssueDto newSampleIssueDto() {
- return new ScaIssueDto("issueUuid",
- ScaIssueType.VULNERABILITY,
- "packageUrl",
- "vulnerabilityId",
- "spdxLicenseId",
- 1L,
- 2L);
- }
-
- private static ScaReleaseDto newSampleReleaseDto() {
- return new ScaReleaseDto("releaseUuid",
- "componentUuid",
- "packageUrl",
- PackageManager.MAVEN,
- "foo:bar",
- "1.0.0",
- "MIT",
- "NOASSERTION",
- true,
- false,
- 2L,
- 3L);
- }
-
- private static ScaIssueReleaseDto newSampleIssueReleaseDto(ScaIssueDto issueDto, ScaReleaseDto releaseDto) {
- return new ScaIssueReleaseDto(
- "issueReleaseUuid",
- issueDto.uuid(),
- releaseDto.uuid(),
- ScaSeverity.INFO,
- 3L,
- 4L);
- }
-
- private static ScaVulnerabilityIssueDto newSampleVulnerabilityIssueDto(ScaIssueDto issueDto) {
- return new ScaVulnerabilityIssueDto(
- issueDto.uuid(),
- ScaSeverity.HIGH,
- List.of("cwe1"),
- BigDecimal.ONE,
- 5L,
- 6L);
- }
-
- private static ScaIssueReleaseDetailsDto newSampleIssueReleaseDetailsDto() {
- var issueDto = newSampleIssueDto();
- var releaseDto = newSampleReleaseDto();
- var issueReleaseDto = newSampleIssueReleaseDto(issueDto, releaseDto);
- var vulnerabilityIssueDto = newSampleVulnerabilityIssueDto(issueDto);
- return new ScaIssueReleaseDetailsDto(
- issueReleaseDto.uuid(),
- issueReleaseDto,
- issueDto,
- releaseDto,
- vulnerabilityIssueDto);
- }
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var dto = newSampleIssueReleaseDetailsDto();
- assertThat(dto.toBuilder().build()).isEqualTo(dto);
- }
-
- @Test
- void test_withMismatchedReleaseInIssueReleaseDto_throwsIllegalArgumentException() {
- var validDto = newSampleIssueReleaseDetailsDto();
- var differentIssueReleaseDto = validDto.issueReleaseDto().toBuilder().setScaReleaseUuid("differentUuid").build();
- var invalidBuilder = validDto.toBuilder().setIssueReleaseDto(differentIssueReleaseDto);
- assertThatThrownBy(invalidBuilder::build).isInstanceOf(IllegalArgumentException.class);
- }
-
- @Test
- void test_withMismatchedIssueInIssueReleaseDto_throwsIllegalArgumentException() {
- var validDto = newSampleIssueReleaseDetailsDto();
- var differentIssueReleaseDto = validDto.issueReleaseDto().toBuilder().setScaIssueUuid("differentUuid").build();
- var invalidBuilder = validDto.toBuilder().setIssueReleaseDto(differentIssueReleaseDto);
- assertThatThrownBy(invalidBuilder::build).isInstanceOf(IllegalArgumentException.class);
- }
-
- @Test
- void test_withMismatchedIssueReleaseUuid_throwsIllegalArgumentException() {
- var validDto = newSampleIssueReleaseDetailsDto();
- ThrowableAssert.ThrowingCallable constructInvalid = () -> new ScaIssueReleaseDetailsDto("differentUuid",
- validDto.issueReleaseDto(), validDto.issueDto(), validDto.releaseDto(), validDto.vulnerabilityIssueDto());
- assertThatThrownBy(constructInvalid).isInstanceOf(IllegalArgumentException.class);
- }
-
- @Test
- void test_withMismatchedVulnerabilityIssue_throwsIllegalArgumentException() {
- var validDto = newSampleIssueReleaseDetailsDto();
- var differentVulnerabiiltyIssue = validDto.vulnerabilityIssueDto().toBuilder().setUuid("differentUuid").build();
- var invalidBuilder = validDto.toBuilder().setVulnerabilityIssueDto(differentVulnerabiiltyIssue);
- assertThatThrownBy(invalidBuilder::build).isInstanceOf(IllegalArgumentException.class);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDtoTest.java
deleted file mode 100644
index e1df2cfd1c2..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueReleaseDtoTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
-class ScaIssueReleaseDtoTest {
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var scaIssueReleaseDto = new ScaIssueReleaseDto("sca-issue-release-uuid",
- "sca-issue-uuid",
- "sca-release-uuid",
- ScaSeverity.INFO,
- 1L,
- 2L);
- assertThat(scaIssueReleaseDto.toBuilder().build()).isEqualTo(scaIssueReleaseDto);
- }
-
- @Test
- void test_identity_shouldIgnoreUuidAndUpdatableFields() {
- var scaIssueReleaseDto = new ScaIssueReleaseDto("sca-issue-release-uuid",
- "sca-issue-uuid",
- "sca-release-uuid",
- ScaSeverity.INFO,
- 1L,
- 2L);
- var scaIssueReleaseDtoDifferentButSameIdentity = new ScaIssueReleaseDto("differentUuid",
- "sca-issue-uuid",
- "sca-release-uuid",
- ScaSeverity.HIGH,
- 10L,
- 20L);
- assertThat(scaIssueReleaseDto.identity()).isEqualTo(scaIssueReleaseDtoDifferentButSameIdentity.identity());
- assertThat(scaIssueReleaseDto).isNotEqualTo(scaIssueReleaseDtoDifferentButSameIdentity);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueTypeTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueTypeTest.java
deleted file mode 100644
index 3027f5e96bd..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssueTypeTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class ScaIssueTypeTest {
-
- @Test
- void test_namesAreShortEnough() {
- for (ScaIssueType issueType : ScaIssueType.values()) {
- assertThat(issueType.name().length()).isLessThanOrEqualTo(ScaIssueDto.SCA_ISSUE_TYPE_MAX_LENGTH);
- }
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssuesReleasesDetailsQueryTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssuesReleasesDetailsQueryTest.java
deleted file mode 100644
index e295fc6b3b4..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaIssuesReleasesDetailsQueryTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.util.List;
-import org.assertj.core.api.AssertionsForClassTypes;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class ScaIssuesReleasesDetailsQueryTest {
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var query = new ScaIssuesReleasesDetailsQuery("branchUuid", ScaIssuesReleasesDetailsQuery.Sort.IDENTITY_ASC,
- true, true, "vulnerabilityIdSubstring", "packageNameSubstring", true,
- List.of(ScaIssueType.VULNERABILITY), List.of(ScaSeverity.BLOCKER), List.of(PackageManager.NPM));
- AssertionsForClassTypes.assertThat(query.toBuilder().build()).isEqualTo(query);
- }
-
- @Test
- void test_queryParameterValues() {
- for (var value : ScaIssuesReleasesDetailsQuery.Sort.values()) {
- var queryParameterValue = value.queryParameterValue();
- var fromQueryParameterValue = ScaIssuesReleasesDetailsQuery.Sort.fromQueryParameterValue(queryParameterValue);
- assertThat(fromQueryParameterValue).contains(value);
- assertThat((queryParameterValue.startsWith("+") && value.name().endsWith("_ASC")) ||
- (queryParameterValue.startsWith("-") && value.name().endsWith("_DESC")))
- .as("+/- prefix and ASC/DESC suffix line up")
- .isTrue();
- }
- }
-
- @Test
- void test_whenValueIsInvalid_fromQueryParameterValue() {
- assertThat(ScaIssuesReleasesDetailsQuery.Sort.fromQueryParameterValue("invalid")).isEmpty();
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleaseDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleaseDtoTest.java
deleted file mode 100644
index 6c0ac3d9e53..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleaseDtoTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
-class ScaReleaseDtoTest {
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var scaReleaseDto = new ScaReleaseDto("scaReleaseUuid",
- "componentUuid",
- "packageUrl",
- PackageManager.MAVEN,
- "foo:bar",
- "1.0.0",
- "MIT",
- "MIT",
- true,
- false,
- 1L,
- 2L);
- assertThat(scaReleaseDto.toBuilder().build()).isEqualTo(scaReleaseDto);
- }
-
- @Test
- void test_identity_shouldIgnoreUuidAndUpdatableFields() {
- var scaReleaseDto = new ScaReleaseDto("scaReleaseUuid",
- "componentUuid",
- "packageUrl",
- PackageManager.MAVEN,
- "foo:bar",
- "1.0.0",
- "MIT",
- "MIT",
- true,
- false,
- 1L,
- 2L);
- var scaReleaseDtoDifferentButSameIdentity = new ScaReleaseDto("differentUuid",
- "componentUuidDifferent",
- "packageUrl",
- PackageManager.NPM,
- "foo:bar-different",
- "2.0.0",
- "GPL-3.0",
- "GPL-3.0",
- false,
- true,
- 10L,
- 30L);
- assertThat(scaReleaseDto.identity()).isEqualTo(scaReleaseDtoDifferentButSameIdentity.identity());
- assertThat(scaReleaseDto).isNotEqualTo(scaReleaseDtoDifferentButSameIdentity);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleasesQueryTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleasesQueryTest.java
deleted file mode 100644
index 23a16876ac9..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaReleasesQueryTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.util.List;
-import org.assertj.core.api.AssertionsForClassTypes;
-import org.junit.jupiter.api.Test;
-
-class ScaReleasesQueryTest {
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var query = new ScaReleasesQuery("branchUuid",
- true, false, List.of("NPM"), true, "query");
- AssertionsForClassTypes.assertThat(query.toBuilder().build()).isEqualTo(query);
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaSeverityTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaSeverityTest.java
deleted file mode 100644
index 023f2bd9b20..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaSeverityTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.util.stream.Stream;
-import org.junit.jupiter.api.Test;
-import org.sonar.api.issue.impact.Severity;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class ScaSeverityTest {
- private static void assertSortOrder(ScaSeverity lower, ScaSeverity higher) {
- assertThat(lower.databaseSortKey())
- .as(lower + " sorts below " + higher)
- .isLessThan(higher.databaseSortKey());
- }
-
- @Test
- void test_maxLength() {
- for (ScaSeverity severity : ScaSeverity.values()) {
- assertThat(severity.name().length()).as(severity.name() + " is short enough")
- .isLessThanOrEqualTo(ScaSeverity.MAX_NAME_LENGTH);
- }
- }
-
- @Test
- void test_sortKeysInOrder() {
- assertSortOrder(ScaSeverity.INFO, ScaSeverity.LOW);
- assertSortOrder(ScaSeverity.LOW, ScaSeverity.MEDIUM);
- assertSortOrder(ScaSeverity.MEDIUM, ScaSeverity.HIGH);
- assertSortOrder(ScaSeverity.HIGH, ScaSeverity.BLOCKER);
- }
-
- @Test
- void test_matchesImpactSeverity() {
- assertThat(Stream.of(ScaSeverity.values()).map(Enum::name).toList())
- .as("ScaSeverity has the same values in the same order as impact.Severity")
- .isEqualTo(Stream.of(Severity.values()).map(Enum::name).toList());
- }
-}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaVulnerabilityIssueDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaVulnerabilityIssueDtoTest.java
deleted file mode 100644
index 1019f1e3e5d..00000000000
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/sca/ScaVulnerabilityIssueDtoTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2025 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.sca;
-
-import java.math.BigDecimal;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class ScaVulnerabilityIssueDtoTest {
- @Test
- void test_cweIdsLength_handledByTypeHandler() {
- // this test is here to prevent accidentally messing it up
- assertThat(ScaVulnerabilityIssueDto.CWE_IDS_MAX_LENGTH).isLessThanOrEqualTo(ListOfStringsTypeHandler.MAXIMUM_LENGTH);
- }
-
- @Test
- void test_toBuilder_build_shouldRoundTrip() {
- var scaVulnerabilityIssueDto = new ScaVulnerabilityIssueDto("sca-issue-uuid",
- ScaSeverity.INFO,
- List.of("cwe"),
- new BigDecimal("7.1"),
- 1L,
- 2L);
- assertThat(scaVulnerabilityIssueDto.toBuilder().build()).isEqualTo(scaVulnerabilityIssueDto);
- }
-}