diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2024-10-24 10:54:15 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-24 20:02:44 +0000 |
commit | e0a940902f37156757e84544d0a876f47f69040f (patch) | |
tree | 988c74e5242ad1bb349148601bb207b7cf515b09 /server/sonar-db-dao/src/it | |
parent | c11922595bf67a70a38588a6f7763fb6f6c14501 (diff) | |
download | sonarqube-e0a940902f37156757e84544d0a876f47f69040f.tar.gz sonarqube-e0a940902f37156757e84544d0a876f47f69040f.zip |
SONAR-23427 Stop relying on Qualifiers, Scopes and ResourceType from the plugin API
Diffstat (limited to 'server/sonar-db-dao/src/it')
8 files changed, 37 insertions, 39 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java index 3d43a6e6810..9da57afcc8c 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java @@ -37,8 +37,6 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -72,10 +70,10 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.sonar.api.issue.Issue.STATUS_CLOSED; import static org.sonar.api.issue.Issue.STATUS_CONFIRMED; import static org.sonar.api.issue.Issue.STATUS_OPEN; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.utils.DateUtils.parseDate; import static org.sonar.db.Pagination.forPage; import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; @@ -830,8 +828,8 @@ class ComponentDaoIT { static Object[][] portfolioOrApplicationRootViewQualifier() { return new Object[][]{ - {Qualifiers.VIEW}, - {Qualifiers.APP}, + {ComponentQualifiers.VIEW}, + {ComponentQualifiers.APP}, }; } @@ -850,7 +848,7 @@ class ComponentDaoIT { private ComponentDto insertView(String rootViewQualifier, Consumer<ComponentDto> dtoPopulators) { ComponentDbTester tester = db.components(); - if (rootViewQualifier.equals(Qualifiers.VIEW)) { + if (rootViewQualifier.equals(ComponentQualifiers.VIEW)) { return random.nextBoolean() ? tester.insertPublicPortfolio(dtoPopulators) : tester.insertPrivatePortfolio(dtoPopulators); } return random.nextBoolean() ? tester.insertPublicApplication(dtoPopulators).getMainBranchComponent() : @@ -945,7 +943,7 @@ class ComponentDaoIT { assertThat(underTest.selectByQuery(dbSession, query.get().setQualifiers(PROJECT, "XXX").build(), forPage(1).andSize(10))) .extracting(ComponentDto::uuid) .containsOnly(provisionedProject.uuid()); - assertThat(underTest.selectByQuery(dbSession, query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build(), forPage(1).andSize(10))) + assertThat(underTest.selectByQuery(dbSession, query.get().setQualifiers(PROJECT, ComponentQualifiers.VIEW).build(), forPage(1).andSize(10))) .extracting(ComponentDto::uuid) .containsOnly(provisionedProject.uuid(), provisionedPortfolio.uuid()); @@ -1026,8 +1024,8 @@ class ComponentDaoIT { Supplier<ComponentQuery.Builder> query = () -> ComponentQuery.builder().setOnProvisionedOnly(true); assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT).build())).isOne(); - assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(Qualifiers.VIEW).build())).isZero(); - assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build())).isOne(); + assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(ComponentQualifiers.VIEW).build())).isZero(); + assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT, ComponentQualifiers.VIEW).build())).isOne(); } @Test @@ -1537,7 +1535,7 @@ class ComponentDaoIT { assertThat(children).extracting("uuid").containsOnly(FILE_1_UUID, DIR_UUID); // test children of root, filtered by qualifier - query = newTreeQuery(PROJECT_UUID).setQualifiers(asList(Qualifiers.DIRECTORY)).build(); + query = newTreeQuery(PROJECT_UUID).setQualifiers(asList(ComponentQualifiers.DIRECTORY)).build(); children = underTest.selectDescendants(dbSession, query); assertThat(children).extracting("uuid").containsOnly(DIR_UUID); @@ -1582,11 +1580,11 @@ class ComponentDaoIT { assertThat(underTest.selectDescendants(dbSession, query)).isEmpty(); // test filtering by scope - query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.FILE)).build(); + query = newTreeQuery(project.uuid()).setScopes(asList(ComponentScopes.FILE)).build(); assertThat(underTest.selectDescendants(dbSession, query)) .extracting(ComponentDto::uuid) .containsExactlyInAnyOrder(fileInProject.uuid()); - query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.DIRECTORY)).build(); + query = newTreeQuery(project.uuid()).setScopes(asList(ComponentScopes.DIRECTORY)).build(); assertThat(underTest.selectDescendants(dbSession, query)) .extracting(ComponentDto::uuid) .containsExactlyInAnyOrder(dir.uuid()); diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java index 9a509e8da57..32b04d67c27 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java @@ -40,8 +40,8 @@ import org.sonar.db.source.FileSourceDto; import static org.apache.commons.lang3.RandomStringUtils.secure; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; class ScrollForFileMoveComponentDaoIT { @RegisterExtension diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java index ed11ebf9183..86d14f5e0f8 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java @@ -30,7 +30,7 @@ import org.apache.ibatis.session.ResultHandler; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -455,13 +455,13 @@ class MeasureDaoIT { newMeasureForMetrics(branch1, metric1, metric2); ComponentDto file = db.components().insertComponent(newFileDto(branch1)); - ComponentDto uts = db.components().insertComponent(newFileDto(branch1).setQualifier(Qualifiers.UNIT_TEST_FILE)); + ComponentDto uts = db.components().insertComponent(newFileDto(branch1).setQualifier(ComponentQualifiers.UNIT_TEST_FILE)); MeasureDto measureOnFile11 = newMeasureForMetrics(file, metric1, metric2); newMeasureForMetrics(uts, metric1, metric2); underTest.selectTreeByQuery(db.getSession(), branch1, MeasureTreeQuery.builder() - .setQualifiers(Collections.singletonList(Qualifiers.FILE)) + .setQualifiers(Collections.singletonList(ComponentQualifiers.FILE)) .setStrategy(MeasureTreeQuery.Strategy.LEAVES).build(), context -> results.add(context.getResultObject())); diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java index 3befb795478..2ebe14fa96c 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java @@ -35,7 +35,7 @@ import org.assertj.core.groups.Tuple; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.Pagination; @@ -434,7 +434,7 @@ class ProjectDaoIT { return new ProjectDto() .setName("projectName_" + name) .setKey("projectKee_" + org + "_" + name) - .setQualifier(Qualifiers.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setUuid("uuid_" + org + "_" + name) .setTags(Arrays.asList("tag1", "tag2")) .setDescription("desc_" + name) diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java index b136fd44817..67da5d6523a 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -1049,7 +1049,7 @@ class PropertiesDaoIT { private void insertProperties(@Nullable String userLogin, @Nullable String projectKey, @Nullable String projectName, PropertyDto... properties) { for (PropertyDto propertyDto : properties) { - underTest.saveProperty(session, propertyDto, userLogin, projectKey, projectName, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, userLogin, projectKey, projectName, ComponentQualifiers.PROJECT); } session.commit(); } @@ -1062,7 +1062,7 @@ class PropertiesDaoIT { .setUserUuid(userUuid) .setValue(value); boolean isNew = session.getMapper(PropertiesMapper.class).selectByKey(dto) == null; - db.properties().insertProperty(dto, projectKey, projectName, Qualifiers.PROJECT, userLogin); + db.properties().insertProperty(dto, projectKey, projectName, ComponentQualifiers.PROJECT, userLogin); if (isNew) { verify(auditPersister).addProperty(any(), any(), anyBoolean()); } else { diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java index abf98c6f220..c3fd3e5b843 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.ArgumentCaptor; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -102,7 +102,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -121,7 +121,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, "app-key", "app-name", Qualifiers.APP); + underTest.saveProperty(session, propertyDto, USER_LOGIN, "app-key", "app-name", ComponentQualifiers.APP); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -141,7 +141,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, "portfolio-key", "portfolio-name", Qualifiers.VIEW); + underTest.saveProperty(session, propertyDto, USER_LOGIN, "portfolio-key", "portfolio-name", ComponentQualifiers.VIEW); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -161,7 +161,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(SECURED_KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(SECURED_KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -180,7 +180,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyQuery query = getPropertyQuery(KEY); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); underTest.deleteByQuery(session, query); @@ -211,7 +211,7 @@ class PropertiesDaoWithPersisterIT { PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); underTest.saveProperty(session, propertyDto, USER_LOGIN, null, null, null); - underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verify(auditPersister).deleteProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -229,7 +229,7 @@ class PropertiesDaoWithPersisterIT { void deleteTrackedPropertyWithoutAffectedRowsIsNotPersisted() { PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verifyNoInteractions(auditPersister); } 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 506c3dfe4ee..4ed444fa907 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 @@ -44,7 +44,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.slf4j.event.Level; import org.sonar.api.issue.Issue; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.testfixtures.log.LogAndArguments; import org.sonar.api.testfixtures.log.LogTesterJUnit5; import org.sonar.api.utils.System2; @@ -396,7 +396,7 @@ project.getProjectDto().getUuid()), PurgeListener.EMPTY, new PurgeProfiler()); ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); logTester.setLevel(Level.DEBUG); - underTest.deleteProject(db.getSession(), project.uuid(), Qualifiers.PROJECT, project.name(), project.getKey()); + underTest.deleteProject(db.getSession(), project.uuid(), ComponentQualifiers.PROJECT, project.name(), project.getKey()); assertThat(logTester.getLogs(LoggerLevel.DEBUG).stream() .map(LogAndArguments::getFormattedMsg) @@ -409,7 +409,7 @@ project.getProjectDto().getUuid()), PurgeListener.EMPTY, new PurgeProfiler()); ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); logTester.setLevel(Level.INFO); - underTest.deleteProject(db.getSession(), project.uuid(), Qualifiers.PROJECT, project.name(), project.getKey()); + underTest.deleteProject(db.getSession(), project.uuid(), ComponentQualifiers.PROJECT, project.name(), project.getKey()); assertThat(logTester.getLogs(LoggerLevel.DEBUG).stream() .map(LogAndArguments::getFormattedMsg) @@ -1611,7 +1611,7 @@ project.getProjectDto().getKey()); dbClient.scannerAnalysisCacheDao().insert(dbSession, branch.getUuid(), IOUtils.toInputStream("test1", UTF_8)); dbClient.scannerAnalysisCacheDao().insert(dbSession, project.getUuid(), IOUtils.toInputStream("test2", UTF_8)); - underTest.deleteProject(dbSession, project.getUuid(), Qualifiers.PROJECT, "project", "project"); + underTest.deleteProject(dbSession, project.getUuid(), ComponentQualifiers.PROJECT, "project", "project"); assertThat(dbClient.scannerAnalysisCacheDao().selectData(dbSession, project.getUuid())).isNull(); assertThat(dbClient.scannerAnalysisCacheDao().selectData(dbSession, branch.getUuid())).isNull(); diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java index 5c88f46f074..bc325265a3e 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java @@ -25,7 +25,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.util.Uuids; @@ -40,7 +40,7 @@ import static org.sonar.db.permission.GlobalPermission.ADMINISTER; class RoleDaoIT { - private static final Set<String> PROJECT_QUALIFIER = Set.of(Qualifiers.PROJECT); + private static final Set<String> PROJECT_QUALIFIER = Set.of(ComponentQualifiers.PROJECT); @RegisterExtension private final DbTester db = DbTester.create(System2.INSTANCE); |