use of org.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES_DENSITY_KEY in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_new_duplications_facet.
@Test
public void return_new_duplications_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(NEW_DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
insertProject();
insertProject(new Measure(coverage, c -> c.setVariation(10d)));
insertProject(new Measure(coverage, c -> c.setVariation(15d)));
insertProject(new Measure(coverage, c -> c.setVariation(5d)));
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(NEW_DUPLICATED_LINES_DENSITY_KEY)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> NEW_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.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES_DENSITY_KEY 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());
}
Aggregations