]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10257 Fix ITs
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 24 Jan 2018 12:53:39 +0000 (13:53 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 7 Feb 2018 13:33:55 +0000 (14:33 +0100)
tests/projects/shared/xoo-sample-missing-some-lines/sonar-project.properties [new file with mode: 0644]
tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo [new file with mode: 0644]
tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo.measures [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDateQPChangedTest.java
tests/src/test/java/org/sonarqube/tests/issue/NewIssuesMeasureTest.java
tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java
tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtAndIssueNewMeasuresTest.java
tests/src/test/java/org/sonarqube/tests/source/ScmTest.java
tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java
tests/src/test/java/org/sonarqube/tests/source/SourceSuite.java
tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java

diff --git a/tests/projects/shared/xoo-sample-missing-some-lines/sonar-project.properties b/tests/projects/shared/xoo-sample-missing-some-lines/sonar-project.properties
new file mode 100644 (file)
index 0000000..9e4aa0e
--- /dev/null
@@ -0,0 +1,5 @@
+sonar.projectKey=sample
+sonar.projectName=Sample
+sonar.projectVersion=1.0-SNAPSHOT
+sonar.sources=src/main/xoo
+sonar.language=xoo
diff --git a/tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo b/tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo
new file mode 100644 (file)
index 0000000..4ee57fd
--- /dev/null
@@ -0,0 +1,9 @@
+package sample;
+
+public class Sample {
+       
+       public Sample(int i) {
+               int j = i++;
+       }
+       
+}
diff --git a/tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo.measures b/tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo.measures
new file mode 100644 (file)
index 0000000..a403da9
--- /dev/null
@@ -0,0 +1,9 @@
+ncloc:6
+#Used by dashboard/widgets tests
+complexity:1
+complexity_in_classes:1
+cognitive_complexity:2
+classes:1
+comment_lines:2
+public_api:3
+public_undocumented_api:1
index 30c3e101ce30501ecac8a7f6d846455ab7bb5144..c9196dfe22f9b22dc07f886f1a7463c0a2ab917b 100644 (file)
@@ -146,10 +146,9 @@ public class IssueCreationDateQPChangedTest extends AbstractIssueTest {
     analysis(QProfile.ONE_RULE, SourceCode.CHANGED);
 
     assertNumberOfIssues(3);
-    Stream.of(COMPONENTS_OF_SOURCE_CHANGED)
-      .forEach(component -> {
-        assertIssueCreationDate(component, IssueCreationDate.LATEST_ANALYSIS);
-      });
+    assertIssueCreationDate(Component.ForeverAndModified, IssueCreationDate.LATEST_ANALYSIS);
+    assertIssueCreationDate(Component.ForeverAndUnmodified, IssueCreationDate.FIRST_ANALYSIS);
+    assertIssueCreationDate(Component.OnlyInChanged, IssueCreationDate.LATEST_ANALYSIS);
   }
 
   @Test
@@ -182,7 +181,9 @@ public class IssueCreationDateQPChangedTest extends AbstractIssueTest {
     analysis(QProfile.ONE_RULE, SourceCode.CHANGED, ScannerFeature.EXPLICIT_DATE_2);
 
     assertNumberOfIssues(3);
-    assertIssueCreationDates(COMPONENTS_OF_SOURCE_CHANGED, IssueCreationDate.EXPLICIT_DATE_2);
+    assertIssueCreationDate(Component.ForeverAndModified, IssueCreationDate.EXPLICIT_DATE_2);
+    assertIssueCreationDate(Component.ForeverAndUnmodified, IssueCreationDate.EXPLICIT_DATE_1);
+    assertIssueCreationDate(Component.OnlyInChanged, IssueCreationDate.EXPLICIT_DATE_2);
   }
 
   private void analysis(QProfile qProfile, SourceCode sourceCode, ScannerFeature... scm) {
index 648de1a9a304d65431c3b1544d5fe588bb787772..ba9ba095c54ee2c3725e325a29ef3162edfbd2f2 100644 (file)
@@ -63,21 +63,23 @@ public class NewIssuesMeasureTest extends AbstractIssueTest {
     // Execute an analysis in the past with no issue to have a past snapshot
     String past = formatDate(addDays(new Date(), -30));
     ORCHESTRATOR.getServer().associateProjectToQualityProfile("sample", "xoo", "empty");
-    ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperty("sonar.projectDate", past));
+    ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample-missing-some-lines")).setProperty("sonar.projectDate", past));
 
-    // Execute an analysis now with some issues
+    // Execute an analysis now with some issues. Issues on new lines will be new, while the issues on matching lines will be backdated.
     ItUtils.restoreProfile(ORCHESTRATOR, getClass().getResource("/issue/one-issue-per-line-profile.xml"));
     ORCHESTRATOR.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line-profile");
     ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
 
     assertThat(ORCHESTRATOR.getServer().wsClient().issueClient().find(IssueQuery.create()).list()).isNotEmpty();
-    assertThat(getLeakPeriodValue(ORCHESTRATOR, "sample:src/main/xoo/sample/Sample.xoo", "new_violations")).isEqualTo(17);
+    assertThat(getLeakPeriodValue(ORCHESTRATOR, "sample:src/main/xoo/sample/Sample.xoo", "new_violations")).isEqualTo(7);
+    assertThat(ItUtils.getMeasureAsDouble(ORCHESTRATOR, "sample:src/main/xoo/sample/Sample.xoo", "violations")).isEqualTo(17);
+
 
     // second analysis, with exactly the same profile -> no new issues
     ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
 
     assertThat(ORCHESTRATOR.getServer().wsClient().issueClient().find(IssueQuery.create()).list()).isNotEmpty();
-    assertThat(getLeakPeriodValue(ORCHESTRATOR, "sample:src/main/xoo/sample/Sample.xoo", "new_violations")).isEqualTo(17);
+    assertThat(getLeakPeriodValue(ORCHESTRATOR, "sample:src/main/xoo/sample/Sample.xoo", "new_violations")).isEqualTo(7);
   }
 
   @Test
@@ -145,7 +147,9 @@ public class NewIssuesMeasureTest extends AbstractIssueTest {
     ORCHESTRATOR.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "profile2");
     ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")));
 
-    assertThat(getLeakPeriodValue(ORCHESTRATOR, "com.sonarsource.it.samples:multi-modules-sample", "new_violations")).isEqualTo(65);
+    // new issues only in module B. For module B, even with the new rule activated, issues are backdated
+    // 2 issuePerModule + 2 issuePerFile + 24 issuePerLine
+    assertThat(getLeakPeriodValue(ORCHESTRATOR, "com.sonarsource.it.samples:multi-modules-sample", "new_violations")).isEqualTo(28);
   }
 
 }
