use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ProjectDataLoaderMediumTest method return_sub_module_settings.
@Test
public void return_sub_module_settings() {
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
dbClient.organizationDao().insert(dbSession, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
dbClient.componentDao().insert(dbSession, project);
addDefaultProfile();
// No project properties
ComponentDto module = ComponentTesting.newModuleDto(project);
dbClient.componentDao().insert(dbSession, module);
// No module properties
ComponentDto subModule = ComponentTesting.newModuleDto(module);
userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
dbClient.componentDao().insert(dbSession, subModule);
// Sub module properties
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(subModule.getId()));
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(subModule.getId()));
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(subModule.getId()));
dbSession.commit();
ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(subModule.key()));
assertThat(ref.settings(project.key())).isEmpty();
assertThat(ref.settings(module.key())).isEmpty();
assertThat(ref.settings(subModule.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR", "sonar.jira.login.secured", "john", "sonar.coverage.exclusions", "**/*.java"));
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method select_ghost_projects.
@Test
public void select_ghost_projects() {
OrganizationDto organization = db.organizations().insert();
// ghosts because has at least one snapshot with status U but none with status P
ComponentDto ghostProject = db.components().insertProject(organization);
db.components().insertSnapshot(ghostProject, dto -> dto.setStatus("U"));
db.components().insertSnapshot(ghostProject, dto -> dto.setStatus("U"));
ComponentDto ghostProject2 = db.components().insertProject(organization);
db.components().insertSnapshot(ghostProject2, dto -> dto.setStatus("U"));
ComponentDto disabledGhostProject = db.components().insertProject(dto -> dto.setEnabled(false));
db.components().insertSnapshot(disabledGhostProject, dto -> dto.setStatus("U"));
ComponentDto project1 = db.components().insertProject(organization);
db.components().insertSnapshot(project1, dto -> dto.setStatus("P"));
db.components().insertSnapshot(project1, dto -> dto.setStatus("U"));
ComponentDto module = db.components().insertComponent(newModuleDto(project1));
ComponentDto dir = db.components().insertComponent(newDirectory(module, "foo"));
db.components().insertComponent(newFileDto(module, dir, "bar"));
ComponentDto provisionedProject = db.components().insertProject(organization);
// not a ghost because has at least one snapshot with status P
ComponentDto project2 = db.components().insertProject(organization);
db.components().insertSnapshot(project2, dto -> dto.setStatus("P"));
// not a ghost because it's not a project
ComponentDto view = db.components().insertView(organization);
db.components().insertSnapshot(view, dto -> dto.setStatus("U"));
db.components().insertComponent(newProjectCopy("do", project1, view));
assertThat(underTest.selectGhostProjects(dbSession, organization.getUuid(), null, 0, 10)).extracting(ComponentDto::uuid).containsOnly(ghostProject.uuid(), ghostProject2.uuid(), disabledGhostProject.uuid());
assertThat(underTest.countGhostProjects(dbSession, organization.getUuid(), null)).isEqualTo(3);
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method select_projects.
@Test
public void select_projects() {
OrganizationDto organization = db.organizations().insert();
ComponentDto provisionedProject = db.components().insertProject();
ComponentDto provisionedView = db.components().insertView(organization, (dto) -> {
});
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid();
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid();
String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid();
assertThat(underTest.selectProjects(dbSession)).extracting(ComponentDto::uuid).containsOnly(provisionedProject.uuid(), projectUuid);
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method select_provisioned.
@Test
public void select_provisioned() {
OrganizationDto organization = db.organizations().insert();
ComponentDto provisionedProject = db.components().insertComponent(newProjectDto(organization).setKey("provisioned.project").setName("Provisioned Project"));
ComponentDto provisionedView = db.components().insertView(organization);
String projectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization)).getComponentUuid();
String disabledProjectUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization).setEnabled(false)).getComponentUuid();
String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid();
Set<String> projectQualifiers = newHashSet(Qualifiers.PROJECT);
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), null, projectQualifiers, new RowBounds(0, 10))).extracting(ComponentDto::uuid).containsOnly(provisionedProject.uuid());
// pagination
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), null, projectQualifiers, new RowBounds(2, 10))).isEmpty();
// filter on qualifiers
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), null, newHashSet("XXX"), new RowBounds(0, 10))).isEmpty();
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.PROJECT, "XXX"), new RowBounds(0, 10))).extracting(ComponentDto::uuid).containsOnly(provisionedProject.uuid());
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.PROJECT, Qualifiers.VIEW), new RowBounds(0, 10))).extracting(ComponentDto::uuid).containsOnly(provisionedProject.uuid(), provisionedView.uuid());
// match key
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), provisionedProject.getKey(), projectQualifiers, new RowBounds(0, 10))).extracting(ComponentDto::uuid).containsExactly(provisionedProject.uuid());
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), "pROvisiONed.proJEcT", projectQualifiers, new RowBounds(0, 10))).extracting(ComponentDto::uuid).containsExactly(provisionedProject.uuid());
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), "missing", projectQualifiers, new RowBounds(0, 10))).isEmpty();
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), "to be escaped '\"\\%", projectQualifiers, new RowBounds(0, 10))).isEmpty();
// match name
assertThat(underTest.selectProvisioned(dbSession, organization.getUuid(), "ned proj", projectQualifiers, new RowBounds(0, 10))).extracting(ComponentDto::uuid).containsExactly(provisionedProject.uuid());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method selectAncestors.
@Test
public void selectAncestors() {
// organization
OrganizationDto organization = db.organizations().insert();
// project -> module -> file
ComponentDto project = newProjectDto(organization, PROJECT_UUID);
db.components().insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
db.components().insertComponent(module);
ComponentDto file = newFileDto(module, null, FILE_1_UUID);
db.components().insertComponent(file);
db.commit();
// ancestors of root
List<ComponentDto> ancestors = underTest.selectAncestors(dbSession, project);
assertThat(ancestors).isEmpty();
// ancestors of module
ancestors = underTest.selectAncestors(dbSession, module);
assertThat(ancestors).extracting("uuid").containsExactly(PROJECT_UUID);
// ancestors of file
ancestors = underTest.selectAncestors(dbSession, file);
assertThat(ancestors).extracting("uuid").containsExactly(PROJECT_UUID, MODULE_UUID);
}
Aggregations