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();
}
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);
}
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();
}
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();
}
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"));
}
Aggregations