use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class AnalysisPropertiesDaoTest method selectProjectCountPerAnalysisPropertyValueInLastAnalysis_should_return_correct_values.
@Test
public void selectProjectCountPerAnalysisPropertyValueInLastAnalysis_should_return_correct_values() {
final String analysisPropertyKey = "key";
for (int i = 0; i < 7; i++) {
final int index = i;
ProjectDto project = dbTester.components().insertPrivateProjectDto();
dbTester.components().insertSnapshot(project, s -> s.setLast(true).setUuid("uuid" + index));
}
underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("git").setAnalysisUuid("uuid0").setUuid("0"));
underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("svn").setAnalysisUuid("uuid1").setUuid("1"));
underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("undetected").setAnalysisUuid("uuid2").setUuid("2"));
underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("undetected").setAnalysisUuid("uuid3").setUuid("3"));
underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("git").setAnalysisUuid("uuid4").setUuid("4"));
underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("git").setAnalysisUuid("uuid5").setUuid("5"));
List<ProjectCountPerAnalysisPropertyValue> result = underTest.selectProjectCountPerAnalysisPropertyValueInLastAnalysis(dbSession, analysisPropertyKey);
assertThat(result).extracting(ProjectCountPerAnalysisPropertyValue::getPropertyValue, ProjectCountPerAnalysisPropertyValue::getCount).containsExactlyInAnyOrder(tuple("git", 3L), tuple("svn", 1L), tuple("undetected", 2L));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class CeTaskMessageDaoTest method selectNonDismissedByUserAndTask_returns_non_dismissed_messages.
@Test
public void selectNonDismissedByUserAndTask_returns_non_dismissed_messages() {
UserDto user = dbTester.users().insertUser();
ProjectDto project = dbTester.components().insertPrivateProjectDto();
dbTester.users().insertUserDismissedMessage(user, project, CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
String taskUuid = "17ae66e6-fe83-4c80-b704-4b04e9c5abe8";
CeTaskMessageDto msg1 = insertMessage(taskUuid, 1, 1_222_333L);
insertMessage(taskUuid, 2, 1_222_334L, CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
CeTaskMessageDto msg3 = insertMessage(taskUuid, 3, 1_222_335L);
List<CeTaskMessageDto> messages = underTest.selectNonDismissedByUserAndTask(dbTester.getSession(), taskUuid, user.getUuid());
assertThat(messages).hasSize(2);
assertThat(messages).extracting(CeTaskMessageDto::getUuid).containsExactlyInAnyOrder(msg1.getUuid(), msg3.getUuid());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PurgeCommandsTest method deleteProjectInPortfolios_deletes_branch_from_portfolios_if_root_is_branch.
@Test
public void deleteProjectInPortfolios_deletes_branch_from_portfolios_if_root_is_branch() {
var portfolio1 = dbTester.components().insertPrivatePortfolioDto();
ProjectDto project = dbTester.components().insertPrivateProjectDto();
dbTester.components().addPortfolioProject(portfolio1, project);
dbTester.components().addPortfolioProjectBranch(portfolio1, project, "projectBranch");
dbTester.components().addPortfolioProjectBranch(portfolio1, project, "anotherBranch");
PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler, system2);
purgeCommands.deleteProjectInPortfolios("projectBranch");
assertThat(dbTester.getDbClient().portfolioDao().selectAllPortfolioProjects(dbTester.getSession())).extracting(PortfolioProjectDto::getPortfolioUuid, PortfolioProjectDto::getProjectUuid, PortfolioProjectDto::getBranchUuids).containsExactlyInAnyOrder(tuple(portfolio1.getUuid(), project.getUuid(), Set.of("anotherBranch")));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PurgeCommandsTest method deleteUserDismissedMessages_deletes_dismissed_warnings_on_project_for_all_users.
@Test
public void deleteUserDismissedMessages_deletes_dismissed_warnings_on_project_for_all_users() {
UserDto user1 = dbTester.users().insertUser();
UserDto user2 = dbTester.users().insertUser();
ProjectDto project = dbTester.components().insertPrivateProjectDto();
ProjectDto anotherProject = dbTester.components().insertPrivateProjectDto();
dbTester.users().insertUserDismissedMessage(user1, project, CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
dbTester.users().insertUserDismissedMessage(user2, project, CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
dbTester.users().insertUserDismissedMessage(user1, anotherProject, CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler, system2);
purgeCommands.deleteUserDismissedMessages(project.getUuid());
assertThat(dbTester.countRowsOfTable("user_dismissed_messages")).isOne();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method selectAllDirectChildApplications.
@Test
public void selectAllDirectChildApplications() {
var p1 = db.components().insertPrivatePortfolioDto("portfolio1");
var p2 = db.components().insertPrivatePortfolioDto("portfolio2", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
var p3 = db.components().insertPrivatePortfolioDto("portfolio3", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app3"));
portfolioDao.addReference(session, "portfolio1", app1.getUuid());
portfolioDao.addReference(session, "portfolio2", app2.getUuid());
portfolioDao.addReference(session, "portfolio3", app3.getUuid());
assertThat(portfolioDao.selectApplicationReferenceUuids(session, p1.getUuid())).containsOnly(app1.getUuid());
assertThat(portfolioDao.selectApplicationReferenceUuids(session, p2.getUuid())).containsOnly(app2.getUuid());
assertThat(portfolioDao.selectApplicationReferenceUuids(session, p3.getUuid())).containsOnly(app3.getUuid());
}
Aggregations