use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_and_apps_by_APP_qualifier_when_ee_dc.
@Test
@UseDataProvider("enterprise_or_datacenter_edition")
public void filter_projects_and_apps_by_APP_qualifier_when_ee_dc(Edition edition) {
when(editionProviderMock.get()).thenReturn(Optional.of(edition));
userSession.logIn();
ComponentDto application1 = insertApplication();
ComponentDto application2 = insertApplication();
ComponentDto application3 = insertApplication();
insertProject();
insertProject();
insertProject();
index();
SearchProjectsWsResponse result = call(request.setFilter("qualifier = APP"));
assertThat(result.getComponentsCount()).isEqualTo(3);
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(Stream.of(application1, application2, application3).map(ComponentDto::getDbKey).toArray(String[]::new));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse 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.SearchProjectsWsResponse 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