use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_new_duplications.
@Test
public void filter_projects_by_new_duplications() {
userSession.logIn();
MetricDto newDuplications = db.measures().insertMetric(c -> c.setKey(NEW_DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
ComponentDto project1 = insertProject(new Measure(newDuplications, c -> c.setVariation(80d)));
ComponentDto project2 = insertProject(new Measure(newDuplications, c -> c.setVariation(85d)));
ComponentDto project3 = insertProject(new Measure(newDuplications, c -> c.setVariation(10d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("new_duplicated_lines_density <= 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 return_duplications_facet.
@Test
public void return_duplications_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
insertProject(new Measure(coverage, c -> c.setValue(10d)));
insertProject(new Measure(coverage, c -> c.setValue(15d)));
insertProject(new Measure(coverage, c -> c.setValue(5d)));
insertProject();
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(DUPLICATED_LINES_DENSITY_KEY)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> DUPLICATED_LINES_DENSITY_KEY.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsOnly(tuple("NO_DATA", 1L), tuple("*-3.0", 0L), tuple("3.0-5.0", 0L), tuple("5.0-10.0", 1L), tuple("10.0-20.0", 2L), tuple("20.0-*", 0L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_quality_gate.
@Test
public void filter_projects_by_quality_gate() {
userSession.logIn();
MetricDto qualityGateStatus = db.measures().insertMetric(c -> c.setKey(QUALITY_GATE_STATUS).setValueType(LEVEL.name()));
ComponentDto project1 = insertProject(new Measure(qualityGateStatus, c -> c.setValue(null).setData("OK")));
ComponentDto project2 = insertProject(new Measure(qualityGateStatus, c -> c.setValue(null).setData("OK")));
ComponentDto project3 = insertProject(new Measure(qualityGateStatus, c -> c.setValue(null).setData("ERROR")));
index();
SearchProjectsWsResponse result = call(request.setFilter("alert_status = OK"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project2.getDbKey());
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method does_not_return_branches.
@Test
public void does_not_return_branches() {
ComponentDto project = db.components().insertPublicProject();
authorizationIndexerTester.allowOnlyAnyone(project);
ComponentDto branch = db.components().insertProjectBranch(project);
index();
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project.getDbKey());
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_new_rating.
@Test
@UseDataProvider("new_rating_metric_keys")
public void filter_projects_by_new_rating(String newMetricKey) {
userSession.logIn();
MetricDto ratingMetric = db.measures().insertMetric(c -> c.setKey(newMetricKey).setValueType(INT.name()));
insertProject(new Measure(ratingMetric, c -> c.setVariation(1d)));
ComponentDto project2 = insertProject(new Measure(ratingMetric, c -> c.setVariation(2d)));
insertProject(new Measure(ratingMetric, c -> c.setVariation(3d)));
index();
SearchProjectsWsResponse result = call(request.setFilter(newMetricKey + " = 2"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
}
Aggregations