use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method leak_period_start_date_is_exclusive.
@Test
public void leak_period_start_date_is_exclusive() {
long leakPeriodStart = addDays(new Date(), -14).getTime();
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
SnapshotDto analysis = db.components().insertSnapshot(project, s -> s.setPeriodDate(leakPeriodStart));
SearchRequest request = new SearchRequest().setComponentUuids(Collections.singletonList(file.uuid())).setOnComponentOnly(true).setSinceLeakPeriod(true);
IssueQuery query = underTest.create(request);
assertThat(query.componentUuids()).containsOnly(file.uuid());
assertThat(query.createdAfter().date()).isEqualTo(new Date(leakPeriodStart));
assertThat(query.createdAfter().inclusive()).isFalse();
assertThat(query.newCodeOnReference()).isNull();
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method param_componentUuids_enables_search_in_directory_tree.
@Test
public void param_componentUuids_enables_search_in_directory_tree() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto dir = db.components().insertComponent(newDirectory(project, "src/main/java/foo"));
SearchRequest request = new SearchRequest().setComponentUuids(asList(dir.uuid()));
IssueQuery query = underTest.create(request);
assertThat(query.moduleUuids()).containsOnly(dir.moduleUuid());
assertThat(query.directories()).containsOnly(dir.path());
assertThat(query.onComponentOnly()).isFalse();
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method fail_if_created_after_and_created_since_are_both_set.
@Test
public void fail_if_created_after_and_created_since_are_both_set() {
SearchRequest request = new SearchRequest().setCreatedAfter("2013-07-25T07:35:00+0100").setCreatedInLast("palap");
try {
underTest.create(request);
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Parameters createdAfter and createdInLast cannot be set simultaneously");
}
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method fail_if_several_components_provided_with_since_leak_period.
@Test
public void fail_if_several_components_provided_with_since_leak_period() {
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
assertThatThrownBy(() -> underTest.create(new SearchRequest().setSinceLeakPeriod(true).setComponents(asList(project1.getKey(), project2.getKey())))).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("One and only one component must be provided when searching in new code period");
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method search_by_application_key.
@Test
public void search_by_application_key() {
ComponentDto application = db.components().insertPrivateApplication();
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
db.components().insertComponents(newProjectCopy(project1, application));
db.components().insertComponents(newProjectCopy(project2, application));
userSession.registerApplication(application, project1, project2).addProjectPermission(USER, application).addProjectPermission(USER, project1).addProjectPermission(USER, project2);
assertThat(underTest.create(new SearchRequest().setComponents(singletonList(application.getKey()))).viewUuids()).containsExactly(application.uuid());
}
Aggregations