use of org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_DENSITY_KEY 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.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_DENSITY_KEY in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_duplications.
@Test
public void filter_projects_by_duplications() {
userSession.logIn();
MetricDto duplications = db.measures().insertMetric(c -> c.setKey(DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
ComponentDto project1 = insertProject(new Measure(duplications, c -> c.setValue(80d)));
ComponentDto project2 = insertProject(new Measure(duplications, c -> c.setValue(85d)));
ComponentDto project3 = insertProject(new Measure(duplications, c -> c.setValue(10d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density <= 80"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
use of org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_DENSITY_KEY in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_no_duplication_should_not_return_projects_with_duplication.
@Test
public void filter_projects_by_no_duplication_should_not_return_projects_with_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"));
insertProject(new Measure(duplications, c -> c.setValue(10d)), new Measure(coverage, c -> c.setValue(50d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density = NO_DATA"));
assertThat(result.getComponentsList()).extracting(Component::getKey).isEmpty();
}
use of org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_DENSITY_KEY in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_duplications_facet.
@Test
public void return_duplications_facet() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
insertProject(new Measure(coverage, c -> c.setValue(10d)));
insertProject(new Measure(coverage, c -> c.setValue(15d)));
insertProject(new Measure(coverage, c -> c.setValue(5d)));
insertProject();
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(DUPLICATED_LINES_DENSITY_KEY)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> 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));
}
Aggregations