diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClient.java index 17f1819fac..638d460553 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClient.java @@ -38,7 +38,6 @@ import org.jclouds.rest.annotations.OnlyElement; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.Unwrap; import com.google.common.util.concurrent.ListenableFuture; @@ -80,7 +79,7 @@ public interface VirtualMachineAsyncClient { */ @GET @QueryParams(keys = "command", values = "deployVirtualMachine") - @Unwrap + @SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" }) @Consumes(MediaType.APPLICATION_JSON) ListenableFuture deployVirtualMachineInZone(@QueryParam("zoneid") String zoneId, @QueryParam("serviceofferingid") String serviceOfferingId, @QueryParam("templateid") String templateId, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java index 47b64808ea..d35f34a3c0 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java @@ -26,13 +26,10 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.AssignVirtualMachineOptions; -import org.jclouds.cloudstack.options.DeployVirtualMachineOptions; import org.jclouds.cloudstack.options.ListVirtualMachinesOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; @@ -104,31 +101,6 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } - HttpRequest deployVirtualMachine = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "deployVirtualMachine") - .addQueryParam("zoneid", "6") - .addQueryParam("serviceofferingid", "4") - .addQueryParam("templateid", "5").build(); - - public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineAsyncClient.class, "deployVirtualMachineInZone", String.class, String.class, - String.class, DeployVirtualMachineOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, 4, 5)); - - assertRequestLineEquals(httpRequest, deployVirtualMachine.getRequestLine()); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = method(VirtualMachineAsyncClient.class, "rebootVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientExpectTest.java index 3fec266830..ec652b7922 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientExpectTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientExpectTest.java @@ -26,6 +26,7 @@ import java.security.cert.CertificateException; import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackContext; +import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.EncryptedPasswordAndPrivateKey; import org.jclouds.cloudstack.functions.WindowsLoginCredentialsFromEncryptedData; import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest; @@ -60,11 +61,8 @@ public class VirtualMachineClientExpectTest extends BaseCloudStackExpectTest { + + @Override + public String resource() { + return "/deployvirtualmachineresponse.json"; + } + + @Override + @SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" }) + public AsyncCreateResponse expected() { + return AsyncCreateResponse.builder().id("1234").jobId("50006").build(); + } +} diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/DeployVirtualMachineResponse4xTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/DeployVirtualMachineResponse4xTest.java new file mode 100644 index 0000000000..40e110b0be --- /dev/null +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/DeployVirtualMachineResponse4xTest.java @@ -0,0 +1,44 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudstack.parse; + +import org.jclouds.cloudstack.domain.AsyncCreateResponse; +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "DeployVirtualMachineResponse3xTest") +public class DeployVirtualMachineResponse4xTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/deployvirtualmachineresponse4x.json"; + } + + @Override + @SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" }) + public AsyncCreateResponse expected() { + return AsyncCreateResponse.builder().id("1cce6cb7-2268-47ff-9696-d9e610f6619a") + .jobId("13330fc9-8b3e-4582-aa3e-90883c041ff0").build(); + } +} diff --git a/apis/cloudstack/src/test/resources/deployvirtualmachineresponse4x.json b/apis/cloudstack/src/test/resources/deployvirtualmachineresponse4x.json new file mode 100644 index 0000000000..cf04a8d2f1 --- /dev/null +++ b/apis/cloudstack/src/test/resources/deployvirtualmachineresponse4x.json @@ -0,0 +1 @@ + { "deployvirtualmachineresponse" : {"id":"1cce6cb7-2268-47ff-9696-d9e610f6619a","jobid":"13330fc9-8b3e-4582-aa3e-90883c041ff0"}, "cloudstack-version": "4.1.0-SNAPSHOT" } \ No newline at end of file