Issue 464: updated cloudstack to use new json parsers

This commit is contained in:
Adrian Cole 2011-08-14 18:06:44 +01:00
parent 6b02b93cf7
commit 802f813663
39 changed files with 183 additions and 129 deletions

View File

@ -90,7 +90,7 @@ public class CloudStackParserModule extends AbstractModule {
private String name;
@SerializedName("receivedbytes")
private long receivedBytes;
@SerializedName("sentBytes")
@SerializedName("sentbytes")
private long sentBytes;
@SerializedName("snapshotavailable")
private String snapshotsAvailable;

View File

@ -29,9 +29,10 @@ import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.ListAccountsOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -53,7 +54,7 @@ public interface AccountAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listAccounts")
@Unwrap(depth = 2)
@SelectJson("account")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Account>> listAccounts(ListAccountsOptions... options);
@ -63,7 +64,8 @@ public interface AccountAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listAccounts")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("account")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Account> getAccount(@QueryParam("id") long id);

View File

@ -32,8 +32,10 @@ import org.jclouds.cloudstack.functions.ReturnVoidOnNotFoundOr404OrUnableToFindA
import org.jclouds.cloudstack.options.AssociateIPAddressOptions;
import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions;
import org.jclouds.rest.annotations.ExceptionParser;
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 org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -57,7 +59,7 @@ public interface AddressAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listPublicIpAddresses")
@Unwrap(depth = 2)
@SelectJson("publicipaddress")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<PublicIPAddress>> listPublicIPAddresses(ListPublicIPAddressesOptions... options);
@ -67,7 +69,8 @@ public interface AddressAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listPublicIpAddresses")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("publicipaddress")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<PublicIPAddress> getPublicIPAddress(@QueryParam("id") long id);

View File

@ -26,7 +26,7 @@ import org.jclouds.cloudstack.domain.Capabilities;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.util.concurrent.ListenableFuture;
@ -47,7 +47,7 @@ public interface ConfigurationAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listCapabilities")
@Unwrap(depth = 2)
@SelectJson("capability")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Capabilities> listCapabilities();

View File

@ -32,6 +32,7 @@ import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
import org.jclouds.rest.annotations.ExceptionParser;
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 org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
@ -55,7 +56,7 @@ public interface FirewallAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listPortForwardingRules")
@Unwrap(depth = 2)
@SelectJson("portforwardingrule")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<PortForwardingRule>> listPortForwardingRules(ListPortForwardingRulesOptions... options);

View File

@ -32,10 +32,11 @@ import org.jclouds.cloudstack.functions.ParseIdToNameEntryFromHttpResponse;
import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse;
import org.jclouds.cloudstack.options.ListOSTypesOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -58,7 +59,7 @@ public interface GuestOSAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listOsTypes")
@Unwrap(depth = 2)
@SelectJson("ostype")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<OSType>> listOSTypes(ListOSTypesOptions... options);
@ -68,7 +69,8 @@ public interface GuestOSAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listOsTypes")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("ostype")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<OSType> getOSType(@QueryParam("id") long id);

View File

@ -30,9 +30,10 @@ import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.CreateNetworkOptions;
import org.jclouds.cloudstack.options.ListNetworksOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -55,7 +56,7 @@ public interface NetworkAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listNetworks")
@Unwrap(depth = 2)
@SelectJson("network")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Network>> listNetworks(ListNetworksOptions... options);
@ -65,7 +66,8 @@ public interface NetworkAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listNetworks")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("network")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Network> getNetwork(@QueryParam("id") long id);
@ -75,7 +77,7 @@ public interface NetworkAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "createNetwork")
@Unwrap(depth = 2)
@SelectJson("network")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Network> createNetworkInZone(@QueryParam("zoneid") long zoneId,
@QueryParam("networkofferingid") long networkOfferingId, @QueryParam("name") String name,
@ -86,7 +88,7 @@ public interface NetworkAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "deleteNetwork")
@Unwrap(depth = 2)
@SelectJson("network")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Long> deleteNetwork(@QueryParam("id") long id);

