]> source.dussan.org Git - sonarqube.git/commitdiff
Add support of WS api/ce/task to sonar-ws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 14 Apr 2016 08:52:35 +0000 (10:52 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 14 Apr 2016 13:40:01 +0000 (15:40 +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 a05d383c67d2fb64669329a37343d328c7385133..1871cd800d946f4e626de93b4bed164f7e14b306 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.sonarqube.ws.client.ce;
 
+import org.sonarqube.ws.WsCe;
 import org.sonarqube.ws.WsCe.ActivityResponse;
 import org.sonarqube.ws.WsCe.TaskTypesWsResponse;
 import org.sonarqube.ws.client.BaseService;
@@ -33,6 +34,9 @@ import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_ONLY_CURRENTS;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_STATUS;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_TYPE;
 
+/**
+ * Maps web service {@code api/ce} (Compute Engine).
+ */
 public class CeService extends BaseService {
 
   public CeService(WsConnector wsConnector) {
@@ -58,4 +62,13 @@ public class CeService extends BaseService {
     return call(new GetRequest(path("task_types")), TaskTypesWsResponse.parser());
   }
 
+  /**
+   * Gets details of a Compute Engine task.
+   *
+   * @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx.
+   * @since 5.5
+   */
+  public WsCe.TaskResponse task(String id) {
+    return call(new GetRequest(path("task")).setParam("id", id), WsCe.TaskResponse.parser());
+  }
 }
index 1125072b933411a956f081872dfa554134363e19..51cc5293bc6f80ed3391cb302318f4a4d082bf7d 100644 (file)
@@ -30,6 +30,7 @@ import org.sonarqube.ws.client.ServiceTester;
 import org.sonarqube.ws.client.WsConnector;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.data.MapEntry.entry;
 import static org.mockito.Mockito.mock;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID;
 import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MAX_EXECUTED_AT;
@@ -94,4 +95,12 @@ public class CeServiceTest {
 
     assertThat(serviceTester.getGetParser()).isSameAs(WsCe.TaskTypesWsResponse.parser());
   }
+
+  @Test
+  public void task() {
+    underTest.task("task_id");
+
+    assertThat(serviceTester.getGetRequest().getPath()).isEqualTo("api/ce/task");
+    assertThat(serviceTester.getGetRequest().getParams()).containsOnly(entry("id", "task_id"));
+  }
 }