]> source.dussan.org Git - sonarqube.git/commitdiff
fix coverage of CeService and TaskWsRequest
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 24 Aug 2016 10:37:37 +0000 (12:37 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 25 Aug 2016 13:05:41 +0000 (15:05 +0200)
sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java
sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java

index f598efa447813749ce5af8b401fd6ae7c2c4a458..c1d51fded43093db9c00a5bf54798c7c3cf2ac74 100644 (file)
@@ -70,7 +70,7 @@ public class CeService extends BaseService {
    * @since 5.5
    */
   public WsCe.TaskResponse task(String id) {
-    return call(new GetRequest(path("task")).setParam("id", id), WsCe.TaskResponse.parser());
+    return task(TaskWsRequest.newBuilder(id).build());
   }
 
   public WsCe.TaskResponse task(TaskWsRequest taskWsRequest) {
index f268f98dc91ce163ff74e987bf5a2a7114204862..4674d9d184fbf913b979010b8be3eb39f5e37b71 100644 (file)
@@ -105,7 +105,7 @@ public class CeServiceTest {
   }
 
   @Test
-  public void task() {
+  public void task_with_stacktrace_and_scanner_context() {
     underTest.task(TaskWsRequest.newBuilder("task_id")
         .withErrorStacktrace()
         .withScannerContext()
@@ -114,4 +114,24 @@ public class CeServiceTest {
     assertThat(serviceTester.getGetRequest().getPath()).isEqualTo("api/ce/task");
     assertThat(serviceTester.getGetRequest().getParams()).containsOnly(entry("id", "task_id"), entry("additionalFields", "stacktrace,scannerContext"));
   }
+
+  @Test
+  public void task_with_scanner_context_only() {
+    underTest.task(TaskWsRequest.newBuilder("task_id")
+        .withScannerContext()
+        .build());
+
+    assertThat(serviceTester.getGetRequest().getPath()).isEqualTo("api/ce/task");
+    assertThat(serviceTester.getGetRequest().getParams()).containsOnly(entry("id", "task_id"), entry("additionalFields", "scannerContext"));
+  }
+
+  @Test
+  public void task_with_stacktrace_only() {
+    underTest.task(TaskWsRequest.newBuilder("task_id")
+        .withErrorStacktrace()
+        .build());
+
+    assertThat(serviceTester.getGetRequest().getPath()).isEqualTo("api/ce/task");
+    assertThat(serviceTester.getGetRequest().getParams()).containsOnly(entry("id", "task_id"), entry("additionalFields", "stacktrace"));
+  }
 }