From: Sébastien Lesaint Date: Wed, 24 Aug 2016 10:37:37 +0000 (+0200) Subject: fix coverage of CeService and TaskWsRequest X-Git-Tag: 6.1-RC1~301 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=21f1eb81370839656845e1136e8a7f01913c6e05;p=sonarqube.git fix coverage of CeService and TaskWsRequest --- diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java index f598efa4478..c1d51fded43 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java @@ -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) { diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java index f268f98dc91..4674d9d184f 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/ce/CeServiceTest.java @@ -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")); + } }