use of org.sonarqube.ws.Components.Component 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.Component 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());
}
use of org.sonarqube.ws.Components.Component in project sonarqube by SonarSource.
the class SearchProjectsActionTest method sort_by_quality_gate_then_by_name.
@Test
public void sort_by_quality_gate_then_by_name() {
userSession.logIn();
MetricDto qualityGateStatus = db.measures().insertMetric(c -> c.setKey(QUALITY_GATE_STATUS).setValueType(LEVEL.name()));
ComponentDto project1 = insertProject(c -> c.setName("Sonar Java"), new Measure(qualityGateStatus, c -> c.setValue(null).setData("ERROR")));
ComponentDto project2 = insertProject(c -> c.setName("Sonar Groovy"), new Measure(qualityGateStatus, c -> c.setValue(null).setData("ERROR")));
ComponentDto project3 = insertProject(c -> c.setName("Sonar Markdown"), new Measure(qualityGateStatus, c -> c.setValue(null).setData("OK")));
ComponentDto project4 = insertProject(c -> c.setName("Sonar Qube"), new Measure(qualityGateStatus, c -> c.setValue(null).setData("OK")));
index();
assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(true)).getComponentsList()).extracting(Component::getKey).containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
assertThat(call(request.setSort(QUALITY_GATE_STATUS).setAsc(false)).getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey(), project1.getDbKey(), project3.getDbKey(), project4.getDbKey());
}
use of org.sonarqube.ws.Components.Component in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_ncloc.
@Test
public void filter_projects_by_ncloc() {
userSession.logIn();
MetricDto ncloc = db.measures().insertMetric(c -> c.setKey(NCLOC).setValueType(INT.name()));
ComponentDto project1 = insertProject(new Measure(ncloc, c -> c.setValue(80d)));
ComponentDto project2 = insertProject(new Measure(ncloc, c -> c.setValue(85d)));
ComponentDto project3 = insertProject(new Measure(ncloc, c -> c.setValue(10d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("ncloc <= 80"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
use of org.sonarqube.ws.Components.Component in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_with_query.
@Test
public void filter_projects_with_query() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType(INT.name()));
MetricDto ncloc = db.measures().insertMetric(c -> c.setKey(NCLOC).setValueType(INT.name()));
ComponentDto project1 = insertProject(new Measure(coverage, c -> c.setValue(81d)), new Measure(ncloc, c -> c.setValue(10_000d)));
ComponentDto project2 = insertProject(new Measure(coverage, c -> c.setValue(80d)), new Measure(ncloc, c -> c.setValue(10_000d)));
ComponentDto project3 = insertProject(new Measure(coverage, c -> c.setValue(80d)), new Measure(ncloc, c -> c.setValue(10_001d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("coverage <= 80 and ncloc <= 10000"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
}
Aggregations