Search in sources :

Example 6 with SearchRequest

use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.

the class IssueQueryFactoryTest method should_search_in_tree_with_module_uuid.

@Test
public void should_search_in_tree_with_module_uuid() {
    ComponentDto project = db.components().insertPrivateProject();
    ComponentDto module = db.components().insertComponent(newModuleDto(project));
    SearchRequest request = new SearchRequest().setComponentUuids(asList(module.uuid()));
    IssueQuery query = underTest.create(request);
    assertThat(query.moduleRootUuids()).containsExactly(module.uuid());
    assertThat(query.onComponentOnly()).isFalse();
}
Also used : SearchRequest(org.sonar.server.issue.SearchRequest) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 7 with SearchRequest

use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.

the class IssueQueryFactoryTest method param_componentUuids_enables_search_by_test_file.

@Test
public void param_componentUuids_enables_search_by_test_file() {
    ComponentDto project = db.components().insertPrivateProject();
    ComponentDto file = db.components().insertComponent(newFileDto(project).setQualifier(Qualifiers.UNIT_TEST_FILE));
    SearchRequest request = new SearchRequest().setComponentUuids(asList(file.uuid()));
    IssueQuery query = underTest.create(request);
    assertThat(query.componentUuids()).containsExactly(file.uuid());
}
Also used : SearchRequest(org.sonar.server.issue.SearchRequest) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 8 with SearchRequest

use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.

the class IssueQueryFactoryTest method application_search_project_issues.

@Test
public void application_search_project_issues() {
    ComponentDto project1 = db.components().insertPublicProject();
    ComponentDto project2 = db.components().insertPublicProject();
    ComponentDto application = db.components().insertPublicApplication();
    db.components().insertComponents(newProjectCopy("PC1", project1, application));
    db.components().insertComponents(newProjectCopy("PC2", project2, application));
    userSession.registerApplication(application, project1, project2);
    IssueQuery result = underTest.create(new SearchRequest().setComponentUuids(singletonList(application.uuid())));
    assertThat(result.viewUuids()).containsExactlyInAnyOrder(application.uuid());
}
Also used : SearchRequest(org.sonar.server.issue.SearchRequest) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 9 with SearchRequest

use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.

the class IssueQueryFactoryTest method fail_if_since_leak_period_and_created_in_last_set_at_the_same_time.

@Test
public void fail_if_since_leak_period_and_created_in_last_set_at_the_same_time() {
    SearchRequest searchRequest = new SearchRequest().setSinceLeakPeriod(true).setCreatedInLast("1y2m3w4d");
    assertThatThrownBy(() -> underTest.create(searchRequest)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Parameters 'createdInLast' and 'inNewCodePeriod' or 'sinceLeakPeriod' cannot be set simultaneously");
}
Also used : SearchRequest(org.sonar.server.issue.SearchRequest) Test(org.junit.Test)

Example 10 with SearchRequest

use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.

the class IssueQueryFactoryTest method fail_if_several_components_provided_with_in_new_code_period.

@Test
public void fail_if_several_components_provided_with_in_new_code_period() {
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    SearchRequest searchRequest = new SearchRequest().setInNewCodePeriod(true).setComponents(asList(project1.getKey(), project2.getKey()));
    assertThatThrownBy(() -> underTest.create(searchRequest)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("One and only one component must be provided when searching in new code period");
}
Also used : SearchRequest(org.sonar.server.issue.SearchRequest) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

SearchRequest (org.sonar.server.issue.SearchRequest)45 Test (org.junit.Test)43 ComponentDto (org.sonar.db.component.ComponentDto)26 Date (java.util.Date)11 SnapshotDto (org.sonar.db.component.SnapshotDto)11 Map (java.util.Map)8 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)8 UserDto (org.sonar.db.user.UserDto)8 Clock (java.time.Clock)7 ZoneId (java.time.ZoneId)7 ZoneOffset (java.time.ZoneOffset)7 ArrayList (java.util.ArrayList)7 Arrays.asList (java.util.Arrays.asList)7 Collections (java.util.Collections)7 Collections.singletonList (java.util.Collections.singletonList)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)7 Assertions.tuple (org.assertj.core.api.Assertions.tuple)7 Assert.fail (org.junit.Assert.fail)7 Rule (org.junit.Rule)7