Search in sources :

Example 6 with OrganizationDto

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());
}
Also used : OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 7 with OrganizationDto

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);
}
Also used : OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 8 with OrganizationDto

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();
}
Also used : OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 9 with OrganizationDto

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();
}
Also used : PermissionTemplateTesting.newPermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 10 with OrganizationDto

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();
}
Also used : OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

OrganizationDto (org.sonar.db.organization.OrganizationDto)384 Test (org.junit.Test)329 ComponentDto (org.sonar.db.component.ComponentDto)148 GroupDto (org.sonar.db.user.GroupDto)74 UserDto (org.sonar.db.user.UserDto)40 DbSession (org.sonar.db.DbSession)35 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)33 TestResponse (org.sonar.server.ws.TestResponse)19 SnapshotDto (org.sonar.db.component.SnapshotDto)17 BasePermissionWsTest (org.sonar.server.permission.ws.BasePermissionWsTest)16 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)15 PropertyDto (org.sonar.db.property.PropertyDto)13 SearchProjectsWsResponse (org.sonarqube.ws.WsComponents.SearchProjectsWsResponse)12 GroupTesting.newGroupDto (org.sonar.db.user.GroupTesting.newGroupDto)11 SearchOptions (org.sonar.server.es.SearchOptions)11 OrganizationTesting.newOrganizationDto (org.sonar.db.organization.OrganizationTesting.newOrganizationDto)9 PermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateGroupDto)8 Organizations (org.sonarqube.ws.Organizations)8 MetricDto (org.sonar.db.metric.MetricDto)7 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)7