use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_new_lines_facet.
@Test
public void return_new_lines_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(NEW_LINES_KEY).setValueType(INT.name()));
insertProject(new Measure(coverage, c -> c.setVariation(100d)));
insertProject(new Measure(coverage, c -> c.setVariation(15_000d)));
insertProject(new Measure(coverage, c -> c.setVariation(50_000d)));
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NEW_LINES_KEY)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> NEW_LINES_KEY.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("*-1000.0", 1L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 2L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 0L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsAction method handle.
@Override
public void handle(Request httpRequest, Response httpResponse) throws Exception {
SearchProjectsWsResponse response = doHandle(toRequest(httpRequest));
writeProtobuf(response, httpRequest, httpResponse);
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_coverage.
@Test
public void filter_projects_by_coverage() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType("PERCENT"));
ComponentDto project1 = insertProject(new Measure(coverage, c -> c.setValue(80d)));
ComponentDto project2 = insertProject(new Measure(coverage, c -> c.setValue(85d)));
ComponentDto project3 = insertProject(new Measure(coverage, c -> c.setValue(10d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("coverage <= 80"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_new_lines.
@Test
public void filter_projects_by_new_lines() {
userSession.logIn();
MetricDto newLines = db.measures().insertMetric(c -> c.setKey(NEW_LINES_KEY).setValueType(INT.name()));
ComponentDto project1 = insertProject(new Measure(newLines, c -> c.setVariation(80d)));
ComponentDto project2 = insertProject(new Measure(newLines, c -> c.setVariation(85d)));
ComponentDto project3 = insertProject(new Measure(newLines, c -> c.setVariation(10d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("new_lines <= 80"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_on_favorites.
@Test
public void filter_projects_on_favorites() {
userSession.logIn();
ComponentDto javaProject = insertProject();
ComponentDto markDownProject = insertProject();
ComponentDto sonarQubeProject = insertProject();
Stream.of(javaProject, markDownProject).forEach(this::addFavourite);
index();
SearchProjectsWsResponse result = call(request.setFilter("isFavorite"));
assertThat(result.getComponentsCount()).isEqualTo(2);
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getDbKey(), markDownProject.getDbKey());
}
Aggregations