index 0828af7a7ff0061c4d48569d21e1b1da270f6f4c..83b243db7dd35f3c82f33d10b553c79e1cd38b71 100644 (file)
@@ -263,7 +263,7 @@ public class ProjectFilterTest {
       tuple("10.0-20.0", 0L),
       tuple("20.0-*", 0L));
     checkFacet(response, "new_lines",
-      tuple("*-1000.0", 1L),
+      tuple("*-1000.0", 2L),
       tuple("1000.0-10000.0", 0L),
       tuple("10000.0-100000.0", 0L),
       tuple("100000.0-500000.0", 0L),
index 842778d649688382bb261805c1426364ee556cd3..120a45d418043480db92db2f0a92478592271618 100644 (file)
@@ -54,31 +54,31 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
     setSampleProjectQualityProfile("empty");
     runSampleProjectAnalysis("v1", "sonar.projectDate", DATE_31_DAYS_AGO);
 
-    // Second analysis issues will be created -> new issues and new technical debt
+    // Second analysis issues will be created -> issues are backdated
     setSampleProjectQualityProfile("one-issue-per-line");
     runSampleProjectAnalysis("v1");
-    assertLeakPeriodForComponent("sample", 26, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 13, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
-    // Third analysis, with exactly the same profile -> no new issues but still the same on leak => same values as before
+    // Third analysis, with exactly the same profile -> no new issues => same values as before
     runSampleProjectAnalysis("v1");
-    assertLeakPeriodForComponent("sample", 26, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 13, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
     // Fourth analysis, with new files and modified files -> new issues and new technical debt
     runSampleProjectAnalysis("v2");
-    assertLeakPeriodForComponent("sample", 43, 43);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 17, 17);
+    assertLeakPeriodForComponent("sample", 17, 17);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 4, 4);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 13, 13);
 
     // Fifth analysis, no change -> no new issues but still the same on leak => same values as before
     runSampleProjectAnalysis("v2");
