use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class ComponentActionTest method project_tasks.
@Test
public void project_tasks() {
OrganizationDto organizationDto = dbTester.organizations().insert();
dbTester.components().insertComponent(newProjectDto(organizationDto, "PROJECT_1"));
userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1");
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
insertActivity("T3", "PROJECT_1", CeActivityDto.Status.FAILED);
insertQueue("T4", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
insertQueue("T5", "PROJECT_1", CeQueueDto.Status.PENDING);
TestResponse wsResponse = ws.newRequest().setParam("componentId", "PROJECT_1").setMediaType(MediaTypes.PROTOBUF).execute();
WsCe.ProjectResponse response = Protobuf.read(wsResponse.getInputStream(), WsCe.ProjectResponse.parser());
assertThat(response.getQueueCount()).isEqualTo(2);
assertThat(response.getQueue(0).getId()).isEqualTo("T4");
assertThat(response.getQueue(1).getId()).isEqualTo("T5");
// T3 is the latest task executed on PROJECT_1
assertThat(response.hasCurrent()).isTrue();
assertThat(response.getCurrent().getId()).isEqualTo("T3");
assertThat(response.getQueueList()).extracting(WsCe.Task::getOrganization).containsOnly(organizationDto.getKey());
assertThat(response.getCurrent().getOrganization()).isEqualTo(organizationDto.getKey());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchActionTest method test_json_example.
@Test
public void test_json_example() {
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-1");
db.components().insertComponent(newView(organizationDto));
ComponentDto project = newProjectDto(organizationDto, "project-uuid").setName("Project Name").setKey("project-key");
ComponentDto module = newModuleDto("module-uuid", project).setName("Module Name").setKey("module-key");
ComponentDto directory = newDirectory(module, "path/to/directoy").setUuid("directory-uuid").setKey("directory-key").setName("Directory Name");
db.components().insertComponents(project, module, directory, newFileDto(module, directory, "file-uuid").setKey("file-key").setLanguage("java").setName("File Name"));
setBrowsePermissionOnUser(project);
String response = ws.newRequest().setMediaType(MediaTypes.JSON).setParam(PARAM_ORGANIZATION, organizationDto.getKey()).setParam(PARAM_QUALIFIERS, Joiner.on(",").join(PROJECT, MODULE, DIRECTORY, FILE)).execute().getInput();
assertJson(response).isSimilarTo(ws.getDef().responseExampleAsString());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchActionTest method search_with_language.
@Test
public void search_with_language() throws IOException {
OrganizationDto organizationDto = db.organizations().insert();
insertProjectsAuthorizedForUser(newProjectDto(organizationDto).setKey("java-project").setLanguage("java"), newProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp"));
SearchWsResponse response = call(new SearchWsRequest().setOrganization(organizationDto.getKey()).setLanguage("java").setQualifiers(singletonList(PROJECT)));
assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("java-project");
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchActionTest method do_not_verify_permissions_if_user_is_root.
@Test
public void do_not_verify_permissions_if_user_is_root() throws IOException {
OrganizationDto org = db.organizations().insert();
ComponentDto project1 = newProjectDto(org);
ComponentDto file1 = newFileDto(project1);
ComponentDto project2 = newProjectDto(org);
ComponentDto file2 = newFileDto(project2);
db.components().insertComponents(project1, file1, project2, file2);
SearchWsRequest request = new SearchWsRequest().setQualifiers(singletonList(FILE)).setOrganization(org.getKey());
userSession.logIn().setNonRoot();
assertThat(call(request).getComponentsCount()).isZero();
userSession.logIn().setRoot();
assertThat(call(request).getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey(), file2.getKey());
}
use of org.sonar.db.organization.OrganizationDto in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_languages_facet_with_language_having_no_project_if_language_is_in_filter.
@Test
public void return_languages_facet_with_language_having_no_project_if_language_is_in_filter() {
OrganizationDto organization = db.getDefaultOrganization();
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java"));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java"));
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
SearchProjectsWsResponse result = call(request.setFilter("languages = xoo").setFacets(singletonList(FILTER_LANGUAGES)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_LANGUAGES.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsOnly(tuple("xoo", 0L), tuple("java", 2L), tuple("<null>", 1L));
}
Aggregations