Search in sources :

Example 26 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class UserDismissedMessagesDaoTest method selectByUserAndProjectAndMessageType_returns_object_if_record_found.

@Test
public void selectByUserAndProjectAndMessageType_returns_object_if_record_found() {
    UserDto user = db.users().insertUser();
    ProjectDto project = db.components().insertPrivateProjectDto();
    db.users().insertUserDismissedMessage(user, project, CeTaskMessageType.GENERIC);
    Optional<UserDismissedMessageDto> result = underTest.selectByUserAndProjectAndMessageType(db.getSession(), user, project, CeTaskMessageType.GENERIC);
    assertThat(result).isPresent();
    assertThat(result.get().getUserUuid()).isEqualTo(user.getUuid());
    assertThat(result.get().getProjectUuid()).isEqualTo(project.getUuid());
    assertThat(result.get().getCeMessageType()).isEqualTo(CeTaskMessageType.GENERIC);
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 27 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class UserDismissedMessagesDaoTest method deleteByUserUuid_removes_dismissed_messages_of_that_type.

@Test
public void deleteByUserUuid_removes_dismissed_messages_of_that_type() {
    UserDto user1 = db.users().insertUser();
    UserDto user2 = db.users().insertUser();
    ProjectDto project1 = db.components().insertPrivateProjectDto();
    ProjectDto project2 = db.components().insertPrivateProjectDto();
    UserDismissedMessageDto dto1 = db.users().insertUserDismissedMessage(user1, project1, CeTaskMessageType.GENERIC);
    db.users().insertUserDismissedMessage(user1, project2, SUGGEST_DEVELOPER_EDITION_UPGRADE);
    db.users().insertUserDismissedMessage(user2, project1, SUGGEST_DEVELOPER_EDITION_UPGRADE);
    UserDismissedMessageDto dto2 = db.users().insertUserDismissedMessage(user2, project2, CeTaskMessageType.GENERIC);
    underTest.deleteByType(db.getSession(), SUGGEST_DEVELOPER_EDITION_UPGRADE);
    assertThat(underTest.selectByUser(db.getSession(), user1)).extracting(UserDismissedMessageDto::getUuid).containsExactly(dto1.getUuid());
    assertThat(underTest.selectByUser(db.getSession(), user2)).extracting(UserDismissedMessageDto::getUuid).containsExactly(dto2.getUuid());
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 28 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class UserDismissedMessagesDaoTest method selectByUserAndProjectAndMessageType_returns_absent_if_no_record_found.

@Test
public void selectByUserAndProjectAndMessageType_returns_absent_if_no_record_found() {
    UserDto user = db.users().insertUser();
    ProjectDto project = db.components().insertPrivateProjectDto();
    db.users().insertUserDismissedMessage(user, project, CeTaskMessageType.GENERIC);
    Optional<UserDismissedMessageDto> result = underTest.selectByUserAndProjectAndMessageType(db.getSession(), user, project, SUGGEST_DEVELOPER_EDITION_UPGRADE);
    assertThat(result).isNotPresent();
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 29 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class WebhookDaoWithPersisterTest method deleteProjectWebhooksWithoutAffectedRowsIsNotPersisted.

@Test
public void deleteProjectWebhooksWithoutAffectedRowsIsNotPersisted() {
    ProjectDto projectDto = componentDbTester.insertPrivateProjectDto(p -> p.setUuid("puuid").setName("pname"));
    underTest.deleteByProject(dbSession, projectDto);
    verify(auditPersister).addComponent(any(), any());
    verifyNoMoreInteractions(auditPersister);
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 30 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class ComponentDbTester method insertComponentAndBranchAndProject.

private ComponentDto insertComponentAndBranchAndProject(ComponentDto component, @Nullable Boolean isPrivate, Consumer<BranchDto> branchPopulator, Consumer<ComponentDto> componentDtoPopulator, Consumer<ProjectDto> projectDtoPopulator) {
    insertComponentImpl(component, isPrivate, componentDtoPopulator);
    ProjectDto projectDto = toProjectDto(component, System2.INSTANCE.now());
    projectDtoPopulator.accept(projectDto);
    dbClient.projectDao().insert(dbSession, projectDto);
    BranchDto branchDto = ComponentTesting.newBranchDto(component, BRANCH);
    branchDto.setExcludeFromPurge(true);
    branchPopulator.accept(branchDto);
    dbClient.branchDao().insert(dbSession, branchDto);
    db.commit();
    return component;
}
Also used : PortfolioProjectDto(org.sonar.db.portfolio.PortfolioProjectDto) ProjectDto(org.sonar.db.project.ProjectDto)

Aggregations

ProjectDto (org.sonar.db.project.ProjectDto)283 Test (org.junit.Test)215 DbSession (org.sonar.db.DbSession)49 BranchDto (org.sonar.db.component.BranchDto)42 UserDto (org.sonar.db.user.UserDto)39 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)38 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)31 SnapshotDto (org.sonar.db.component.SnapshotDto)27 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)26 ComponentDto (org.sonar.db.component.ComponentDto)23 ComponentTesting.newPrivateProjectDto (org.sonar.db.component.ComponentTesting.newPrivateProjectDto)20 NotFoundException (org.sonar.server.exceptions.NotFoundException)17 WebhookDto (org.sonar.db.webhook.WebhookDto)15 ApplicationProjectDto (org.sonar.db.project.ApplicationProjectDto)14 WebService (org.sonar.api.server.ws.WebService)13 DbClient (org.sonar.db.DbClient)12 PortfolioProjectDto (org.sonar.db.portfolio.PortfolioProjectDto)12 TestRequest (org.sonar.server.ws.TestRequest)11 TestResponse (org.sonar.server.ws.TestResponse)10 Projects (org.sonarqube.ws.Projects)10