use of org.sonar.db.rule.RuleDto 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();
}
}
}
use of org.sonar.db.rule.RuleDto 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");
}
use of org.sonar.db.rule.RuleDto 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");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method newRule.
private RuleDto newRule() {
RuleDto rule = RuleTesting.newXooX1().setName("Rule name").setDescription("Rule desc").setStatus(RuleStatus.READY);
tester.get(RuleDao.class).insert(session, rule);
session.commit();
return rule;
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method search_by_developer_technical_project.
@Test
public void search_by_developer_technical_project() throws Exception {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(newFileDto(project, null, "F1").setKey("FK1"));
ComponentDto otherProject = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "P2").setKey("PK2"));
setDefaultProjectPermission(otherProject);
ComponentDto otherFile = insertComponent(newFileDto(otherProject, null, "F2").setKey("FK2"));
ComponentDto developer = insertComponent(ComponentTesting.newDeveloper(defaultOrganization, "Anakin Skywalker"));
ComponentDto technicalProject = insertComponent(ComponentTesting.newDevProjectCopy("COPY_P1", project, developer));
insertComponent(ComponentTesting.newDevProjectCopy("COPY_P2", otherProject, developer));
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");
IssueDto issueX = IssueTesting.newDto(newRule, otherFile, otherProject).setAuthorLogin("anakin@skywalker.name").setKee("82fd47d4-b650-4037-7b11-80bc82fd47d4");
db.issueDao().insert(session, issue1, issue2, issueX);
session.commit();
indexIssues();
Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(IssuesWsParameters.PARAM_COMPONENT_UUIDS, technicalProject.uuid()).execute();
result.assertJson(this.getClass(), "search_by_developer.json");
}
Aggregations