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);
}
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());
}
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();
}
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);
}
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;
}
Aggregations