Skip to content

Commit

Permalink
SONAR-8574 Replace usage of api/resources/index by api/measures/compo…
Browse files Browse the repository at this point in the history
…nent in ITs
  • Loading branch information
julienlancelot committed Jan 18, 2017
1 parent 013a9aa commit 5690b11
Show file tree
Hide file tree
Showing 41 changed files with 805 additions and 844 deletions.
35 changes: 15 additions & 20 deletions it/it-tests/src/test/java/it/analysis/IssuesModeTest.java
Expand Up @@ -56,13 +56,13 @@
import org.sonar.wsclient.issue.IssueClient; import org.sonar.wsclient.issue.IssueClient;
import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.issue.IssueQuery;
import org.sonar.wsclient.issue.Issues; import org.sonar.wsclient.issue.Issues;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import org.sonar.wsclient.user.UserParameters; import org.sonar.wsclient.user.UserParameters;
import util.ItUtils; import util.ItUtils;


import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static util.ItUtils.getComponent;
import static util.ItUtils.getMeasureAsDouble;


public class IssuesModeTest { public class IssuesModeTest {


Expand Down Expand Up @@ -206,16 +206,16 @@ public void only_scan_changed_files_on_change() throws IOException {
assertThat(result.getLogs()).doesNotContain("'One Issue Per Line' skipped because there is no related file in current project"); assertThat(result.getLogs()).doesNotContain("'One Issue Per Line' skipped because there is no related file in current project");
ItUtils.assertIssuesInJsonReport(result, 3, 0, 17); ItUtils.assertIssuesInJsonReport(result, 3, 0, 17);
} }

// SONAR-8518 // SONAR-8518
@Test @Test
public void shoud_support_sonar_profile_prop() throws IOException { public void shoud_support_sonar_profile_prop() throws IOException {
restoreProfile("one-issue-per-line.xml"); restoreProfile("one-issue-per-line.xml");
restoreProfile("empty.xml"); restoreProfile("empty.xml");
orchestrator.getServer().provisionProject("sample", "xoo-sample"); orchestrator.getServer().provisionProject("sample", "xoo-sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "empty"); orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "empty");

SonarScanner runner = configureRunner("shared/xoo-sample", SonarScanner runner = configureRunner("shared/xoo-sample",
"sonar.verbose", "true", "sonar.verbose", "true",
"sonar.analysis.mode", "issues", "sonar.analysis.mode", "issues",
"sonar.profile", "one-issue-per-line"); "sonar.profile", "one-issue-per-line");
Expand All @@ -231,14 +231,13 @@ public void test_issues_mode_on_project_with_space_in_filename() throws IOExcept
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "with-many-rules"); orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "with-many-rules");


SonarScanner runner = configureRunner("analysis/xoo-sample-with-spaces/v2"); SonarScanner runner = configureRunner("analysis/xoo-sample-with-spaces/v2");
BuildResult result = orchestrator.executeBuild(runner); orchestrator.executeBuild(runner);
assertThat(getResource("sample:my sources/main/xoo/sample/My Sample.xoo")).isNotNull(); assertThat(getComponent(orchestrator, "sample:my sources/main/xoo/sample/My Sample.xoo")).isNotNull();


runner = configureRunnerIssues("analysis/xoo-sample-with-spaces/v2", null); runner = configureRunnerIssues("analysis/xoo-sample-with-spaces/v2", null);
result = orchestrator.executeBuild(runner); BuildResult result = orchestrator.executeBuild(runner);
// Analysis is not persisted in database // Analysis is not persisted in database
Resource project = getResource("com.sonarsource.it.samples:simple-sample"); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:simple-sample")).isNull();
assertThat(project).isNull();
assertThat(result.getLogs()).contains("Issues"); assertThat(result.getLogs()).contains("Issues");
assertThat(result.getLogs()).contains("ANALYSIS SUCCESSFUL"); assertThat(result.getLogs()).contains("ANALYSIS SUCCESSFUL");
} }
Expand All @@ -251,19 +250,19 @@ public void should_not_fail_on_resources_that_have_existed_before() throws IOExc


// First real scan with source // First real scan with source
SonarScanner runner = configureRunner("shared/xoo-history-v2"); SonarScanner runner = configureRunner("shared/xoo-history-v2");
BuildResult result = orchestrator.executeBuild(runner); orchestrator.executeBuild(runner);
assertThat(getResource("sample:src/main/xoo/sample/ClassAdded.xoo")).isNotNull(); assertThat(getComponent(orchestrator, "sample:src/main/xoo/sample/ClassAdded.xoo")).isNotNull();


