use of org.sonar.wsclient.base.HttpException in project sonarqube by SonarSource.
the class IssueSearchTest method search_issues_by_dates.
/**
* SONAR-2981
*/
@Test
public void search_issues_by_dates() {
// issues have been created today
Date today = toDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
Date past = toDate("2013-01-01");
Date future = toDate("2020-12-31");
// createdAfter in the future => bad request
try {
search(IssueQuery.create().createdAfter(future)).list();
Fail.fail("Expecting 400 from issues search WS");
} catch (HttpException exception) {
assertThat(exception.getMessage()).contains("Start bound cannot be in the future");
}
// after date
assertThat(search(IssueQuery.create().createdAfter(today)).list().size()).isGreaterThan(0);
assertThat(search(IssueQuery.create().createdAfter(past)).list().size()).isGreaterThan(0);
// before
assertThat(search(IssueQuery.create().createdBefore(future)).list().size()).isGreaterThan(0);
assertThat(search(IssueQuery.create().createdBefore(past)).list()).isEmpty();
// before and after
assertThat(search(IssueQuery.create().createdBefore(future).createdAfter(past)).list().size()).isGreaterThan(0);
// createdAfter > createdBefore => bad request
try {
search(IssueQuery.create().createdBefore(past).createdAfter(today)).list();
Fail.fail("Expecting 400 from issues search WS");
} catch (HttpException exception) {
assertThat(exception.getMessage()).contains("Start bound cannot be larger or equal to end bound");
}
}
use of org.sonar.wsclient.base.HttpException in project sonarqube by SonarSource.
the class RealmAuthenticationTest method verifyHttpException.
private void verifyHttpException(Exception e, int expectedCode) {
assertThat(e).isInstanceOf(HttpException.class);
HttpException exception = (HttpException) e;
assertThat(exception.status()).isEqualTo(expectedCode);
}
use of org.sonar.wsclient.base.HttpException in project sonarqube by SonarSource.
the class ItUtils method verifyHttpException.
public static void verifyHttpException(Exception e, int expectedCode) {
assertThat(e).isInstanceOf(HttpException.class);
HttpException exception = (HttpException) e;
assertThat(exception.status()).isEqualTo(expectedCode);
}
Aggregations