use of org.sonarqube.ws.Components.Component in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_no_duplication.
@Test
public void filter_projects_by_no_duplication() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType("PERCENT"));
MetricDto duplications = db.measures().insertMetric(c -> c.setKey(DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
ComponentDto project1 = insertProject(new Measure(coverage, c -> c.setValue(10d)));
ComponentDto project2 = insertProject(new Measure(duplications, c -> c.setValue(0d)));
ComponentDto project3 = insertProject(new Measure(duplications, c -> c.setValue(79d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density = NO_DATA"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey());
}
use of org.sonarqube.ws.Components.Component in project sonarqube by SonarSource.
the class SearchProjectsActionTest method sort_by_coverage_then_by_name.
@Test
public void sort_by_coverage_then_by_name() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType(INT.name()));
ComponentDto project1 = insertProject(c -> c.setName("Sonar Java"), new Measure(coverage, c -> c.setValue(81d)));
ComponentDto project2 = insertProject(c -> c.setName("Sonar Groovy"), new Measure(coverage, c -> c.setValue(81d)));
ComponentDto project3 = insertProject(c -> c.setName("Sonar Markdown"), new Measure(coverage, c -> c.setValue(80d)));
ComponentDto project4 = insertProject(c -> c.setName("Sonar Qube"), new Measure(coverage, c -> c.setValue(80d)));
index();
assertThat(call(request.setSort(COVERAGE).setAsc(true)).getComponentsList()).extracting(Component::getKey).containsExactly(project3.getDbKey(), project4.getDbKey(), project2.getDbKey(), project1.getDbKey());
assertThat(call(request.setSort(COVERAGE).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 use_deprecated_warning_quality_gate_in_filter.
@Test
public void use_deprecated_warning_quality_gate_in_filter() {
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("WARN")));
ComponentDto project3 = insertProject(c -> c.setName("Sonar Markdown"), new Measure(qualityGateStatus, c -> c.setValue(null).setData("WARN")));
ComponentDto project4 = insertProject(c -> c.setName("Sonar Qube"), new Measure(qualityGateStatus, c -> c.setValue(null).setData("OK")));
index();
List<Component> projects = call(request.setFilter("alert_status = WARN")).getComponentsList();
assertThat(projects).extracting(Component::getKey).containsExactly(project2.getKey(), project3.getKey());
}
use of org.sonarqube.ws.Components.Component in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_rating.
@Test
@UseDataProvider("rating_metric_keys")
public void filter_projects_by_rating(String metricKey) {
userSession.logIn();
MetricDto ratingMetric = db.measures().insertMetric(c -> c.setKey(metricKey).setValueType(INT.name()));
ComponentDto project1 = insertProject(new Measure(ratingMetric, c -> c.setValue(1d)));
ComponentDto project2 = insertProject(new Measure(ratingMetric, c -> c.setValue(2d)));
ComponentDto project3 = insertProject(new Measure(ratingMetric, c -> c.setValue(3d)));
index();
SearchProjectsWsResponse result = call(request.setFilter(metricKey + " = 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 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