use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentDtoToWsComponentTest method componentDtoToWsComponent_throws_IAE_if_organization_uuid_of_component_does_not_match_organizationDto_uuid.
@Test
public void componentDtoToWsComponent_throws_IAE_if_organization_uuid_of_component_does_not_match_organizationDto_uuid() {
OrganizationDto organizationDto1 = OrganizationTesting.newOrganizationDto();
OrganizationDto organizationDto2 = OrganizationTesting.newOrganizationDto();
ComponentDto componentDto = ComponentTesting.newProjectDto(organizationDto1);
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("OrganizationUuid (" + organizationDto1.getUuid() + ") of ComponentDto to convert " + "to Ws Component is not the same as the one (" + organizationDto2.getUuid() + ") of the specified OrganizationDto");
componentDtoToWsComponent(componentDto, organizationDto2, Optional.empty());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ProjectDataLoaderMediumTest method return_file_data_from_module.
@Test
public void return_file_data_from_module() {
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
dbClient.organizationDao().insert(dbSession, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
dbClient.componentDao().insert(dbSession, project);
addDefaultProfile();
// File on project
ComponentDto projectFile = ComponentTesting.newFileDto(project, null, "projectFile");
dbClient.componentDao().insert(dbSession, projectFile);
tester.get(FileSourceDao.class).insert(dbSession, newFileSourceDto(projectFile).setSrcHash("123456").setRevision("987654321"));
ComponentDto module = ComponentTesting.newModuleDto(project);
userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
dbClient.componentDao().insert(dbSession, module);
// File on module
ComponentDto moduleFile = ComponentTesting.newFileDto(module, null, "moduleFile");
dbClient.componentDao().insert(dbSession, moduleFile);
tester.get(FileSourceDao.class).insert(dbSession, newFileSourceDto(moduleFile).setSrcHash("789456").setRevision("123456789"));
dbSession.commit();
ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(module.key()));
assertThat(ref.fileData(module.key(), moduleFile.path()).hash()).isEqualTo("789456");
assertThat(ref.fileData(module.key(), moduleFile.path()).revision()).isEqualTo("123456789");
assertThat(ref.fileData(project.key(), projectFile.path())).isNull();
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ProjectDataLoaderMediumTest method fail_when_preview_and_only_scan_permission_without_browse_permission.
@Test
public void fail_when_preview_and_only_scan_permission_without_browse_permission() {
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
dbClient.organizationDao().insert(dbSession, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
dbClient.componentDao().insert(dbSession, project);
dbSession.commit();
userSessionRule.logIn("john").addProjectUuidPermissions(GlobalPermissions.SCAN_EXECUTION, project.projectUuid());
thrown.expect(ForbiddenException.class);
thrown.expectMessage("You don't have the required permissions to access this project. Please contact your SonarQube administrator.");
underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ProjectDataLoaderTest method load_fails_with_BRE_if_component_is_neither_a_project_or_a_module.
@Test
public void load_fails_with_BRE_if_component_is_neither_a_project_or_a_module() {
String[][] allScopesAndQualifierButProjectAndModule = { { Scopes.PROJECT, Qualifiers.VIEW }, { Scopes.PROJECT, Qualifiers.SUBVIEW }, { Scopes.FILE, Qualifiers.PROJECT }, { Scopes.DIRECTORY, Qualifiers.DIRECTORY }, { Scopes.FILE, Qualifiers.UNIT_TEST_FILE }, { Scopes.PROJECT, "DEV" }, { Scopes.PROJECT, "DEV_PRJ" } };
OrganizationDto organizationDto = dbTester.organizations().insert();
for (String[] scopeAndQualifier : allScopesAndQualifierButProjectAndModule) {
String scope = scopeAndQualifier[0];
String qualifier = scopeAndQualifier[1];
String key = "theKey_" + scope + "_" + qualifier;
String uuid = "uuid_" + uuidCounter++;
dbClient.componentDao().insert(dbSession, new ComponentDto().setOrganizationUuid(organizationDto.getUuid()).setUuid(uuid).setUuidPath(uuid + ".").setRootUuid(uuid).setScope(scope).setQualifier(qualifier).setKey(key));
dbSession.commit();
try {
underTest.load(ProjectDataQuery.create().setModuleKey(key));
fail(format("A NotFoundException should have been raised because scope (%s) or qualifier (%s) is not project", scope, qualifier));
} catch (BadRequestException e) {
assertThat(e).hasMessage("Key '" + key + "' belongs to a component which is not a Project");
}
}
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ActivityActionTest method search_activity_returns_views_and_developers.
@Test
public void search_activity_returns_views_and_developers() {
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto apacheView = newView(organizationDto).setName("Apache View").setUuid("V1").setProjectUuid("V1");
ComponentDto developer = newDeveloper(organizationDto, "Apache Developer").setUuid("D1").setProjectUuid("D1");
dbTester.components().insertDeveloperAndSnapshot(developer);
dbTester.components().insertViewAndSnapshot(apacheView);
logInAsSystemAdministrator();
insertActivity("T1", "D1", CeActivityDto.Status.SUCCESS);
insertActivity("T2", "V1", CeActivityDto.Status.SUCCESS);
ActivityResponse activityResponse = call(ws.newRequest().setParam(PARAM_COMPONENT_QUERY, "apac"));
assertThat(activityResponse.getTasksList()).extracting("id").containsOnly("T1", "T2");
}
Aggregations