Search in sources :

Example 26 with RuleDto

use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.

the class IssueServiceMediumTest method list_tags.

@Test
public void list_tags() {
    RuleDto rule = newRule();
    ComponentDto project = newProject();
    ComponentDto file = newFile(project);
    saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention", "java8", "bug")));
    saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention", "bug")));
    saveIssue(IssueTesting.newDto(rule, file, project));
    saveIssue(IssueTesting.newDto(rule, file, project).setTags(ImmutableSet.of("convention")));
    assertThat(service.listTags(null, 5)).containsOnly("convention", "java8", "bug", /* from issues */
    "systag1", "systag2");
    assertThat(service.listTags(null, 2)).containsOnly("bug", "convention");
    assertThat(service.listTags("vent", 5)).containsOnly("convention");
    assertThat(service.listTags("sys", 5)).containsOnly("systag1", "systag2");
    assertThat(service.listTags(null, 1)).containsOnly("bug");
    assertThat(service.listTags(null, Integer.MAX_VALUE)).containsOnly("convention", "java8", "bug", "systag1", "systag2", "tag1", "tag2");
    assertThat(service.listTags("invalidRegexp[", 5)).isEmpty();
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 27 with RuleDto

use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.

the class TransitionServiceTest method newIssue.

private IssueDto newIssue() {
    RuleDto rule = newRuleDto().setId(10);
    ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto());
    ComponentDto file = (newFileDto(project));
    return newDto(rule, file, project);
}
Also used : RuleTesting.newRuleDto(org.sonar.db.rule.RuleTesting.newRuleDto) RuleDto(org.sonar.db.rule.RuleDto) ComponentDto(org.sonar.db.component.ComponentDto)

Example 28 with RuleDto

use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.

the class SearchActionComponentsMediumTest method search_by_developer.

@Test
public void search_by_developer() throws Exception {
    ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
    setDefaultProjectPermission(project);
    ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
    ComponentDto developer = insertComponent(ComponentTesting.newDeveloper(otherOrganization1, "Anakin Skywalker"));
    db.authorDao().insertAuthor(session, "vader", developer.getId());
    db.authorDao().insertAuthor(session, "anakin@skywalker.name", developer.getId());
    RuleDto newRule = newRule();
    IssueDto issue1 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("vader").setKee("2bd4eac2-b650-4037-80bc-7b112bd4eac2");
    IssueDto issue2 = IssueTesting.newDto(newRule, file, project).setAuthorLogin("anakin@skywalker.name").setKee("82fd47d4-b650-4037-80bc-7b1182fd47d4");
    db.issueDao().insert(session, issue1, issue2);
    session.commit();
    indexIssues();
    wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, developer.uuid()).execute().assertJson(this.getClass(), "search_by_developer.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 29 with RuleDto

use of org.sonar.db.rule.RuleDto 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 30 with RuleDto

use of org.sonar.db.rule.RuleDto 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)

Aggregations

RuleDto (org.sonar.db.rule.RuleDto)197 Test (org.junit.Test)140 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)80 ComponentDto (org.sonar.db.component.ComponentDto)47 WsTester (org.sonar.server.ws.WsTester)38 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)29 RuleParamDto (org.sonar.db.rule.RuleParamDto)29 IssueDto (org.sonar.db.issue.IssueDto)28 RuleKey (org.sonar.api.rule.RuleKey)24 SearchOptions (org.sonar.server.es.SearchOptions)16 RuleQuery (org.sonar.server.rule.index.RuleQuery)16 BadRequestException (org.sonar.server.exceptions.BadRequestException)15 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)14 ActiveRuleParamDto (org.sonar.db.qualityprofile.ActiveRuleParamDto)12 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)10 Date (java.util.Date)9 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)8 QualityProfileDao (org.sonar.db.qualityprofile.QualityProfileDao)8 ActiveRuleDao (org.sonar.db.qualityprofile.ActiveRuleDao)7 ArrayList (java.util.ArrayList)6