View File

@ -33,9 +33,10 @@ import org.jclouds.cloudstack.options.ListDiskOfferingsOptions;
import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions;
import org.jclouds.cloudstack.options.ListServiceOfferingsOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -58,7 +59,7 @@ public interface OfferingAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listServiceOfferings")
@Unwrap(depth = 2)
@SelectJson("serviceoffering")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<ServiceOffering>> listServiceOfferings(ListServiceOfferingsOptions... options);
@ -68,7 +69,8 @@ public interface OfferingAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listServiceOfferings")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("serviceoffering")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ServiceOffering> getServiceOffering(@QueryParam("id") long id);
@ -78,7 +80,7 @@ public interface OfferingAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listDiskOfferings")
@Unwrap(depth = 2)
@SelectJson("diskoffering")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<DiskOffering>> listDiskOfferings(ListDiskOfferingsOptions... options);
@ -88,7 +90,8 @@ public interface OfferingAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listDiskOfferings")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("diskoffering")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<DiskOffering> getDiskOffering(@QueryParam("id") long id);
@ -98,7 +101,7 @@ public interface OfferingAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listNetworkOfferings")
@Unwrap(depth = 2)
@SelectJson("networkoffering")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<NetworkOffering>> listNetworkOfferings(ListNetworkOfferingsOptions... options);
@ -108,7 +111,8 @@ public interface OfferingAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listNetworkOfferings")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("networkoffering")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<NetworkOffering> getNetworkOffering(@QueryParam("id") long id);

View File

@ -33,8 +33,10 @@ import org.jclouds.cloudstack.options.AccountInDomainOptions;
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.ExceptionParser;
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 org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -60,7 +62,7 @@ public interface SecurityGroupAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listSecurityGroups")
@Unwrap(depth = 2)
@SelectJson("securitygroup")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<SecurityGroup>> listSecurityGroups(ListSecurityGroupsOptions... options);
@ -70,7 +72,8 @@ public interface SecurityGroupAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listSecurityGroups")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("securitygroup")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<SecurityGroup> getSecurityGroup(@QueryParam("id") long id);
@ -80,7 +83,7 @@ public interface SecurityGroupAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "createSecurityGroup")
@Unwrap(depth = 2)
@SelectJson("securitygroup")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<SecurityGroup> createSecurityGroup(@QueryParam("name") String name);

View File