-    assertLeakPeriodForComponent("sample", 43, 43);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 17, 17);
+    assertLeakPeriodForComponent("sample", 17, 17);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 4, 4);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 13, 13);
   }
 
@@ -92,31 +92,31 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
     setSampleProjectQualityProfile("empty");
     runSampleProjectAnalysis("v1", "sonar.projectDate", DATE_31_DAYS_AGO);
 
-    // Second analysis issues will be created -> new issues and new technical debt
+    // Second analysis issues will be created -> new issues that are backdated
     setSampleProjectQualityProfile("one-issue-per-line");
     runSampleProjectAnalysis("v1");
-    assertLeakPeriodForComponent("sample", 26, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 13, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
-    // Third analysis, with exactly the same profile -> no new issues but still the same on leak => same values as before
+    // Third analysis, with exactly the same profile -> no new issues => same values as before
     runSampleProjectAnalysis("v1", "sonar.oneIssuePerLine.effortToFix", "10");
-    assertLeakPeriodForComponent("sample", 260, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 130, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 130, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
     // Fourth analysis, with new files, modified files and increased effort -> new issues and new technical debt
     runSampleProjectAnalysis("v2", "sonar.oneIssuePerLine.effortToFix", "10");
-    assertLeakPeriodForComponent("sample", 430, 43);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 130, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 170, 17);
+    assertLeakPeriodForComponent("sample", 170, 17);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 40, 4);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 130, 13);
 
     // Fifth analysis, effort divided by 2 -> no new issues but still the same on leak => same values as before
     runSampleProjectAnalysis("v2", "sonar.oneIssuePerLine.effortToFix", "5");
-    assertLeakPeriodForComponent("sample", 215, 43);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 65, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 85, 17);
+    assertLeakPeriodForComponent("sample", 85, 17);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 20, 4);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 65, 13);
   }
 
@@ -130,18 +130,18 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
     setSampleProjectQualityProfile("empty");
     runSampleProjectAnalysis("v1", "sonar.projectDate", DATE_31_DAYS_AGO);
 
-    // Second analysis issues will be created -> new issues and new technical debt
+    // Second analysis issues will be created -> no new issues as they are backdated
     setSampleProjectQualityProfile("one-issue-per-line");
     runSampleProjectAnalysis("v1");
-    assertLeakPeriodForComponent("sample", 26, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 13, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
-    // Third analysis, with exactly the same profile -> no new issues but still the same on leak => same values as before
+    // Third analysis, with exactly the same profile -> no new issues => same values as before
     runSampleProjectAnalysis("v1");
-    assertLeakPeriodForComponent("sample", 26, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 13, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
     // Fourth analysis, with new files and modified files -> new issues and new technical debt
     runSampleProjectAnalysis("v2");
@@ -150,7 +150,7 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 4, 4);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 13, 13);
 
-    // Fifth analysis, no change -> no new issues but still the same on leak => same values as before
+    // Fifth analysis, no change -> no new issues and still the same effort => same values as before
     runSampleProjectAnalysis("v2");
     assertLeakPeriodForComponent("sample", 17, 17);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
@@ -160,7 +160,7 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
 
   @Test
   public void since_previous_version_with_effort_change() {
-    tester.settings().setGlobalSettings( "sonar.leak.period", "previous_version");
+    tester.settings().setGlobalSettings("sonar.leak.period", "previous_version");
     restoreQualityProfile("one-issue-per-line");
     provisionSampleProject();
 
@@ -168,18 +168,18 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
     setSampleProjectQualityProfile("empty");
     runSampleProjectAnalysis("v1", "sonar.projectDate", DATE_31_DAYS_AGO);
 
-    // Second analysis issues will be created -> new issues and new technical debt
+    // Second analysis issues will be created -> isues are backdated
     setSampleProjectQualityProfile("one-issue-per-line");
     runSampleProjectAnalysis("v1");
-    assertLeakPeriodForComponent("sample", 26, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 13, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 13, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
-    // Third analysis, with exactly the same profile -> no new issues but still the same on leak => same values as before
+    // Third analysis, with exactly the same profile -> no new issues => same values as before
     runSampleProjectAnalysis("v1", "sonar.oneIssuePerLine.effortToFix", "10");
-    assertLeakPeriodForComponent("sample", 260, 26);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 130, 13);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 130, 13);
+    assertLeakPeriodForComponent("sample", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 0, 0);
 
     // Fourth analysis, with new files, modified files and increased effort -> new issues and new technical debt
     runSampleProjectAnalysis("v2", "sonar.oneIssuePerLine.effortToFix", "10");
