diff options
author | Daniel Schwarz <daniel.schwarz@sonarsource.com> | 2017-05-22 18:40:12 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-06-09 08:26:48 +0200 |
commit | 7a9dd7414a10abcec0c3f8e4297ba5d7ff72bcc5 (patch) | |
tree | a3245bc8764d838ec9358b71d00e61380aab97db /it/it-tests | |
parent | 30db273c743f85891db296e66694835a5d524b4d (diff) | |
download | sonarqube-7a9dd7414a10abcec0c3f8e4297ba5d7ff72bcc5.tar.gz sonarqube-7a9dd7414a10abcec0c3f8e4297ba5d7ff72bcc5.zip |
SONAR-9260 add "NO_DATA" range for duplication facet of project search
Diffstat (limited to 'it/it-tests')
-rw-r--r-- | it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java b/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java index 46d30a139b6..5070fd3c5c9 100644 --- a/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java +++ b/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java @@ -23,6 +23,9 @@ import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; import it.Category6Suite; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; import org.assertj.core.groups.Tuple; import org.junit.After; import org.junit.Before; @@ -158,6 +161,7 @@ public class SearchProjectsTest { tuple("70.0-80.0", 0L), tuple("80.0-*", 0L)); checkFacet(response, "duplicated_lines_density", + tuple("NO_DATA", 0L), tuple("*-3.0", 2L), tuple("3.0-5.0", 0L), tuple("5.0-10.0", 0L), @@ -195,27 +199,32 @@ public class SearchProjectsTest { @Test public void should_return_facets_on_leak() throws Exception { setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis"); - String projectKey = newProjectKey(); - analyzeProject(projectKey, "shared/xoo-history-v1"); - analyzeProject(projectKey, "shared/xoo-history-v2"); + // This project has no duplication on new code + String projectKey1 = newProjectKey(); + analyzeProject(projectKey1, "shared/xoo-sample", "2016-12-31"); + analyzeProject(projectKey1, "shared/xoo-sample"); + // This project has 0% duplication on new code + String projectKey2 = newProjectKey(); + analyzeProject(projectKey2, "projectSearch/xoo-history-v1", "2016-12-31"); + analyzeProject(projectKey2, "projectSearch/xoo-history-v2"); SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organizationKey).setFacets(asList( "new_reliability_rating", "new_security_rating", "new_maintainability_rating", "new_coverage", "new_duplicated_lines_density", "new_lines")).build()); checkFacet(response, "new_reliability_rating", - tuple("1", 1L), + tuple("1", 2L), tuple("2", 0L), tuple("3", 0L), tuple("4", 0L), tuple("5", 0L)); checkFacet(response, "new_security_rating", - tuple("1", 1L), + tuple("1", 2L), tuple("2", 0L), tuple("3", 0L), tuple("4", 0L), tuple("5", 0L)); checkFacet(response, "new_maintainability_rating", - tuple("1", 1L), + tuple("1", 2L), tuple("2", 0L), tuple("3", 0L), tuple("4", 0L), @@ -227,13 +236,14 @@ public class SearchProjectsTest { tuple("70.0-80.0", 0L), tuple("80.0-*", 0L)); checkFacet(response, "new_duplicated_lines_density", - tuple("*-3.0", 0L), + tuple("NO_DATA", 1L), + tuple("*-3.0", 1L), tuple("3.0-5.0", 0L), tuple("5.0-10.0", 0L), tuple("10.0-20.0", 0L), tuple("20.0-*", 0L)); checkFacet(response, "new_lines", - tuple("*-1000.0", 0L), + tuple("*-1000.0", 1L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 0L), tuple("100000.0-500000.0", 0L), @@ -242,15 +252,26 @@ public class SearchProjectsTest { private void checkFacet(SearchProjectsWsResponse response, String facetKey, Tuple... values) { Common.Facet facet = response.getFacets().getFacetsList().stream().filter(f -> f.getProperty().equals(facetKey)).findAny().get(); - assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(values); + assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactlyInAnyOrder(values); } private void analyzeProject(String projectKey, String relativePath) { - orchestrator.executeBuild(SonarScanner.create(projectDir(relativePath), + analyzeProject(projectKey, relativePath, null); + } + + private void analyzeProject(String projectKey, String relativePath, @Nullable String analysisDate) { + List<String> keyValueProperties = new ArrayList<>(asList( "sonar.projectKey", projectKey, "sonar.organization", organizationKey, "sonar.profile", "with-many-rules", - "sonar.login", "admin", "sonar.password", "admin")); + "sonar.login", "admin", "sonar.password", "admin", + "sonar.scm.disabled", "false" + )); + if (analysisDate != null) { + keyValueProperties.add("sonar.projectDate"); + keyValueProperties.add(analysisDate); + } + orchestrator.executeBuild(SonarScanner.create(projectDir(relativePath), keyValueProperties.toArray(new String[0]))); } private SearchProjectsWsResponse searchProjects(String filter) throws IOException { |