use of org.sonarqube.ws.WsComponents.SearchProjectsWsResponse 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));
}
use of org.sonarqube.ws.WsComponents.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_last_analysis_date.
@Test
public void return_last_analysis_date() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto project1 = insertProjectInDbAndEs(newProjectDto(organizationDto));
db.components().insertSnapshot(newAnalysis(project1).setCreatedAt(10_000_000_000L).setLast(false));
db.components().insertSnapshot(newAnalysis(project1).setCreatedAt(20_000_000_000L).setLast(true));
ComponentDto project2 = insertProjectInDbAndEs(newProjectDto(organizationDto));
db.components().insertSnapshot(newAnalysis(project2).setCreatedAt(30_000_000_000L).setLast(true));
// No snapshot on project 3
insertProjectInDbAndEs(newProjectDto(organizationDto));
SearchProjectsWsResponse result = call(request.setAdditionalFields(singletonList("analysisDate")));
assertThat(result.getComponentsList()).extracting(Component::getAnalysisDate).containsOnly(formatDateTime(new Date(20_000_000_000L)), formatDateTime(new Date(30_000_000_000L)), "");
}
use of org.sonarqube.ws.WsComponents.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_languages_facet.
@Test
public void return_languages_facet() {
OrganizationDto organization = db.getDefaultOrganization();
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo"));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo"));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo"));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo"));
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_LANGUAGES)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_LANGUAGES.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getProperty()).isEqualTo(FILTER_LANGUAGES);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("xoo", 4L), tuple("java", 3L), tuple("<null>", 2L));
}
use of org.sonarqube.ws.WsComponents.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_languages.
@Test
public void filter_projects_by_languages() {
OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81d)), null, asList("<null>", "java", "xoo"));
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81)), null, asList("java", "xoo"));
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("xoo"));
insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d)), null, asList("<null>", "java", "xoo"));
insertMetrics(COVERAGE, NCLOC_LANGUAGE_DISTRIBUTION_KEY);
request.setFilter("languages IN (java, js, <null>)");
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java", "Sonar Groovy", "Sonar Qube");
}
use of org.sonarqube.ws.WsComponents.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_nloc_facet.
@Test
public void return_nloc_facet() {
OrganizationDto organization = db.getDefaultOrganization();
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
insertMetrics(COVERAGE, NCLOC);
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NCLOC)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> NCLOC.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getProperty()).isEqualTo(NCLOC);
assertThat(facet.getValuesCount()).isEqualTo(5);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("*-1000.0", 2L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 1L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 1L));
}
Aggregations