]> source.dussan.org Git - sonarqube.git/commitdiff
Add some UT
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 20 Jun 2013 14:39:40 +0000 (16:39 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 20 Jun 2013 14:39:40 +0000 (16:39 +0200)
sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClientTest.java

index 27ee1da2ee86063938d050bf6f2b6ef559cdcb43..feb57e3c984bc06092b8898e6c370cbf31df0d45 100644 (file)
@@ -52,6 +52,7 @@ public class IssueQueryTest {
       .planned(true)
       .resolved(true)
       .sort(IssueQuery.SORT_BY_ASSIGNEE)
+      .asc(true)
       .pageSize(10)
       .pageIndex(2)
       .requiredRole(UserRole.USER)
@@ -72,11 +73,34 @@ public class IssueQueryTest {
     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()
index 2e74730df142f84bd31428a83cafa4de121ecefe..540253a9bd58e7def4d1ab2d1c99067283fb5575 100644 (file)
@@ -48,6 +48,7 @@ public class DefaultActionPlanClientTest {
     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" +
@@ -65,6 +66,7 @@ public class DefaultActionPlanClientTest {
     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");