use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method use_provided_timezone_to_parse_createdAfter.
@Test
public void use_provided_timezone_to_parse_createdAfter() {
SearchRequest request = new SearchRequest().setCreatedAfter("2020-04-16").setTimeZone("Europe/Volgograd");
IssueQuery query = underTest.create(request);
assertThat(query.createdAfter().date()).isEqualTo(parseDateTime("2020-04-16T00:00:00+0400"));
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method create_from_parameters.
@Test
public void create_from_parameters() {
String ruleAdHocName = "New Name";
UserDto user = db.users().insertUser(u -> u.setLogin("joanna"));
ComponentDto project = db.components().insertPrivateProject();
ComponentDto module = db.components().insertComponent(newModuleDto(project));
ComponentDto file = db.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule1 = ruleDbTester.insert();
RuleDefinitionDto rule2 = ruleDbTester.insert();
ruleDbTester.insertOrUpdateMetadata(rule1, m -> m.setAdHocName(ruleAdHocName));
ruleDbTester.insertOrUpdateMetadata(rule2, m -> m.setAdHocName(ruleAdHocName));
newRule(RuleKey.of("findbugs", "NullReference"));
SearchRequest request = new SearchRequest().setIssues(asList("anIssueKey")).setSeverities(asList("MAJOR", "MINOR")).setStatuses(asList("CLOSED")).setResolutions(asList("FALSE-POSITIVE")).setResolved(true).setProjects(asList(project.getDbKey())).setDirectories(asList("aDirPath")).setFiles(asList(file.uuid())).setAssigneesUuid(asList(user.getUuid())).setScopes(asList("MAIN", "TEST")).setLanguages(asList("xoo")).setTags(asList("tag1", "tag2")).setAssigned(true).setCreatedAfter("2013-04-16T09:08:24+0200").setCreatedBefore("2013-04-17T09:08:24+0200").setRules(asList(rule1.getKey().toString(), rule2.getKey().toString())).setSort("CREATION_DATE").setAsc(true);
IssueQuery query = underTest.create(request);
assertThat(query.issueKeys()).containsOnly("anIssueKey");
assertThat(query.severities()).containsOnly("MAJOR", "MINOR");
assertThat(query.statuses()).containsOnly("CLOSED");
assertThat(query.resolutions()).containsOnly("FALSE-POSITIVE");
assertThat(query.resolved()).isTrue();
assertThat(query.projectUuids()).containsOnly(project.uuid());
assertThat(query.files()).containsOnly(file.uuid());
assertThat(query.assignees()).containsOnly(user.getUuid());
assertThat(query.scopes()).containsOnly("TEST", "MAIN");
assertThat(query.languages()).containsOnly("xoo");
assertThat(query.tags()).containsOnly("tag1", "tag2");
assertThat(query.onComponentOnly()).isFalse();
assertThat(query.assigned()).isTrue();
assertThat(query.rules()).hasSize(2);
assertThat(query.ruleUuids()).hasSize(2);
assertThat(query.directories()).containsOnly("aDirPath");
assertThat(query.createdAfter().date()).isEqualTo(parseDateTime("2013-04-16T09:08:24+0200"));
assertThat(query.createdAfter().inclusive()).isTrue();
assertThat(query.createdBefore()).isEqualTo(parseDateTime("2013-04-17T09:08:24+0200"));
assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_CREATION_DATE);
assertThat(query.asc()).isTrue();
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method return_empty_results_if_not_allowed_to_search_for_subview.
@Test
public void return_empty_results_if_not_allowed_to_search_for_subview() {
ComponentDto view = db.components().insertPrivatePortfolio();
ComponentDto subView = db.components().insertComponent(newSubPortfolio(view));
SearchRequest request = new SearchRequest().setComponentUuids(singletonList(subView.uuid()));
IssueQuery query = underTest.create(request);
assertThat(query.viewUuids()).containsOnly("<UNKNOWN>");
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method search_file_issue_from_branch.
@Test
public void search_file_issue_from_branch() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project);
ComponentDto file = db.components().insertComponent(newFileDto(branch));
assertThat(underTest.create(new SearchRequest().setComponents(singletonList(file.getKey())).setBranch(branch.getBranch()))).extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.componentUuids()), IssueQuery::isMainBranch).containsOnly(branch.uuid(), singletonList(file.uuid()), false);
assertThat(underTest.create(new SearchRequest().setComponents(singletonList(branch.getKey())).setFiles(singletonList(file.path())).setBranch(branch.getBranch()))).extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.files()), IssueQuery::isMainBranch).containsOnly(branch.uuid(), singletonList(file.path()), false);
assertThat(underTest.create(new SearchRequest().setProjects(singletonList(branch.getKey())).setFiles(singletonList(file.path())).setBranch(branch.getBranch()))).extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.files()), IssueQuery::isMainBranch).containsOnly(branch.uuid(), singletonList(file.path()), false);
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method param_componentUuids_enables_search_by_file.
@Test
public void param_componentUuids_enables_search_by_file() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
SearchRequest request = new SearchRequest().setComponentUuids(asList(file.uuid()));
IssueQuery query = underTest.create(request);
assertThat(query.componentUuids()).containsExactly(file.uuid());
}
Aggregations