Search in sources :

Example 21 with SearchRequest

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

the class SearchAction method handle.

@Override
public final void handle(Request request, Response response) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        SearchRequest searchRequest = toSearchWsRequest(dbSession, request);
        checkIfNeedIssueSync(dbSession, searchRequest);
        SearchWsResponse searchWsResponse = doHandle(searchRequest);
        writeProtobuf(searchWsResponse, request, response);
    }
}
Also used : DbSession(org.sonar.db.DbSession) SearchRequest(org.sonar.server.issue.SearchRequest) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse)

Example 22 with SearchRequest

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

the class IssueQueryFactoryTest method fail_if_in_new_code_period_and_created_in_last_set_at_the_same_time.

@Test
public void fail_if_in_new_code_period_and_created_in_last_set_at_the_same_time() {
    SearchRequest searchRequest = new SearchRequest().setInNewCodePeriod(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 23 with SearchRequest

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

the class IssueQueryFactoryTest method dates_are_inclusive.

@Test
public void dates_are_inclusive() {
    when(clock.getZone()).thenReturn(ZoneId.of("Europe/Paris"));
    SearchRequest request = new SearchRequest().setCreatedAfter("2013-04-16").setCreatedBefore("2013-04-17");
    IssueQuery query = underTest.create(request);
    assertThat(query.createdAfter().date()).isEqualTo(parseDateTime("2013-04-16T00:00:00+0200"));
    assertThat(query.createdAfter().inclusive()).isTrue();
    assertThat(query.createdBefore()).isEqualTo(parseDateTime("2013-04-18T00:00:00+0200"));
}
Also used : SearchRequest(org.sonar.server.issue.SearchRequest) Test(org.junit.Test)

Example 24 with SearchRequest

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

the class IssueQueryFactoryTest method fail_if_no_component_provided_with_in_new_code_period.

@Test
public void fail_if_no_component_provided_with_in_new_code_period() {
    SearchRequest searchRequest = new SearchRequest().setInNewCodePeriod(true);
    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) Test(org.junit.Test)

Example 25 with SearchRequest

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

the class IssueQueryFactoryTest method create_with_rule_key_that_does_not_exist_in_the_db.

@Test
public void create_with_rule_key_that_does_not_exist_in_the_db() {
    db.users().insertUser(u -> u.setLogin("joanna"));
    ComponentDto project = db.components().insertPrivateProject();
    db.components().insertComponent(newModuleDto(project));
    db.components().insertComponent(newFileDto(project));
    newRule(RuleKey.of("findbugs", "NullReference"));
    SearchRequest request = new SearchRequest().setRules(asList("unknown:key1", "unknown:key2"));
    IssueQuery query = underTest.create(request);
    assertThat(query.rules()).isEmpty();
    assertThat(query.ruleUuids()).containsExactly("non-existing-uuid");
}
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