// Second scan should remove ClassAdded.xoo // Second scan should remove ClassAdded.xoo
runner = configureRunner("shared/xoo-history-v1"); runner = configureRunner("shared/xoo-history-v1");
result = orchestrator.executeBuild(runner); orchestrator.executeBuild(runner);
assertThat(getResource("sample:src/main/xoo/sample/ClassAdded.xoo")).isNull(); assertThat(getMeasureAsDouble(orchestrator, "sample:src/main/xoo/sample/ClassAdded.xoo", "ncloc")).isNull();


// Re-add ClassAdded.xoo in local workspace // Re-add ClassAdded.xoo in local workspace
runner = configureRunnerIssues("shared/xoo-history-v2", null); runner = configureRunnerIssues("shared/xoo-history-v2", null);
result = orchestrator.executeBuild(runner); BuildResult result = orchestrator.executeBuild(runner);


assertThat(getResource("sample:src/main/xoo/sample/ClassAdded.xoo")).isNull(); assertThat(getMeasureAsDouble(orchestrator, "sample:src/main/xoo/sample/ClassAdded.xoo", "ncloc")).isNull();
assertThat(result.getLogs()).contains("Issues"); assertThat(result.getLogs()).contains("Issues");
assertThat(result.getLogs()).contains("ANALYSIS SUCCESSFUL"); assertThat(result.getLogs()).contains("ANALYSIS SUCCESSFUL");
} }
Expand Down Expand Up @@ -433,10 +432,6 @@ private void restoreProfile(String fileName) {
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/IssuesModeTest/" + fileName)); orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/IssuesModeTest/" + fileName));
} }


private Resource getResource(String key) {
return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(key, "lines"));
}

