Search in sources :

Example 1 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueActionTest method assign.

/**
   * SONAR-4287
   */
@Test
public void assign() {
    assertThat(randomIssue.hasAssignee()).isFalse();
    Issues.SearchWsResponse response = issueRule.search(new SearchWsRequest().setIssues(singletonList(randomIssue.getKey())));
    assertThat(response.getUsers().getUsersList()).isEmpty();
    issuesService.assign(new AssignRequest(randomIssue.getKey(), "admin"));
    assertThat(issueRule.search(new SearchWsRequest().setAssignees(singletonList("admin"))).getIssuesList()).hasSize(1);
    projectAnalysis.run();
    Issue reloaded = issueRule.getByKey(randomIssue.getKey());
    assertThat(reloaded.getAssignee()).isEqualTo("admin");
    assertThat(reloaded.getCreationDate()).isEqualTo(randomIssue.getCreationDate());
    response = issueRule.search(new SearchWsRequest().setIssues(singletonList(randomIssue.getKey())).setAdditionalFields(singletonList("users")));
    assertThat(response.getUsers().getUsersList().stream().filter(user -> "admin".equals(user.getLogin())).findFirst()).isPresent();
    assertThat(response.getUsers().getUsersList().stream().filter(user -> "Administrator".equals(user.getName())).findFirst()).isPresent();
    // unassign
    issuesService.assign(new AssignRequest(randomIssue.getKey(), null));
    reloaded = issueRule.getByKey(randomIssue.getKey());
    assertThat(reloaded.hasAssignee()).isFalse();
    assertThat(issueRule.search(new SearchWsRequest().setAssignees(singletonList("admin"))).getIssuesList()).isEmpty();
}
Also used : EditCommentRequest(org.sonarqube.ws.client.issue.EditCommentRequest) Issues(org.sonarqube.ws.Issues) ItUtils.toDatetime(util.ItUtils.toDatetime) Issue(org.sonarqube.ws.Issues.Issue) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ProjectAnalysis(util.ProjectAnalysis) IssuesService(org.sonarqube.ws.client.issue.IssuesService) Test(org.junit.Test) SetSeverityRequest(org.sonarqube.ws.client.issue.SetSeverityRequest) Collections.singletonList(java.util.Collections.singletonList) ItUtils.newAdminWsClient(util.ItUtils.newAdminWsClient) List(java.util.List) BLOCKER(org.sonarqube.ws.Common.Severity.BLOCKER) Rule(org.junit.Rule) ProjectAnalysisRule(util.ProjectAnalysisRule) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) AddCommentRequest(org.sonarqube.ws.client.issue.AddCommentRequest) IssueRule(util.issue.IssueRule) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) AssignRequest(org.sonarqube.ws.client.issue.AssignRequest) Before(org.junit.Before) Issue(org.sonarqube.ws.Issues.Issue) Issues(org.sonarqube.ws.Issues) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) AssignRequest(org.sonarqube.ws.client.issue.AssignRequest) Test(org.junit.Test)

Example 2 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class LiteTest method call_issues_ws.

@Test
public void call_issues_ws() {
    // all issues
    Issues.SearchWsResponse response = wsClient.issues().search(new SearchWsRequest());
    assertThat(response.getIssuesCount()).isGreaterThan(0);
    // project issues
    response = wsClient.issues().search(new SearchWsRequest().setProjectKeys(singletonList(PROJECT_KEY)));
    assertThat(response.getIssuesCount()).isGreaterThan(0);
}
Also used : Issues(org.sonarqube.ws.Issues) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Example 3 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueTrackingTest method track_existing_unchanged_issues_on_module.

/**
   * SONAR-4310
   */
@Test
public void track_existing_unchanged_issues_on_module() throws Exception {
    // The custom rule on module is enabled
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "one-issue-per-module");
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");
    // Only one issue is created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(1);
    Issue issue = getRandomIssue();
    // Re analysis of the same project
    runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");
    // No new issue should be created
    assertThat(searchIssues(new SearchWsRequest()).getIssuesList()).hasSize(1);
    // The issue on module should stay open and be the same from the first analysis
    Issue reloadIssue = getIssueByKey(issue.getKey());
    assertThat(reloadIssue.getCreationDate()).isEqualTo(issue.getCreationDate());
    assertThat(reloadIssue.getStatus()).isEqualTo("OPEN");
    assertThat(reloadIssue.hasResolution()).isFalse();
}
Also used : Issue(org.sonarqube.ws.Issues.Issue) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Example 4 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueWorkflowTest method transitions.

private List<String> transitions(String issueKey) {
    Issues.SearchWsResponse response = searchIssues(new SearchWsRequest().setIssues(singletonList(issueKey)).setAdditionalFields(singletonList("transitions")));
    assertThat(response.getTotal()).isEqualTo(1);
    return response.getIssues(0).getTransitions().getTransitionsList();
}
Also used : Issues(org.sonarqube.ws.Issues) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest)

Example 5 with SearchWsRequest

use of org.sonarqube.ws.client.issue.SearchWsRequest in project sonarqube by SonarSource.

the class IssueQueryServiceTest method dates_are_inclusive.

@Test
public void dates_are_inclusive() {
    SearchWsRequest request = new SearchWsRequest().setCreatedAfter("2013-04-16").setCreatedBefore("2013-04-17");
    IssueQuery query = underTest.createFromRequest(request);
    assertThat(query.createdAfter()).isEqualTo(DateUtils.parseDate("2013-04-16"));
    assertThat(query.createdBefore()).isEqualTo(DateUtils.parseDate("2013-04-18"));
}
Also used : SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) Test(org.junit.Test)

Aggregations

SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)10 Test (org.junit.Test)8 Issue (org.sonarqube.ws.Issues.Issue)4 Issues (org.sonarqube.ws.Issues)3 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 ClassRule (org.junit.ClassRule)1 Rule (org.junit.Rule)1 BLOCKER (org.sonarqube.ws.Common.Severity.BLOCKER)1 SearchWsResponse (org.sonarqube.ws.Issues.SearchWsResponse)1 AddCommentRequest (org.sonarqube.ws.client.issue.AddCommentRequest)1 AssignRequest (org.sonarqube.ws.client.issue.AssignRequest)1 EditCommentRequest (org.sonarqube.ws.client.issue.EditCommentRequest)1 IssuesService (org.sonarqube.ws.client.issue.IssuesService)1 SetSeverityRequest (org.sonarqube.ws.client.issue.SetSeverityRequest)1 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)1 ItUtils.toDatetime (util.ItUtils.toDatetime)1