Search in sources :

Example 1 with Component

use of org.sonar.wsclient.component.Component in project sonarqube by SonarSource.

the class IssueSearchTest method components_contain_sub_project_id_and_project_id_informations.

@Test
public void components_contain_sub_project_id_and_project_id_informations() {
    String fileKey = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo";
    Issues issues = issueClient().find(IssueQuery.create().components(fileKey));
    assertThat(issues.list()).isNotEmpty();
    Collection<Component> components = issues.components();
    Component project = findComponent(components, "com.sonarsource.it.samples:multi-modules-sample");
    assertThat(project.subProjectId()).isNull();
    assertThat(project.projectId()).isNull();
    Component subModuleA1 = findComponent(components, "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1");
    assertThat(subModuleA1.subProjectId()).isEqualTo(project.id());
    assertThat(subModuleA1.projectId()).isEqualTo(project.id());
    Component file = findComponent(components, fileKey);
    assertThat(file.subProjectId()).isNotNull();
    assertThat(file.projectId()).isNotNull();
    Issue issue = issues.list().get(0);
    assertThat(issues.component(issue)).isNotNull();
    assertThat(issues.component(issue).subProjectId()).isEqualTo(subModuleA1.id());
    assertThat(issues.component(issue).projectId()).isEqualTo(project.id());
}
Also used : Issue(org.sonar.wsclient.issue.Issue) Issues(org.sonar.wsclient.issue.Issues) Component(org.sonar.wsclient.component.Component) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Component (org.sonar.wsclient.component.Component)1 Issue (org.sonar.wsclient.issue.Issue)1 Issues (org.sonar.wsclient.issue.Issues)1