private SonarScanner configureRunnerIssues(String projectDir, @Nullable File homeDir, String... props) throws IOException { private SonarScanner configureRunnerIssues(String projectDir, @Nullable File homeDir, String... props) throws IOException {
SonarScanner scanner = SonarScanner.create(ItUtils.projectDir(projectDir), SonarScanner scanner = SonarScanner.create(ItUtils.projectDir(projectDir),
"sonar.working.directory", temp.newFolder().getAbsolutePath(), "sonar.working.directory", temp.newFolder().getAbsolutePath(),
Expand Down
24 changes: 9 additions & 15 deletions it/it-tests/src/test/java/it/analysis/MultiLanguageTest.java
Expand Up @@ -24,14 +24,15 @@
import com.sonar.orchestrator.build.SonarScanner; import com.sonar.orchestrator.build.SonarScanner;
import com.sonar.orchestrator.locator.FileLocation; import com.sonar.orchestrator.locator.FileLocation;
import it.Category3Suite; import it.Category3Suite;
import java.util.Map;
import org.junit.After; import org.junit.After;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import util.ItUtils; import util.ItUtils;


import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.getMeasureAsDouble;
import static util.ItUtils.getMeasuresAsDoubleByMetricKey;


public class MultiLanguageTest { public class MultiLanguageTest {


Expand All @@ -55,7 +56,7 @@ public void test_sonar_runner_inspection() {
orchestrator.getServer().provisionProject("multi-language-sample", "multi-language-sample"); orchestrator.getServer().provisionProject("multi-language-sample", "multi-language-sample");


orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo", "one-issue-per-line"); orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo", "one-issue-per-line");
orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample","xoo2", "one-issue-per-line-xoo2"); orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo2", "one-issue-per-line-xoo2");


SonarScanner build = SonarScanner.create().setProjectDir(ItUtils.projectDir("analysis/xoo-multi-languages")); SonarScanner build = SonarScanner.create().setProjectDir(ItUtils.projectDir("analysis/xoo-multi-languages"));
BuildResult result = orchestrator.executeBuild(build); BuildResult result = orchestrator.executeBuild(build);
Expand All @@ -65,18 +66,11 @@ public void test_sonar_runner_inspection() {
assertThat(result.getLogs()).contains("Quality profile for xoo2: one-issue-per-line-xoo2"); assertThat(result.getLogs()).contains("Quality profile for xoo2: one-issue-per-line-xoo2");


// modules // modules
Resource project = getResource("multi-language-sample", "files", "violations"); Map<String, Double> measures = getMeasuresAsDoubleByMetricKey(orchestrator, "multi-language-sample", "files", "violations");
assertThat(project.getMeasureIntValue("files")).isEqualTo(2); assertThat(measures.get("files")).isEqualTo(2);
assertThat(project.getMeasureIntValue("violations")).isEqualTo(26); assertThat(measures.get("violations")).isEqualTo(26);


Resource xooFile = getResource("multi-language-sample:src/sample/Sample.xoo", "violations"); assertThat(getMeasureAsDouble(orchestrator, "multi-language-sample:src/sample/Sample.xoo", "violations")).isEqualTo(13);
assertThat(xooFile.getMeasureIntValue("violations")).isEqualTo(13); assertThat(getMeasureAsDouble(orchestrator, "multi-language-sample:src/sample/Sample.xoo2", "violations")).isEqualTo(13);

Resource xoo2File = getResource("multi-language-sample:src/sample/Sample.xoo2", "violations");
assertThat(xoo2File.getMeasureIntValue("violations")).isEqualTo(13);
}

private Resource getResource(String resourceKey, String... metricKeys) {
return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(resourceKey, metricKeys));
} }
} }
33 changes: 15 additions & 18 deletions it/it-tests/src/test/java/it/analysis/ProjectBuilderTest.java
Expand Up @@ -22,13 +22,14 @@
import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.MavenBuild; import com.sonar.orchestrator.build.MavenBuild;
import it.Category3Suite; import it.Category3Suite;
import java.util.Map;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import util.ItUtils; import util.ItUtils;


import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.getComponent;
import static util.ItUtils.getMeasuresAsDoubleByMetricKey;


/** /**
* Test the extension point org.sonar.api.batch.bootstrap.ProjectBuilder * Test the extension point org.sonar.api.batch.bootstrap.ProjectBuilder
Expand Down Expand Up @@ -56,34 +57,30 @@ public void shouldDefineProjectFromPlugin() {
checkSubProject("project-builder-module-b"); checkSubProject("project-builder-module-b");
checkFile("project-builder-module-a", "src/HelloA.java"); checkFile("project-builder-module-a", "src/HelloA.java");
checkFile("project-builder-module-b", "src/HelloB.java"); checkFile("project-builder-module-b", "src/HelloB.java");
assertThat(getResource("com.sonarsource.it.projects.batch:project-builder-module-b:src/IgnoredFile.java")).isNull(); assertThat(getComponent(orchestrator, "com.sonarsource.it.projects.batch:project-builder-module-b:src/IgnoredFile.java")).isNull();
} }


private void checkProject() { private void checkProject() {
Resource project = getResource("com.sonarsource.it.projects.batch:project-builder");

// name has been changed by plugin // name has been changed by plugin
assertThat(project.getName()).isEqualTo("Name changed by plugin"); assertThat(getComponent(orchestrator, "com.sonarsource.it.projects.batch:project-builder").getName()).isEqualTo("Name changed by plugin");


assertThat(project).isNotNull(); Map<String, Double> measures = getMeasures("com.sonarsource.it.projects.batch:project-builder");
assertThat(project.getMeasureIntValue("files")).isEqualTo(2); assertThat(measures.get("files")).isEqualTo(2);
assertThat(project.getMeasureIntValue("lines")).isGreaterThan(10); assertThat(measures.get("lines")).isGreaterThan(10);
} }


private void checkSubProject(String subProjectKey) { private void checkSubProject(String subProjectKey) {
Resource subProject = getResource("com.sonarsource.it.projects.batch:" + subProjectKey); Map<String, Double> measures = getMeasures("com.sonarsource.it.projects.batch:" + subProjectKey);
assertThat(subProject).isNotNull(); assertThat(measures.get("files")).isEqualTo(1);
assertThat(subProject.getMeasureIntValue("files")).isEqualTo(1); assertThat(measures.get("lines")).isGreaterThan(5);
assertThat(subProject.getMeasureIntValue("lines")).isGreaterThan(5);
} }


private void checkFile(String subProjectKey, String fileKey) { private void checkFile(String subProjectKey, String fileKey) {
Resource file = getResource("com.sonarsource.it.projects.batch:" + subProjectKey + ":" + fileKey); Map<String, Double> measures = getMeasures("com.sonarsource.it.projects.batch:" + subProjectKey + ":" + fileKey);
assertThat(file).isNotNull(); assertThat(measures.get("lines")).isGreaterThan(5);
assertThat(file.getMeasureIntValue("lines")).isGreaterThan(5);
} }


private Resource getResource(String key) { private Map<String, Double> getMeasures(String key) {
return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(key, "lines", "files")); return getMeasuresAsDoubleByMetricKey(orchestrator, key, "lines", "files");
} }
} }
73 changes: 25 additions & 48 deletions it/it-tests/src/test/java/it/analysis/ScannerTest.java
Expand Up @@ -26,7 +26,7 @@
import it.Category3Suite; import it.Category3Suite;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Map;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.junit.Assume; import org.junit.Assume;
import org.junit.Before; import org.junit.Before;
Expand All @@ -36,12 +36,16 @@
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.sonar.wsclient.Sonar; import org.sonarqube.ws.client.component.SearchWsRequest;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import util.ItUtils; import util.ItUtils;


import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.getComponent;
import static util.ItUtils.getComponentNavigation;
import static util.ItUtils.getMeasureAsDouble;
import static util.ItUtils.getMeasuresAsDoubleByMetricKey;
import static util.ItUtils.newAdminWsClient;
import static util.ItUtils.resetSettings; import static util.ItUtils.resetSettings;
import static util.ItUtils.setServerProperty; import static util.ItUtils.setServerProperty;


Expand Down Expand Up @@ -70,23 +74,18 @@ public void should_scan_branch_with_forward_slash() {
scan("shared/xoo-multi-modules-sample"); scan("shared/xoo-multi-modules-sample");
scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x"); scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x");


Sonar sonar = orchestrator.getServer().getWsClient(); assertThat(newAdminWsClient(orchestrator).components().search(new SearchWsRequest().setQualifiers(singletonList("TRK"))).getComponentsList()).hasSize(2);
assertThat(sonar.findAll(new ResourceQuery().setQualifiers("TRK"))).hasSize(2); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:multi-modules-sample").getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample");

assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:multi-modules-sample:branch/0.x").getName())
Resource master = sonar.find(new ResourceQuery("com.sonarsource.it.samples:multi-modules-sample")); .isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample branch/0.x");
assertThat(master.getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample");

Resource branch = sonar.find(new ResourceQuery("com.sonarsource.it.samples:multi-modules-sample:branch/0.x"));
assertThat(branch.getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample branch/0.x");
} }


@Test @Test
public void use_sonar_profile_without_provisioning_project() { public void use_sonar_profile_without_provisioning_project() {
scan("shared/xoo-multi-modules-sample", scan("shared/xoo-multi-modules-sample",
"sonar.profile", "one-issue-per-line", "sonar.profile", "one-issue-per-line",
"sonar.verbose", "true"); "sonar.verbose", "true");
Resource r = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("com.sonarsource.it.samples:multi-modules-sample", "violations")); assertThat(getMeasureAsDouble(orchestrator, "com.sonarsource.it.samples:multi-modules-sample", "violations")).isEqualTo(61);
assertThat(r.getMeasureIntValue("violations")).isEqualTo(61);
} }


// SONAR-4680 // SONAR-4680
Expand Down Expand Up @@ -149,11 +148,10 @@ public void should_support_source_files_with_same_deprecated_key() {
orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.projects.batch:duplicate-source", "xoo", "one-issue-per-line"); orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.projects.batch:duplicate-source", "xoo", "one-issue-per-line");
scan("analysis/duplicate-source"); scan("analysis/duplicate-source");


Sonar sonar = orchestrator.getServer().getAdminWsClient(); Map<String, Double> measures = getMeasuresAsDoubleByMetricKey(orchestrator, "com.sonarsource.it.projects.batch:duplicate-source", "files", "directories");
Resource project = sonar.find(new ResourceQuery("com.sonarsource.it.projects.batch:duplicate-source").setMetrics("files", "directories"));
// 2 main files and 1 test file all with same deprecated key // 2 main files and 1 test file all with same deprecated key
assertThat(project.getMeasureIntValue("files")).isEqualTo(2); assertThat(measures.get("files")).isEqualTo(2);
assertThat(project.getMeasureIntValue("directories")).isEqualTo(2); assertThat(measures.get("directories")).isEqualTo(2);
} }


/** /**
Expand Down Expand Up @@ -224,11 +222,8 @@ public void should_analyze_project_without_name_version() {
} }


private void assertNameAndVersion(String projectKey, String expectedProjectName, String expectedProjectVersion) { private void assertNameAndVersion(String projectKey, String expectedProjectName, String expectedProjectVersion) {
// new WS Client with api/components doesn't return the project version, so use the old one assertThat(getComponent(orchestrator, projectKey).getName()).isEqualTo(expectedProjectName);
Resource resource = orchestrator.getServer().getAdminWsClient().find(new ResourceQuery(projectKey)); assertThat(getComponentNavigation(orchestrator, projectKey).getVersion()).isEqualTo(expectedProjectVersion);
assertThat(resource.getName()).isEqualTo(expectedProjectName);
assertThat(resource.getVersion()).isEqualTo(expectedProjectVersion);

} }


@Test @Test
Expand Down Expand Up @@ -366,9 +361,9 @@ public void file_extensions_are_case_insensitive() throws Exception {
orchestrator.getServer().associateProjectToQualityProfile("case-sensitive-file-extensions", "xoo", "one-issue-per-line"); orchestrator.getServer().associateProjectToQualityProfile("case-sensitive-file-extensions", "xoo", "one-issue-per-line");
scan("analysis/case-sensitive-file-extensions"); scan("analysis/case-sensitive-file-extensions");


Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("case-sensitive-file-extensions", "files", "ncloc")); Map<String, Double> measures = getMeasuresAsDoubleByMetricKey(orchestrator, "case-sensitive-file-extensions", "files", "ncloc");
assertThat(project.getMeasureIntValue("files")).isEqualTo(2); assertThat(measures.get("files")).isEqualTo(2);
assertThat(project.getMeasureIntValue("ncloc")).isEqualTo(5 + 2); assertThat(measures.get("ncloc")).isEqualTo(5 + 2);
} }


/** /**
Expand All @@ -379,8 +374,8 @@ public void custom_module_key() {
orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample"); orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line"); orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
scan("analysis/custom-module-key"); scan("analysis/custom-module-key");
assertThat(getResource("com.sonarsource.it.samples:moduleA")).isNotNull(); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:moduleA")).isNotNull();
assertThat(getResource("com.sonarsource.it.samples:moduleB")).isNotNull(); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:moduleB")).isNotNull();
} }


/** /**
Expand All @@ -392,8 +387,8 @@ public void prevent_same_module_key_in_two_projects() {
orchestrator.getServer().provisionProject("projectAB", "project AB"); orchestrator.getServer().provisionProject("projectAB", "project AB");
orchestrator.getServer().associateProjectToQualityProfile("projectAB", "xoo", "one-issue-per-line"); orchestrator.getServer().associateProjectToQualityProfile("projectAB", "xoo", "one-issue-per-line");
scan("analysis/prevent-common-module/projectAB"); scan("analysis/prevent-common-module/projectAB");
assertThat(getResource("com.sonarsource.it.samples:moduleA")).isNotNull(); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:moduleA")).isNotNull();
assertThat(getResource("com.sonarsource.it.samples:moduleB")).isNotNull(); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:moduleB")).isNotNull();


orchestrator.getServer().provisionProject("projectAC", "project AC"); orchestrator.getServer().provisionProject("projectAC", "project AC");
orchestrator.getServer().associateProjectToQualityProfile("projectAC", "xoo", "one-issue-per-line"); orchestrator.getServer().associateProjectToQualityProfile("projectAC", "xoo", "one-issue-per-line");
Expand All @@ -403,20 +398,6 @@ public void prevent_same_module_key_in_two_projects() {
assertThat(result.getLogs()).contains("Module \"com.sonarsource.it.samples:moduleA\" is already part of project \"projectAB\""); assertThat(result.getLogs()).contains("Module \"com.sonarsource.it.samples:moduleA\" is already part of project \"projectAB\"");
} }


/**
* SONAR-4235
*/
@Test
public void test_project_creation_date() {
long before = new Date().getTime() - 2000l;
orchestrator.getServer().provisionProject("sample", "xoo-sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")));
long after = new Date().getTime() + 2000l;
Resource xooSample = orchestrator.getServer().getWsClient().find(new ResourceQuery().setResourceKeyOrId("sample"));
assertThat(xooSample.getCreationDate().getTime()).isGreaterThan(before).isLessThan(after);
}

/** /**
* SONAR-4334 * SONAR-4334
*/ */
Expand All @@ -438,10 +419,6 @@ public void fail_if_project_date_is_older_than_latest_snapshot() {
assertThat(result.getLogs()).contains("This property may only be used to rebuild the past in a chronological order."); assertThat(result.getLogs()).contains("This property may only be used to rebuild the past in a chronological order.");
} }


private Resource getResource(String key) {
return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(key, "lines"));
}

private BuildResult scan(String projectPath, String... props) { private BuildResult scan(String projectPath, String... props) {
SonarScanner scanner = configureScanner(projectPath, props); SonarScanner scanner = configureScanner(projectPath, props);
return orchestrator.executeBuild(scanner); return orchestrator.executeBuild(scanner);
Expand Down

0 comments on commit 5690b11

Please sign in to comment.