use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_nloc_facet.
@Test
public void return_nloc_facet() {
userSession.logIn();
MetricDto ncloc = db.measures().insertMetric(c -> c.setKey(NCLOC).setValueType(INT.name()));
insertProject(new Measure(ncloc, c -> c.setValue(5d)));
insertProject(new Measure(ncloc, c -> c.setValue(5d)));
insertProject(new Measure(ncloc, c -> c.setValue(10_000d)));
insertProject(new Measure(ncloc, c -> c.setValue(500_001d)));
index();
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.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));
}
use of org.sonarqube.ws.Components.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() {
userSession.logIn();
MetricDto languagesDistribution = db.measures().insertMetric(c -> c.setKey(NCLOC_LANGUAGE_DISTRIBUTION_KEY).setValueType("DATA"));
insertProject(new Measure(languagesDistribution, c -> c.setValue(null).setData("<null>=2;java=6")));
insertProject(new Measure(languagesDistribution, c -> c.setValue(null).setData("java=5")));
index();
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.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_new_coverage_facet.
@Test
public void return_new_coverage_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(NEW_COVERAGE).setValueType("PERCENT"));
insertProject();
insertProject(new Measure(coverage, c -> c.setVariation(80d)));
insertProject(new Measure(coverage, c -> c.setVariation(85d)));
insertProject(new Measure(coverage, c -> c.setVariation(10d)));
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NEW_COVERAGE)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> NEW_COVERAGE.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsOnly(tuple("NO_DATA", 1L), tuple("*-30.0", 1L), tuple("30.0-50.0", 0L), tuple("50.0-70.0", 0L), tuple("70.0-80.0", 0L), tuple("80.0-*", 2L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_coverage_facet.
@Test
public void return_coverage_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType("PERCENT"));
insertProject();
insertProject(new Measure(coverage, c -> c.setValue(80d)));
insertProject(new Measure(coverage, c -> c.setValue(85d)));
insertProject(new Measure(coverage, c -> c.setValue(10d)));
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(COVERAGE)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> COVERAGE.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsOnly(tuple("NO_DATA", 1L), tuple("*-30.0", 1L), tuple("30.0-50.0", 0L), tuple("50.0-70.0", 0L), tuple("70.0-80.0", 0L), tuple("80.0-*", 2L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method default_filter_projects_and_apps_by_editions.
@Test
@UseDataProvider("component_qualifiers_for_valid_editions")
public void default_filter_projects_and_apps_by_editions(String[] qualifiers, Edition edition) {
when(editionProviderMock.get()).thenReturn(Optional.of(edition));
userSession.logIn();
ComponentDto portfolio1 = insertPortfolio();
ComponentDto portfolio2 = insertPortfolio();
ComponentDto application1 = insertApplication();
ComponentDto application2 = insertApplication();
ComponentDto application3 = insertApplication();
ComponentDto project1 = insertProject();
ComponentDto project2 = insertProject();
ComponentDto project3 = insertProject();
index();
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsCount()).isEqualTo(Stream.of(application1, application2, application3, project1, project2, project3).filter(c -> Stream.of(qualifiers).anyMatch(s -> s.equals(c.qualifier()))).count());
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(Stream.of(application1, application2, application3, project1, project2, project3).filter(c -> Stream.of(qualifiers).anyMatch(s -> s.equals(c.qualifier()))).map(ComponentDto::getDbKey).toArray(String[]::new));
}
Aggregations