use of org.sonar.api.measures.CoreMetrics.NEW_LINES_KEY 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.sonar.api.measures.CoreMetrics.NEW_LINES_KEY 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());
}
Aggregations