Search in sources :

Example 26 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method display_file_facet.

@Test
public void display_file_facet() throws Exception {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1"));
    setDefaultProjectPermission(project);
    ComponentDto file1 = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
    ComponentDto file2 = insertComponent(newFileDto(project, null, "F2").setKey("FK2"));
    ComponentDto file3 = insertComponent(newFileDto(project, null, "F3").setKey("FK3"));
    RuleDto newRule = newRule();
    IssueDto issue1 = IssueTesting.newDto(newRule, file1, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
    IssueDto issue2 = IssueTesting.newDto(newRule, file2, project).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
    db.issueDao().insert(session, issue1, issue2);
    session.commit();
    indexIssues();
    wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, project.uuid()).setParam(IssuesWsParameters.PARAM_FILE_UUIDS, file1.uuid() + "," + file3.uuid()).setParam(WebService.Param.FACETS, "fileUuids").execute().assertJson(this.getClass(), "display_file_facet.json");
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 27 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method search_since_leak_period_on_project.

@Test
public void search_since_leak_period_on_project() throws Exception {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P1").setKey("PK1"));
    setDefaultProjectPermission(project);
    ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
    db.snapshotDao().insert(session, newAnalysis(project).setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime()));
    RuleDto rule = newRule();
    IssueDto issueAfterLeak = IssueTesting.newDto(rule, file, project).setKee(UUID_EXAMPLE_01).setIssueCreationDate(parseDateTime("2015-09-04T00:00:00+0100")).setIssueUpdateDate(parseDateTime("2015-10-04T00:00:00+0100"));
    IssueDto issueBeforeLeak = IssueTesting.newDto(rule, file, project).setKee(UUID_EXAMPLE_02).setIssueCreationDate(parseDateTime("2014-09-04T00:00:00+0100")).setIssueUpdateDate(parseDateTime("2015-10-04T00:00:00+0100"));
    db.issueDao().insert(session, issueAfterLeak, issueBeforeLeak);
    session.commit();
    indexIssues();
    wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, project.uuid()).setParam(IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD, "true").execute().assertJson(this.getClass(), "search_since_leak_period.json");
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 28 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method do_not_return_module_key_on_single_module_projects.

@Test
public void do_not_return_module_key_on_single_module_projects() throws IOException {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
    setDefaultProjectPermission(project);
    ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
    ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
    RuleDto newRule = newRule();
    IssueDto issueInModule = IssueTesting.newDto(newRule, file, project).setKee("ISSUE_IN_MODULE");
    IssueDto issueInRootModule = IssueTesting.newDto(newRule, project, project).setKee("ISSUE_IN_ROOT_MODULE");
    db.issueDao().insert(session, issueInModule, issueInRootModule);
    session.commit();
    indexIssues();
    WsActionTester actionTester = new WsActionTester(tester.get(SearchAction.class));
    TestResponse response = actionTester.newRequest().setMediaType(MediaTypes.PROTOBUF).execute();
    SearchWsResponse searchResponse = SearchWsResponse.parseFrom(response.getInputStream());
    assertThat(searchResponse.getIssuesCount()).isEqualTo(2);
    for (Issues.Issue issue : searchResponse.getIssuesList()) {
        assertThat(issue.getProject()).isEqualTo("PK1");
        if (issue.getKey().equals("ISSUE_IN_MODULE")) {
            assertThat(issue.getSubProject()).isEqualTo("MK1");
        } else if (issue.getKey().equals("ISSUE_IN_ROOT_MODULE")) {
            assertThat(issue.hasSubProject()).isFalse();
        }
    }
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) TestResponse(org.sonar.server.ws.TestResponse) Issues(org.sonarqube.ws.Issues) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse) WsActionTester(org.sonar.server.ws.WsActionTester) Test(org.junit.Test)

Example 29 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method project_facet_is_sticky.

@Test
public void project_facet_is_sticky() throws Exception {
    ComponentDto project1 = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
    ComponentDto project2 = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P2").setKey("PK2"));
    ComponentDto project3 = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P3").setKey("PK3"));
    setDefaultProjectPermission(project1);
    setDefaultProjectPermission(project2);
    setDefaultProjectPermission(project3);
    ComponentDto file1 = insertComponent(newFileDto(project1, null, "F1").setKey("FK1"));
    ComponentDto file2 = insertComponent(newFileDto(project2, null, "F2").setKey("FK2"));
    ComponentDto file3 = insertComponent(newFileDto(project3, null, "F3").setKey("FK3"));
    RuleDto rule = newRule();
    IssueDto issue1 = IssueTesting.newDto(rule, file1, project1).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
    IssueDto issue2 = IssueTesting.newDto(rule, file2, project2).setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4");
    IssueDto issue3 = IssueTesting.newDto(rule, file3, project3).setKee("7b1182fd-b650-4037-80bc-82fd47d4eac2");
    db.issueDao().insert(session, issue1, issue2, issue3);
    session.commit();
    indexIssues();
    wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_PROJECT_UUIDS, project1.uuid()).setParam(WebService.Param.FACETS, "projectUuids").execute().assertJson(this.getClass(), "display_sticky_project_facet.json");
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 30 with IssueDto

use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method search_since_leak_period_on_file_in_module_project.

@Test
public void search_since_leak_period_on_file_in_module_project() throws Exception {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
    setDefaultProjectPermission(project);
    ComponentDto module = insertComponent(newModuleDto(project));
    ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
    db.snapshotDao().insert(session, newAnalysis(project).setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime()));
    RuleDto rule = newRule();
    IssueDto issueAfterLeak = IssueTesting.newDto(rule, file, project).setKee(UUID_EXAMPLE_01).setIssueCreationDate(parseDateTime("2015-09-04T00:00:00+0100")).setIssueUpdateDate(parseDateTime("2015-10-04T00:00:00+0100"));
    IssueDto issueBeforeLeak = IssueTesting.newDto(rule, file, project).setKee(UUID_EXAMPLE_02).setIssueCreationDate(parseDateTime("2014-09-04T00:00:00+0100")).setIssueUpdateDate(parseDateTime("2015-10-04T00:00:00+0100"));
    db.issueDao().insert(session, issueAfterLeak, issueBeforeLeak);
    session.commit();
    indexIssues();
    wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, project.uuid()).setParam(IssuesWsParameters.PARAM_FILE_UUIDS, file.uuid()).setParam(IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD, "true").execute().assertJson(this.getClass(), "search_since_leak_period.json");
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Aggregations

IssueDto (org.sonar.db.issue.IssueDto)134 Test (org.junit.Test)117 ComponentDto (org.sonar.db.component.ComponentDto)48 RuleDto (org.sonar.db.rule.RuleDto)28 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)19 UserDto (org.sonar.db.user.UserDto)18 WsTester (org.sonar.server.ws.WsTester)18 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)15 FieldDiffs (org.sonar.core.issue.FieldDiffs)14 BulkChangeWsResponse (org.sonarqube.ws.Issues.BulkChangeWsResponse)14 ChangelogWsResponse (org.sonarqube.ws.Issues.ChangelogWsResponse)12 TestResponse (org.sonar.server.ws.TestResponse)9 Request (org.sonar.api.server.ws.Request)8 Response (org.sonar.api.server.ws.Response)8 DefaultIssue (org.sonar.core.issue.DefaultIssue)8 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)8 TestRequest (org.sonar.server.ws.TestRequest)8 Date (java.util.Date)6 DbSession (org.sonar.db.DbSession)5 IssueDao (org.sonar.db.issue.IssueDao)4