use of org.sonar.server.qualitygate.QgateProjectFinder.Association in project sonarqube by SonarSource.
the class QgateProjectFinderTest method return_only_authorized_projects.
@Test
public void return_only_authorized_projects() throws Exception {
UserDto user = dbTester.users().insertUser("a_login");
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto project1 = componentDbTester.insertComponent(newProjectDto(organizationDto));
componentDbTester.insertComponent(newProjectDto(organizationDto));
// User can only see project 1
dbTester.users().insertProjectPermissionOnUser(user, UserRole.USER, project1);
userSession.logIn(user.getLogin()).setUserId(user.getId());
Association result = underTest.find(builder().gateId(Long.toString(qGate.getId())).build());
verifyProjects(result, project1.getId());
}
use of org.sonar.server.qualitygate.QgateProjectFinder.Association in project sonarqube by SonarSource.
the class QgateProjectFinderTest method return_empty_association.
@Test
public void return_empty_association() throws Exception {
Association result = underTest.find(builder().gateId(Long.toString(qGate.getId())).build());
assertThat(result.projects()).isEmpty();
}
use of org.sonar.server.qualitygate.QgateProjectFinder.Association in project sonarqube by SonarSource.
the class QgateProjectFinderTest method return_only_unassociated_project.
@Test
public void return_only_unassociated_project() throws Exception {
OrganizationDto org = dbTester.organizations().insert();
ComponentDto associatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
ComponentDto unassociatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
associateProjectToQualitGate(associatedProject.getId());
Association result = underTest.find(builder().membership(OUT).gateId(Long.toString(qGate.getId())).build());
Map<Long, ProjectQgateAssociation> projectsById = projectsById(result.projects());
assertThat(projectsById).hasSize(1);
verifyProject(projectsById.get(unassociatedProject.getId()), false, unassociatedProject.name());
}
use of org.sonar.server.qualitygate.QgateProjectFinder.Association in project sonarqube by SonarSource.
the class QgateProjectFinderTest method return_only_associated_project.
@Test
public void return_only_associated_project() throws Exception {
OrganizationDto org = dbTester.organizations().insert();
ComponentDto associatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
insertProjectAuthorizedToAnyone(newProjectDto(org));
associateProjectToQualitGate(associatedProject.getId());
Association result = underTest.find(builder().membership(IN).gateId(Long.toString(qGate.getId())).build());
Map<Long, ProjectQgateAssociation> projectsById = projectsById(result.projects());
assertThat(projectsById).hasSize(1);
verifyProject(projectsById.get(associatedProject.getId()), true, associatedProject.name());
}
use of org.sonar.server.qualitygate.QgateProjectFinder.Association in project sonarqube by SonarSource.
the class QgateProjectFinderTest method return_all_projects.
@Test
public void return_all_projects() throws Exception {
OrganizationDto org = dbTester.organizations().insert();
ComponentDto associatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
ComponentDto unassociatedProject = insertProjectAuthorizedToAnyone(newProjectDto(org));
associateProjectToQualitGate(associatedProject.getId());
Association result = underTest.find(builder().gateId(Long.toString(qGate.getId())).build());
Map<Long, ProjectQgateAssociation> projectsById = projectsById(result.projects());
assertThat(projectsById).hasSize(2);
verifyProject(projectsById.get(associatedProject.getId()), true, associatedProject.name());
verifyProject(projectsById.get(unassociatedProject.getId()), false, unassociatedProject.name());
}
Aggregations