Browse Source

SONAR-10257 Fix ITs

tags/7.5
Duarte Meneses 6 years ago
parent
commit
d7f67c0e56

+ 5
- 0
tests/projects/shared/xoo-sample-missing-some-lines/sonar-project.properties View File

@@ -0,0 +1,5 @@
sonar.projectKey=sample
sonar.projectName=Sample
sonar.projectVersion=1.0-SNAPSHOT
sonar.sources=src/main/xoo
sonar.language=xoo

+ 9
- 0
tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo View File

@@ -0,0 +1,9 @@
package sample;

public class Sample {
public Sample(int i) {
int j = i++;
}
}

+ 9
- 0
tests/projects/shared/xoo-sample-missing-some-lines/src/main/xoo/sample/Sample.xoo.measures View File

@@ -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

+ 6
- 5
tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDateQPChangedTest.java View 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) {

+ 9
- 5
tests/src/test/java/org/sonarqube/tests/issue/NewIssuesMeasureTest.java View 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);
}

}

+ 1
- 1
tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java View 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),

+ 51
- 51
tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtAndIssueNewMeasuresTest.java View 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) {

+ 5
- 2
tests/src/test/java/org/sonarqube/tests/source/ScmTest.java View 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");

+ 8
- 5
tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java View 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();

+ 2
- 3
tests/src/test/java/org/sonarqube/tests/source/SourceSuite.java View 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();

}

+ 20
- 5
tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java View File

@@ -19,6 +19,11 @@
*/
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

Loading…
Cancel
Save