use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method selectByQuery_on_component_ids.
@Test
public void selectByQuery_on_component_ids() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto sonarqube = db.components().insertComponent(newProjectDto(organizationDto));
ComponentDto jdk8 = db.components().insertComponent(newProjectDto(organizationDto));
ComponentDto cLang = db.components().insertComponent(newProjectDto(organizationDto));
ComponentQuery query = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT).setComponentIds(newHashSet(sonarqube.getId(), jdk8.getId())).build();
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
assertThat(result).hasSize(2).extracting(ComponentDto::getId).containsOnlyOnce(sonarqube.getId(), jdk8.getId()).doesNotContain(cLang.getId());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method count_provisioned.
@Test
public void count_provisioned() {
OrganizationDto organization = db.organizations().insert();
db.components().insertProject(organization);
db.components().insertProjectAndSnapshot(ComponentTesting.newProjectDto(organization));
db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization));
assertThat(underTest.countProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.PROJECT))).isEqualTo(1);
assertThat(underTest.countProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.VIEW))).isEqualTo(0);
assertThat(underTest.countProvisioned(dbSession, organization.getUuid(), null, newHashSet(Qualifiers.VIEW, Qualifiers.PROJECT))).isEqualTo(1);
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDaoTest method select_projects_by_name_query.
@Test
public void select_projects_by_name_query() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto project1 = db.components().insertComponent(newProjectDto(organizationDto).setName("project1"));
ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setName("module1"));
ComponentDto subModule1 = db.components().insertComponent(newModuleDto(module1).setName("subModule1"));
db.components().insertComponent(newFileDto(subModule1).setName("file"));
ComponentDto project2 = db.components().insertComponent(newProjectDto(organizationDto).setName("project2"));
ComponentDto project3 = db.components().insertComponent(newProjectDto(organizationDto).setName("project3"));
assertThat(underTest.selectProjectsByNameQuery(dbSession, null, false)).extracting(ComponentDto::uuid).containsOnly(project1.uuid(), project2.uuid(), project3.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, null, true)).extracting(ComponentDto::uuid).containsOnly(project1.uuid(), project2.uuid(), project3.uuid(), module1.uuid(), subModule1.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, "project1", false)).extracting(ComponentDto::uuid).containsOnly(project1.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, "ct1", false)).extracting(ComponentDto::uuid).containsOnly(project1.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, "pro", false)).extracting(ComponentDto::uuid).containsOnly(project1.uuid(), project2.uuid(), project3.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, "jec", false)).extracting(ComponentDto::uuid).containsOnly(project1.uuid(), project2.uuid(), project3.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, "1", true)).extracting(ComponentDto::uuid).containsOnly(project1.uuid(), module1.uuid(), subModule1.uuid());
assertThat(underTest.selectProjectsByNameQuery(dbSession, "unknown", true)).extracting(ComponentDto::uuid).isEmpty();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class PermissionTemplateDaoTest method deleteByOrganization_delete_all_templates_of_organization_and_content_of_child_tables.
@Test
public void deleteByOrganization_delete_all_templates_of_organization_and_content_of_child_tables() {
OrganizationDto organization1 = db.organizations().insert();
OrganizationDto organization2 = db.organizations().insert();
OrganizationDto organization3 = db.organizations().insert();
PermissionTemplateDto[] templates = { createTemplate(organization1), createTemplate(organization2), createTemplate(organization3), createTemplate(organization1), createTemplate(organization2) };
verifyTemplateIdsInDb(templates[0].getId(), templates[1].getId(), templates[2].getId(), templates[3].getId(), templates[4].getId());
underTest.deleteByOrganization(dbSession, organization2.getUuid());
dbSession.commit();
verifyTemplateIdsInDb(templates[0].getId(), templates[2].getId(), templates[3].getId());
underTest.deleteByOrganization(dbSession, organization3.getUuid());
dbSession.commit();
verifyTemplateIdsInDb(templates[0].getId(), templates[3].getId());
underTest.deleteByOrganization(dbSession, organization1.getUuid());
dbSession.commit();
verifyTemplateIdsInDb();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class PermissionTemplateDaoTest method deleteByOrganization_does_not_fail_when_organization_has_no_template.
@Test
public void deleteByOrganization_does_not_fail_when_organization_has_no_template() {
OrganizationDto organization = db.organizations().insert();
underTest.deleteByOrganization(dbSession, organization.getUuid());
dbSession.commit();
}
Aggregations