.planned(true)
.resolved(true)
.sort(IssueQuery.SORT_BY_ASSIGNEE)
+ .asc(true)
.pageSize(10)
.pageIndex(2)
.requiredRole(UserRole.USER)
assertThat(query.planned()).isTrue();
assertThat(query.resolved()).isTrue();
assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_ASSIGNEE);
+ assertThat(query.asc()).isTrue();
assertThat(query.pageSize()).isEqualTo(10);
assertThat(query.pageIndex()).isEqualTo(2);
assertThat(query.requiredRole()).isEqualTo(UserRole.USER);
}
+ @Test
+ public void should_build_query_without_dates() throws Exception {
+ IssueQuery query = IssueQuery.builder()
+ .issueKeys(Lists.newArrayList("ABCDE"))
+ .build();
+
+ assertThat(query.issueKeys()).containsOnly("ABCDE");
+ assertThat(query.createdAfter()).isNull();
+ assertThat(query.createdBefore()).isNull();
+ }
+
+ @Test
+ public void should_throw_exception_if_sort_is_not_valid() throws Exception {
+ try {
+ IssueQuery.builder()
+ .sort("UNKNOWN")
+ .build();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Bad sort field: UNKNOWN");
+ }
+ }
+
@Test
public void collection_params_should_not_be_null_but_empty() throws Exception {
IssueQuery query = IssueQuery.builder()
HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
httpServer.doReturnBody("{\"actionPlans\": [{\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\",\n" +
"\"name\": \"Long term\",\n" +
+ "\"desc\": \"Long term acton plan\",\n" +
"\"status\": \"CLOSED\",\n" +
"\"project\": \"com.sonarsource.it.samples:simple-sample\",\n" +
"\"userLogin\": \"admin\",\n" +
ActionPlan actionPlan = actionPlans.get(0);
assertThat(actionPlan.key()).isEqualTo("382f6f2e-ad9d-424a-b973-9b065e04348a");
assertThat(actionPlan.name()).isEqualTo("Long term");
+ assertThat(actionPlan.description()).isEqualTo("Long term acton plan");
assertThat(actionPlan.project()).isEqualTo("com.sonarsource.it.samples:simple-sample");
assertThat(actionPlan.status()).isEqualTo("CLOSED");
assertThat(actionPlan.userLogin()).isEqualTo("admin");