/** SONAR-4310 */
  @Test
  public void track_existing_unchanged_issues_on_multi_modules() throws Exception {
    // The custom rule on module is enabled
    ORCHESTRATOR
        .getServer()
        .provisionProject(
            "com.sonarsource.it.samples:multi-modules-sample",
            "com.sonarsource.it.samples:multi-modules-sample");
    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(
            "com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-module");
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");

    // One issue by module are created
    List<Issue> issues = searchIssues(new SearchWsRequest()).getIssuesList();
    assertThat(issues).hasSize(4);

    // Re analysis of the same project
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample");

    // No new issue should be created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(issues.size());

    // Issues on modules should stay open and be the same from the first analysis
    for (Issue issue : issues) {
      Issue reloadIssue = getIssueByKey(issue.getKey());
      assertThat(reloadIssue.getStatus()).isEqualTo("OPEN");
      assertThat(reloadIssue.hasResolution()).isFalse();
      assertThat(reloadIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
      assertThat(reloadIssue.getUpdateDate()).isEqualTo(issue.getUpdateDate());
    }
  }
  /** SONAR-4310 */
  @Test
  public void track_existing_unchanged_issues_on_module() throws Exception {
    // The custom rule on module is enabled

    ORCHESTRATOR
        .getServer()
        .associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "one-issue-per-module");
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");

    // Only one issue is created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(1);
    Issue issue = getRandomIssue();

    // Re analysis of the same project
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");

    // No new issue should be created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(1);

    // The issue on module should stay open and be the same from the first analysis
    Issue reloadIssue = getIssueByKey(issue.getKey());
    assertThat(reloadIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
    assertThat(reloadIssue.getStatus()).isEqualTo("OPEN");
    assertThat(reloadIssue.hasResolution()).isFalse();
  }