@ -29,9 +29,10 @@ import org.jclouds.cloudstack.domain.Template;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.ListTemplatesOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -54,7 +55,7 @@ public interface TemplateAsyncClient {
*/
@GET
@QueryParams(keys = { "command", "templatefilter" }, values = { "listTemplates", "executable" })
@Unwrap(depth = 2)
@SelectJson("template")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Template>> listTemplates();
@ -64,7 +65,7 @@ public interface TemplateAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listTemplates")
@Unwrap(depth = 2)
@SelectJson("template")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Template>> listTemplates(ListTemplatesOptions options);
@ -74,7 +75,8 @@ public interface TemplateAsyncClient {
*/
@GET
@QueryParams(keys = { "command", "templatefilter" }, values = { "listTemplates", "executable" })
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("template")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Template> getTemplateInZone(@QueryParam("zoneid") long zoneId, @QueryParam("id") long id);

View File

@ -31,8 +31,10 @@ import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
import org.jclouds.rest.annotations.ExceptionParser;
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 org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -56,7 +58,7 @@ public interface VirtualMachineAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listVirtualMachines")
@Unwrap(depth = 2)
@SelectJson("virtualmachine")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<VirtualMachine>> listVirtualMachines(ListVirtualMachinesOptions... options);
@ -66,7 +68,8 @@ public interface VirtualMachineAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listVirtualMachines")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("virtualmachine")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<VirtualMachine> getVirtualMachine(@QueryParam("id") long id);

View File

@ -29,9 +29,10 @@ import org.jclouds.cloudstack.domain.Zone;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.ListZonesOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -54,7 +55,7 @@ public interface ZoneAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listZones")
@Unwrap(depth = 2)
@SelectJson("zone")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Zone>> listZones(ListZonesOptions... options);
@ -64,7 +65,8 @@ public interface ZoneAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "listZones")
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("zone")
@OnlyElement
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Zone> getZone(@QueryParam("id") long id);

View File

@ -26,12 +26,14 @@ import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.json.internal.GsonWrapper;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSortedMap;
import com.google.inject.Inject;
import com.google.inject.TypeLiteral;
/**
*
@ -39,7 +41,7 @@ import com.google.inject.Inject;
*/
@Singleton
public class ParseIdToNameFromHttpResponse implements Function<HttpResponse, Map<Long, String>> {
private final UnwrapOnlyNestedJsonValue<Set<IdName>> parser;
private final ParseFirstJsonValueNamed<Set<IdName>> parser;
private static class IdName {
private long id;
@ -76,8 +78,10 @@ public class ParseIdToNameFromHttpResponse implements Function<HttpResponse, Map
}
@Inject
public ParseIdToNameFromHttpResponse(UnwrapOnlyNestedJsonValue<Set<IdName>> parser) {
this.parser = checkNotNull(parser, "parser");
public ParseIdToNameFromHttpResponse(GsonWrapper gsonWrapper) {
this.parser = new ParseFirstJsonValueNamed<Set<IdName>>(checkNotNull(gsonWrapper, "gsonWrapper"),
new TypeLiteral<Set<IdName>>() {
}, "oscategory");
}
public Map<Long, String> apply(HttpResponse response) {

View File

@ -25,12 +25,14 @@ import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.json.internal.GsonWrapper;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.inject.Inject;
import com.google.inject.TypeLiteral;
/**
*
@ -38,7 +40,7 @@ import com.google.inject.Inject;
*/
@Singleton
public class ParseNamesFromHttpResponse implements Function<HttpResponse, Set<String>> {
private final UnwrapOnlyNestedJsonValue<Set<Name>> parser;
private final ParseFirstJsonValueNamed<Set<Name>> parser;
private static class Name {
private String name;
@ -71,8 +73,9 @@ public class ParseNamesFromHttpResponse implements Function<HttpResponse, Set<St
}
@Inject
public ParseNamesFromHttpResponse(UnwrapOnlyNestedJsonValue<Set<Name>> parser) {
this.parser = checkNotNull(parser, "parser");
public ParseNamesFromHttpResponse(GsonWrapper gsonWrapper) {
this.parser = new ParseFirstJsonValueNamed<Set<Name>>(checkNotNull(gsonWrapper, "gsonWrapper"), new TypeLiteral<Set<Name>>(){},
"hypervisor");
}
public Set<String> apply(HttpResponse response) {

View File

@ -22,14 +22,15 @@ import java.io.IOException;
import java.lang.reflect.Method;
import org.jclouds.cloudstack.options.ListAccountsOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -50,7 +51,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -68,7 +69,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -85,7 +86,8 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -24,17 +24,18 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.functions.ReturnVoidOnNotFoundOr404OrUnableToFindAccountOwner;
import org.jclouds.cloudstack.options.AssociateIPAddressOptions;
import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -55,7 +56,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -75,7 +76,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -92,7 +93,8 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -22,7 +22,7 @@ import java.io.IOException;
import java.lang.reflect.Method;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
@ -47,7 +47,7 @@ public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest<
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);

View File

@ -25,7 +25,7 @@ import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
@ -52,7 +52,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -70,7 +70,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);

View File

@ -24,14 +24,15 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.functions.ParseIdToNameEntryFromHttpResponse;
import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse;
import org.jclouds.cloudstack.options.ListOSTypesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -86,7 +87,8 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
@ -103,7 +105,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -120,7 +122,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);

View File

@ -24,15 +24,16 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.domain.NetworkType;
import org.jclouds.cloudstack.options.CreateNetworkOptions;
import org.jclouds.cloudstack.options.ListNetworksOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -52,7 +53,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -70,7 +71,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -87,7 +88,8 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
@ -105,7 +107,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -125,7 +127,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -142,7 +144,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -24,14 +24,15 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.options.ListDiskOfferingsOptions;
import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions;
import org.jclouds.cloudstack.options.ListServiceOfferingsOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -51,7 +52,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -68,7 +69,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -85,7 +86,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
@ -102,7 +104,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -121,7 +123,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -138,7 +140,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
@ -155,7 +158,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -174,7 +177,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -191,7 +194,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -23,10 +23,11 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.options.AccountInDomainOptions;
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -34,6 +35,7 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
@ -57,7 +59,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -76,7 +78,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -93,7 +95,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
@ -110,7 +113,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);

View File

@ -23,14 +23,15 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.domain.TemplateFilter;
import org.jclouds.cloudstack.options.ListTemplatesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -50,7 +51,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -69,7 +70,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -86,7 +87,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -23,16 +23,18 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
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.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.inject.TypeLiteral;
/**
@ -53,7 +55,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -73,7 +75,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -90,7 +92,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -22,14 +22,15 @@ import java.io.IOException;
import java.lang.reflect.Method;
import org.jclouds.cloudstack.options.ListZonesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
import com.google.common.collect.Iterables;
import com.google.inject.TypeLiteral;
@ -60,7 +61,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -78,7 +79,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
@ -95,7 +96,8 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
assertResponseParserClassEquals(method, httpRequest,
Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);

View File

@ -28,7 +28,7 @@ import org.jclouds.cloudstack.domain.User;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.json.config.GsonModule;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -62,7 +62,7 @@ public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
}
@Override
@Unwrap(depth = 3, edgeCollection = Set.class)
@SelectJson("account")
public Set<Account> expected() {
return ImmutableSet.<Account> of(Account
.builder()
@ -88,6 +88,7 @@ public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
.templateLimit(15l)
.templates(0)
.templatesAvailable(15l)
.VMsAvailable(14l)
.VMsStopped(0)
.VMsRunning(1)
.state(State.ENABLED)

View File

@ -20,7 +20,7 @@ package org.jclouds.cloudstack.parse;
import org.jclouds.cloudstack.domain.Capabilities;
import org.jclouds.json.BaseItemParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
/**
@ -36,7 +36,7 @@ public class ListCapabilitiesResponseTest extends BaseItemParserTest<Capabilitie
}
@Override
@Unwrap(depth = 2)
@SelectJson("capability")
public Capabilities expected() {
return Capabilities.builder().securityGroupsEnabled(true).sharedTemplatesEnabled(true).cloudStackVersion("2.2")
.build();

View File

@ -23,7 +23,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.DiskOffering;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -41,7 +41,7 @@ public class ListDiskOfferingsResponseTest extends BaseSetParserTest<DiskOfferin
}
@Override
@Unwrap(depth = 2)
@SelectJson("diskoffering")
public Set<DiskOffering> expected() {
return ImmutableSet.<DiskOffering> of(
DiskOffering.builder().id(3).domainId(1).domain("ROOT").name("Small").displayText("Small Disk, 5 GB")

View File

@ -23,7 +23,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.NetworkOffering;
import org.jclouds.cloudstack.domain.TrafficType;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -41,7 +41,7 @@ public class ListNetworkOfferingsResponseTest extends BaseSetParserTest<NetworkO
}
@Override
@Unwrap(depth = 2)
@SelectJson("networkoffering")
public Set<NetworkOffering> expected() {
return ImmutableSet.<NetworkOffering> of(
NetworkOffering.builder().id(7).name("DefaultDirectNetworkOffering").displayText("Direct")

View File

@ -26,7 +26,7 @@ import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.domain.NetworkService;
import org.jclouds.cloudstack.domain.TrafficType;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@ -48,7 +48,7 @@ public class ListNetworksResponseTest extends BaseSetParserTest<Network> {
}
@Override
@Unwrap(depth = 2)
@SelectJson("network")
public Set<Network> expected() {
return ImmutableSet
.<Network> of(Network

View File

@ -22,7 +22,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.OSType;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -40,7 +40,7 @@ public class ListOSTypesResponseTest extends BaseSetParserTest<OSType> {
}
@Override
@Unwrap(depth = 2)
@SelectJson("ostype")
public Set<OSType> expected() {
return ImmutableSet.<OSType> builder().add(
OSType.builder().id(69).OSCategoryId(7).description("Asianux 3(32-bit)").build()).add(

View File

@ -22,7 +22,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.PortForwardingRule;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -40,7 +40,7 @@ public class ListPortForwardingRulesResponseTest extends BaseSetParserTest<PortF
}
@Override
@Unwrap(depth = 2)
@SelectJson("portforwardingrule")
public Set<PortForwardingRule> expected() {
return ImmutableSet.<PortForwardingRule> of(
PortForwardingRule.builder().id(15).privatePort(22).protocol("tcp").publicPort(2022).virtualMachineId(3)

View File

@ -23,7 +23,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.PublicIPAddress;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -42,7 +42,7 @@ public class ListPublicIPAddressesResponseTest extends BaseSetParserTest<PublicI
}
@Override
@Unwrap(depth = 2)
@SelectJson("publicipaddress")
public Set<PublicIPAddress> expected() {
return ImmutableSet.of(PublicIPAddress.builder().id(30).IPAddress("72.52.126.59")
.allocated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-19T21:15:01-0800")).zoneId(1)

View File

@ -23,7 +23,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.IngressRule;
import org.jclouds.cloudstack.domain.SecurityGroup;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -41,7 +41,7 @@ public class ListSecurityGroupsResponseTest extends BaseSetParserTest<SecurityGr
}
@Override
@Unwrap(depth = 2)
@SelectJson("securitygroup")
public Set<SecurityGroup> expected() {
return ImmutableSet
.<SecurityGroup> builder()

View File

@ -24,7 +24,7 @@ import org.jclouds.cloudstack.domain.ServiceOffering;
import org.jclouds.cloudstack.domain.StorageType;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -42,7 +42,7 @@ public class ListServiceOfferingsResponseTest extends BaseSetParserTest<ServiceO
}
@Override
@Unwrap(depth = 2)
@SelectJson("serviceoffering")
public Set<ServiceOffering> expected() {
return ImmutableSet.<ServiceOffering> of(
ServiceOffering.builder().id(1).name("Small Instance")

View File

@ -25,7 +25,7 @@ import org.jclouds.cloudstack.domain.Template.Format;
import org.jclouds.cloudstack.domain.Template.Type;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -45,7 +45,7 @@ public class ListTemplatesResponseTest extends BaseSetParserTest<Template> {
}
@Override
@Unwrap(depth = 2)
@SelectJson("template")
public Set<Template> expected() {
return ImmutableSet.of(
Template.builder().id(2).name("CentOS 5.3(64-bit) no GUI (XenServer)")

View File

@ -26,7 +26,7 @@ import org.jclouds.cloudstack.domain.TrafficType;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -44,7 +44,7 @@ public class ListVirtualMachinesResponseTest extends BaseSetParserTest<VirtualMa
}
@Override
@Unwrap(depth = 2)
@SelectJson("virtualmachine")
public Set<VirtualMachine> expected() {
return ImmutableSet.of(VirtualMachine
.builder()

View File

@ -23,7 +23,7 @@ import java.util.Set;
import org.jclouds.cloudstack.domain.NetworkType;
import org.jclouds.cloudstack.domain.Zone;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -41,7 +41,7 @@ public class ListZonesResponseTest extends BaseSetParserTest<Zone> {
}
@Override
@Unwrap(depth = 2)
@SelectJson("zone")
public Set<Zone> expected() {
return ImmutableSet.of(Zone.builder().id(1).name("San Jose 1").networkType(NetworkType.ADVANCED)
.securityGroupsEnabled(false).build(),