@@ -188,12 +188,12 @@ public class TechnicalDebtAndIssueNewMeasuresTest {
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 40, 4);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 130, 13);
 
-    // Fifth analysis, no change -> no new issues but still the same on leak => same values as before
-    runSampleProjectAnalysis("v2", "sonar.oneIssuePerLine.effortToFix", "10");
-    assertLeakPeriodForComponent("sample", 170, 17);
+    // Fifth analysis, no change -> no new issues but different effort => update debt values
+    runSampleProjectAnalysis("v2", "sonar.oneIssuePerLine.effortToFix", "5");
+    assertLeakPeriodForComponent("sample", 85, 17);
     assertLeakPeriodForComponent("sample:src/main/xoo/sample/UnchangedClass.xoo", 0, 0);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 40, 4);
-    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 130, 13);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassToModify.xoo", 20, 4);
+    assertLeakPeriodForComponent("sample:src/main/xoo/sample/ClassAdded.xoo", 65, 13);
   }
 
   private void assertLeakPeriodForComponent(String componentKey, int expectedDebt, int expectedIssues) {
index 6bdd33eaa1507712322b0cc42693cdf72e30bece..cf0363367898d8d34f6d55765c23f1c200bb0dbc 100644 (file)
@@ -87,10 +87,13 @@ public class ScmTest {
     assertThat(buildResult.getLogs()).doesNotContain("1 files to be analyzed");
     assertThat(buildResult.getLogs()).doesNotContain("1/1 files analyzed");
 
-    // Now if SCM is explicitely disabled it should clear SCM data on server side
+    // Now if SCM is explicitely disabled it should clear SCM author and revision
     buildResult = orchestrator.executeBuild(build.setProperty("sonar.scm.disabled", "true"));
 
-    assertThat(getScmData("sample-scm:src/main/xoo/sample/Sample.xoo")).isEmpty();
+    assertThat(getScmData("sample-scm:src/main/xoo/sample/Sample.xoo"))
+    .containsExactly(
+      MapEntry.entry(1, new LineData("", "2013-01-04T00:00:00+0000", "")),
+      MapEntry.entry(8, new LineData("", "2014-01-04T00:00:00+0000", "")));
 
     assertThat(buildResult.getLogs()).doesNotContain("1 files to be analyzed");
     assertThat(buildResult.getLogs()).doesNotContain("1/1 files analyzed");
index 0437a4899ea7b66913d5669b9cceced4f7c28038..b53fbcd63001dd2d1864b0198c3be2c3f494ee5e 100644 (file)
@@ -24,6 +24,8 @@ import com.sonar.orchestrator.build.SonarScanner;
 import java.io.File;
 import java.io.IOException;
 import java.text.ParseException;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
 import java.util.Date;
 import java.util.Map;
 import org.junit.ClassRule;
@@ -65,11 +67,12 @@ public class ScmThenNoScmTest {
 
     orchestrator.executeBuild(scanner);
 
+    Date commitDate = new Date(OffsetDateTime.of(2018, 1, 17, 10, 35, 23, 0, ZoneOffset.ofHours(1)).toInstant().toEpochMilli());
     Map<Integer, LineData> scmData = ws.getScmData("sample-with-then-without-scm:src/main/xoo/sample/Sample.xoo");
     assertThat(scmData.size()).isEqualTo(1);
     assertThat(scmData.get(1).revision).isEqualTo("036fcddbf771b54d7c5f7c8125a493d7d03a9d9d");
     assertThat(scmData.get(1).author).isEqualTo("guillaume.jambet@sonarsource.com");
-    assertThat(scmData.get(1).date).isEqualToIgnoringMillis("2018-01-17T10:35:23");
+    assertThat(scmData.get(1).date).isEqualToIgnoringMillis(commitDate);
 
     // Drop SCM
     deleteDirectory(new File(source, ".git"));
@@ -82,7 +85,7 @@ public class ScmThenNoScmTest {
     assertThat(scmData.size()).isEqualTo(1);
     assertThat(scmData.get(1).revision).isEmpty();
     assertThat(scmData.get(1).author).isEmpty();
-    assertThat(scmData.get(1).date).isEqualToIgnoringMillis("2018-01-17T10:35:23");
+    assertThat(scmData.get(1).date).isEqualToIgnoringMillis(commitDate);
 
   }
 
@@ -98,12 +101,12 @@ public class ScmThenNoScmTest {
       .setProperty("sonar.scm.disabled", "false");
 
     orchestrator.executeBuild(scanner);
-
+    Date commitDate = new Date(OffsetDateTime.of(2018, 1, 17, 10, 35, 23, 0, ZoneOffset.ofHours(1)).toInstant().toEpochMilli());
     Map<Integer, LineData> scmData = ws.getScmData("sample-with-then-without-scm:src/main/xoo/sample/Sample.xoo");
     assertThat(scmData.size()).isEqualTo(1);
     assertThat(scmData.get(1).revision).isEqualTo("036fcddbf771b54d7c5f7c8125a493d7d03a9d9d");
     assertThat(scmData.get(1).author).isEqualTo("guillaume.jambet@sonarsource.com");
-    assertThat(scmData.get(1).date).isEqualToIgnoringMillis("2018-01-17T10:35:23");
+    assertThat(scmData.get(1).date).isEqualToIgnoringMillis(commitDate);
 
     // Drop SCM
     deleteDirectory(new File(source, ".git"));
@@ -120,7 +123,7 @@ public class ScmThenNoScmTest {
     scmData = ws.getScmData("sample-with-then-without-scm:src/main/xoo/sample/Sample.xoo");
     assertThat(scmData.get(1).revision).isEmpty();
     assertThat(scmData.get(1).author).isEmpty();
-    assertThat(scmData.get(1).date).isEqualToIgnoringMillis("2018-01-17T10:35:23");
+    assertThat(scmData.get(1).date).isEqualToIgnoringMillis(commitDate);
 
     assertThat(scmData.get(5).revision).isEmpty();
     assertThat(scmData.get(5).author).isEmpty();
index e658a52d90c2463c3fcf54ea8db8b4de10b0a248..fbcb1885bf92d67afb14feb3ea5508fb9ab7b7ef 100644 (file)
@@ -36,14 +36,13 @@ import static util.ItUtils.xooPlugin;
 })
 public class SourceSuite {
 
-
   @ClassRule
   public static final Orchestrator ORCHESTRATOR = Orchestrator
     .builderEnv()
     .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
-    .setOrchestratorProperty("sonar-scm-git-plugin-version", "1.3.0.869")
+    .setOrchestratorProperty("scmgitVersion", "LATEST_RELEASE")
     .addPlugin(xooPlugin())
-    .addMavenPlugin("org.sonarsource.scm.git", "sonar-scm-git-plugin", "sonar-scm-git-plugin-version")
+    .addPlugin("scmgit")
     .build();
 
 }
index b4ec83087223ec4efc343d66792ee044efbbef1b..dc6e9a5799158d675f181daa56e0bc45dbdc3518 100644 (file)
  */
 package org.sonarqube.tests.test;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.stream.JsonReader;
 import com.sonar.orchestrator.Orchestrator;
 import com.sonar.orchestrator.build.SonarScanner;
 import java.io.File;
@@ -33,6 +38,7 @@ import org.junit.Test;
 import org.skyscreamer.jsonassert.JSONAssert;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsClient;
 import org.sonarqube.ws.client.WsRequest;
 
 import static com.codeborne.selenide.Condition.text;
@@ -78,12 +84,21 @@ public class CoverageTest {
 
     verifyComputeEngineTempDirIsEmpty();
   }
-
+  
   private String cleanupScmAndDuplication(String coverage) {
-    coverage = StringUtils.remove(coverage, ",\"scmAuthor\":\"\"");
-    coverage = StringUtils.remove(coverage, ",\"scmRevision\":\"\"");
-    coverage = StringUtils.remove(coverage, ",\"duplicated\":false");
-    return coverage;
+    JsonObject root = new JsonParser().parse(coverage).getAsJsonObject();
+    JsonArray sources = root.getAsJsonArray("sources");
+    
+    for(JsonElement e : sources) {
+      JsonObject line = e.getAsJsonObject();
+      line.remove("scmDate");
+      line.remove("scmAuthor");
+      line.remove("scmRevision");
+      line.remove("duplicated");
+    }
+    
+    
+    return root.toString();
   }
 
   @Test