From 21f1eb81370839656845e1136e8a7f01913c6e05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 24 Aug 2016 12:37:37 +0200 Subject: [PATCH] fix coverage of CeService and TaskWsRequest --- .../org/sonarqube/ws/client/ce/CeService.java | 2 +- .../sonarqube/ws/client/ce/CeServiceTest.java | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) 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")); + } } -- 2.39.5