From 5b8ee87a4d140573db823f078ea6f8c04bd9d178 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 14 May 2011 00:44:54 -0700 Subject: [PATCH] major overhaul to ibm smartcloud --- .../compute/domain/OsFamilyVersion64Bit.java | 2 +- .../domain/internal/TemplateBuilderImpl.java | 6 +- .../reference/ComputeServiceConstants.java | 2 +- .../compute/util/ComputeServiceUtils.java | 2 + .../compute/BaseComputeServiceLiveTest.java | 101 ++-- .../compute/BaseTemplateBuilderLiveTest.java | 2 +- .../internal/RestAnnotationProcessor.java | 70 +-- core/src/main/resources/rest.properties | 4 +- .../java/org/jclouds/json/BaseParserTest.java | 55 ++- .../org/jclouds/json/BaseSetParserTest.java | 17 - .../functions/UnwrapLoadBalancerTest.java | 7 +- .../functions/UnwrapLoadBalancersTest.java | 7 +- .../parse/ListAccountsResponseTest.java | 10 +- .../parse/ListCapabilitiesResponseTest.java | 7 +- .../parse/ListDiskOfferingsResponseTest.java | 7 +- .../parse/ListHypervisorsResponseTest.java | 7 +- .../ListNetworkOfferingsResponseTest.java | 7 +- .../parse/ListNetworksResponseTest.java | 7 +- .../parse/ListOSCategoriesResponseTest.java | 8 +- .../parse/ListOSTypesResponseTest.java | 10 +- .../ListPortForwardingRulesResponseTest.java | 7 +- .../ListPublicIPAddressesResponseTest.java | 8 +- .../parse/ListSecurityGroupsResponseTest.java | 7 +- .../ListServiceOfferingsResponseTest.java | 7 +- .../parse/ListTemplatesResponseTest.java | 7 +- .../ListVirtualMachinesResponseTest.java | 7 +- .../parse/ListZonesResponseTest.java | 7 +- .../{ibmdev => ibm-smartcloud}/pom.xml | 41 +- .../smartcloud/IBMSmartCloudAsyncClient.java} | 226 ++++----- .../ibm/smartcloud/IBMSmartCloudClient.java} | 32 +- .../IBMSmartCloudContextBuilder.java} | 18 +- .../IBMSmartCloudPropertiesBuilder.java} | 16 +- ...artCloudBindComputeStrategiesByClass.java} | 30 +- ...martCloudBindComputeSuppliersByClass.java} | 18 +- ...martCloudComputeServiceContextModule.java} | 18 +- ...loudComputeServiceDependenciesModule.java} | 43 +- .../functions/InstanceToNodeMetadata.java | 66 ++- .../options/IBMSmartCloudTemplateOptions.java | 366 ++++++++++++++ ...sWithGroupEncodedIntoNameThenAddToSet.java | 64 ++- ...udCreateNodeWithGroupEncodedIntoName.java} | 27 +- .../IBMSmartCloudDestroyNodeStrategy.java | 74 +++ ...IBMSmartCloudGetNodeMetadataStrategy.java} | 14 +- .../IBMSmartCloudLifeCycleStrategy.java} | 12 +- .../IBMSmartCloudListNodesStrategy.java} | 14 +- .../IBMSmartCloudHardwareSupplier.java} | 20 +- .../IBMSmartCloudImageSupplier.java} | 54 ++- .../IBMSmartCloudLocationSupplier.java} | 29 +- .../config/IBMSmartCloudParserModule.java} | 6 +- .../IBMSmartCloudRestClientModule.java} | 28 +- .../ibm/smartcloud}/domain/Address.java | 74 ++- .../org/jclouds/ibm/smartcloud/domain/IP.java | 127 +++++ .../jclouds/ibm/smartcloud/domain/Image.java | 221 +++++++++ .../ibm/smartcloud/domain/Instance.java | 449 ++++++++++++++++++ .../ibm/smartcloud}/domain/InstanceType.java | 4 +- .../jclouds/ibm/smartcloud}/domain/Key.java | 10 +- .../ibm/smartcloud/domain/Location.java | Bin 0 -> 4568 bytes .../ibm/smartcloud}/domain/Offering.java | 13 +- .../jclouds/ibm/smartcloud}/domain/Price.java | 4 +- .../smartcloud}/domain/StorageOffering.java | 2 +- .../jclouds/ibm/smartcloud/domain/Vlan.java} | 96 ++-- .../ibm/smartcloud}/domain/Volume.java | 10 +- .../functions/ParseLongFromDate.java | 2 +- .../handlers/IBMSmartCloudErrorHandler.java} | 6 +- .../options/CreateInstanceOptions.java | 207 ++++++++ .../options/RestartInstanceOptions.java | 2 +- .../smartcloud}/predicates/AddressFree.java | 10 +- .../predicates/InstanceActive.java | 10 +- .../predicates/InstanceActiveOrFailed.java | 10 +- .../predicates/InstanceRemovedOrNotFound.java | 10 +- .../predicates/VolumeUnmounted.java | 10 +- .../smartcloud/reference/Capabilities.java} | 7 +- .../ibm/smartcloud}/xml/LocationHandler.java | 21 +- .../ibm/smartcloud}/xml/LocationsHandler.java | 10 +- .../BaseIBMSmartCloudClientLiveTest.java | 91 ++++ .../IBMSmartCloudAsyncClientTest.java} | 279 ++++++----- .../IBMSmartCloudClientLiveTest.java} | 295 ++++-------- .../ProvidersInPropertiesTest.java | 6 +- .../ReadOnlyIBMSmartCloudClientLiveTest.java | 125 +++++ .../IBMSmartCloudComputeServiceLiveTest.java} | 32 +- .../IBMSmartCloudTemplateBuilderLiveTest.java | 83 ++++ .../ExtendReservationForInstanceTest.java} | 42 +- .../ibm/smartcloud/parse/GetAddressTest.java} | 22 +- .../ibm/smartcloud/parse/GetImageTest.java | 76 +++ .../ibm/smartcloud/parse/GetInstanceTest.java | 61 +++ .../ibm/smartcloud/parse/GetKeyTest.java | 54 +++ .../ibm/smartcloud/parse/GetVolumeTest.java | 50 ++ .../smartcloud/parse/ListAddressesTest.java} | 41 +- .../ibm/smartcloud/parse/ListImagesTest.java | 80 ++++ .../smartcloud/parse/ListInstancesTest.java | 66 +++ .../ibm/smartcloud/parse/ListKeysTest.java | 58 +++ .../parse/ListStorageOfferingsTest.java | 66 +++ .../ibm/smartcloud/parse/ListVolumesTest.java | 57 +++ .../smartcloud}/xml/LocationHandlerTest.java | Bin 2443 -> 2095 bytes .../smartcloud/xml/LocationsHandlerTest.java | Bin 0 -> 4711 bytes .../src/test/resources/address.json | 0 .../src/test/resources/addresses.json | 0 .../src/test/resources/image.json | 1 + .../src/test/resources/images.json | 1 + .../src/test/resources/instance.json | 29 ++ .../src/test/resources/instances.json | 31 ++ .../src/test/resources/key.json | 0 .../src/test/resources/keys.json | 0 .../src/test/resources/location.xml | 24 + .../src/test/resources/locations.xml | 124 +++++ .../src/test/resources/log4j.xml | 0 .../src/test/resources/storage-offerings.json | 0 .../src/test/resources/volume.json | 0 .../src/test/resources/volumes.json | 0 .../IBMDeveloperCloudTemplateOptions.java | 283 ----------- .../IBMDeveloperCloudDestroyNodeStrategy.java | 50 -- .../java/org/jclouds/ibmdev/domain/Image.java | 302 ------------ .../org/jclouds/ibmdev/domain/Instance.java | 432 ----------------- .../functions/ParseAddressFromJson.java | 72 --- .../functions/ParseAddressesFromJson.java | 56 --- .../ParseExpirationTimeFromJson.java | 53 --- .../ibmdev/functions/ParseImagesFromJson.java | 55 --- .../functions/ParseInstanceFromJson.java | 49 -- .../functions/ParseInstancesFromJson.java | 56 --- .../ibmdev/functions/ParseKeysFromJson.java | 55 --- .../jclouds/ibmdev/functions/ParseUtils.java | 99 ---- .../ibmdev/functions/ParseVolumeFromJson.java | 49 -- .../functions/ParseVolumesFromJson.java | 56 --- .../ibmdev/options/CreateInstanceOptions.java | 137 ------ ...erCloudComputeServiceLiveTestDisabled.java | 78 --- ...DeveloperCloudTemplateBuilderLiveTest.java | 60 --- .../functions/ParseAddressFromJsonTest.java | 58 --- .../functions/ParseAddressesFromJsonTest.java | 59 --- .../functions/ParseImageFromJsonTest.java | 83 ---- .../functions/ParseImagesFromJsonTest.java | 81 ---- .../functions/ParseInstanceFromJsonTest.java | 65 --- .../functions/ParseInstancesFromJsonTest.java | 71 --- .../functions/ParseKeyFromJsonTest.java | 65 --- .../functions/ParseKeysFromJsonTest.java | 64 --- .../ParseStorageOfferingsFromJsonTest.java | 77 --- .../functions/ParseVolumeFromJsonTest.java | 63 --- .../functions/ParseVolumesFromJsonTest.java | 65 --- .../ibmdev/xml/LocationsHandlerTest.java | 102 ---- .../ibmdev/src/test/resources/instance.json | 21 - .../ibmdev/src/test/resources/instances.json | 46 -- .../ibmdev/src/test/resources/location.xml | 39 -- 140 files changed, 3558 insertions(+), 4056 deletions(-) rename sandbox-providers/{ibmdev => ibm-smartcloud}/pom.xml (76%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/IBMDeveloperCloudAsyncClient.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/IBMSmartCloudAsyncClient.java} (52%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/IBMDeveloperCloudClient.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/IBMSmartCloudClient.java} (95%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/IBMDeveloperCloudContextBuilder.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/IBMSmartCloudContextBuilder.java} (64%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/IBMDeveloperCloudPropertiesBuilder.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/IBMSmartCloudPropertiesBuilder.java} (79%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudBindComputeStrategiesByClass.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/config/IBMSmartCloudBindComputeStrategiesByClass.java} (67%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudBindComputeSuppliersByClass.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/config/IBMSmartCloudBindComputeSuppliersByClass.java} (71%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceContextModule.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/config/IBMSmartCloudComputeServiceContextModule.java} (69%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceDependenciesModule.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/config/IBMSmartCloudComputeServiceDependenciesModule.java} (66%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/compute/functions/InstanceToNodeMetadata.java (55%) create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/options/IBMSmartCloudTemplateOptions.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/compute/strategy/CreateKeyCreateNodesWithGroupEncodedIntoNameThenAddToSet.java (62%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudCreateNodeWithGroupEncodedIntoName.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/strategy/IBMSmartCloudCreateNodeWithGroupEncodedIntoName.java} (58%) create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/strategy/IBMSmartCloudDestroyNodeStrategy.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudGetNodeMetadataStrategy.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/strategy/IBMSmartCloudGetNodeMetadataStrategy.java} (80%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudLifeCycleStrategy.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/strategy/IBMSmartCloudLifeCycleStrategy.java} (82%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudListNodesStrategy.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/strategy/IBMSmartCloudListNodesStrategy.java} (83%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/suppliers/IBMDeveloperCloudHardwareSupplier.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/suppliers/IBMSmartCloudHardwareSupplier.java} (80%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/suppliers/IBMDeveloperCloudImageSupplier.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/suppliers/IBMSmartCloudImageSupplier.java} (53%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/compute/suppliers/IBMDeveloperCloudLocationSupplier.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/compute/suppliers/IBMSmartCloudLocationSupplier.java} (64%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/config/IBMDeveloperCloudParserModule.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/config/IBMSmartCloudParserModule.java} (95%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/config/IBMDeveloperCloudRestClientModule.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/config/IBMSmartCloudRestClientModule.java} (67%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/Address.java (76%) create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/domain/IP.java create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/domain/Image.java create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/domain/Instance.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/InstanceType.java (98%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/Key.java (95%) create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/domain/Location.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/Offering.java (91%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/Price.java (98%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/StorageOffering.java (98%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/domain/Location.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/domain/Vlan.java} (58%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/domain/Volume.java (97%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/functions/ParseLongFromDate.java (96%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/handlers/IBMDeveloperCloudErrorHandler.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/handlers/IBMSmartCloudErrorHandler.java} (96%) create mode 100644 sandbox-providers/ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/options/CreateInstanceOptions.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/options/RestartInstanceOptions.java (97%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/predicates/AddressFree.java (88%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/predicates/InstanceActive.java (88%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/predicates/InstanceActiveOrFailed.java (86%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/predicates/InstanceRemovedOrNotFound.java (85%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/predicates/VolumeUnmounted.java (86%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/reference/IBMDeveloperCloudConstants.java => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud/reference/Capabilities.java} (81%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/xml/LocationHandler.java (88%) rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev => ibm-smartcloud/src/main/java/org/jclouds/ibm/smartcloud}/xml/LocationsHandler.java (89%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/BaseIBMSmartCloudClientLiveTest.java rename sandbox-providers/{ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudAsyncClientTest.java => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/IBMSmartCloudAsyncClientTest.java} (66%) rename sandbox-providers/{ibmdev/src/test/java/org/jclouds/ibmdev/IBMDeveloperCloudClientLiveTest.java => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/IBMSmartCloudClientLiveTest.java} (63%) rename sandbox-providers/{ibmdev/src/test/java/org/jclouds/ibmdev => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud}/ProvidersInPropertiesTest.java (87%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/ReadOnlyIBMSmartCloudClientLiveTest.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/functions/GetFirstInstanceInList.java => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/compute/IBMSmartCloudComputeServiceLiveTest.java} (57%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/compute/IBMSmartCloudTemplateBuilderLiveTest.java rename sandbox-providers/{ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseExpirationTimeFromJsonTest.java => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ExtendReservationForInstanceTest.java} (51%) rename sandbox-providers/{ibmdev/src/test/java/org/jclouds/ibmdev/compute/config/IBMDeveloperCloudComputeServiceDependenciesModuleTest.java => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/GetAddressTest.java} (63%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/GetImageTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/GetInstanceTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/GetKeyTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/GetVolumeTest.java rename sandbox-providers/{ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseImageFromJson.java => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ListAddressesTest.java} (54%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ListImagesTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ListInstancesTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ListKeysTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ListStorageOfferingsTest.java create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/parse/ListVolumesTest.java rename sandbox-providers/{ibmdev/src/test/java/org/jclouds/ibmdev => ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud}/xml/LocationHandlerTest.java (55%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/xml/LocationsHandlerTest.java rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/address.json (100%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/addresses.json (100%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/image.json (98%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/images.json (98%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/resources/instance.json create mode 100644 sandbox-providers/ibm-smartcloud/src/test/resources/instances.json rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/key.json (100%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/keys.json (100%) create mode 100644 sandbox-providers/ibm-smartcloud/src/test/resources/location.xml create mode 100644 sandbox-providers/ibm-smartcloud/src/test/resources/locations.xml rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/log4j.xml (100%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/storage-offerings.json (100%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/volume.json (100%) rename sandbox-providers/{ibmdev => ibm-smartcloud}/src/test/resources/volumes.json (100%) delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/options/IBMDeveloperCloudTemplateOptions.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/compute/strategy/IBMDeveloperCloudDestroyNodeStrategy.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/domain/Image.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/domain/Instance.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseAddressFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseAddressesFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseExpirationTimeFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseImagesFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseInstanceFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseInstancesFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseKeysFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseUtils.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseVolumeFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/functions/ParseVolumesFromJson.java delete mode 100644 sandbox-providers/ibmdev/src/main/java/org/jclouds/ibmdev/options/CreateInstanceOptions.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTestDisabled.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudTemplateBuilderLiveTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseAddressFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseAddressesFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseImageFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseImagesFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseInstanceFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseInstancesFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseKeyFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseKeysFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseStorageOfferingsFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseVolumeFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/functions/ParseVolumesFromJsonTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/xml/LocationsHandlerTest.java delete mode 100644 sandbox-providers/ibmdev/src/test/resources/instance.json delete mode 100644 sandbox-providers/ibmdev/src/test/resources/instances.json delete mode 100644 sandbox-providers/ibmdev/src/test/resources/location.xml diff --git a/compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java b/compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java index cd57a7e618..7725027694 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java +++ b/compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java @@ -42,7 +42,7 @@ public class OsFamilyVersion64Bit { @Override public String toString() { - return "OsFamilyVersion64Bit [family=" + family + ", version=" + version + ", is64Bit=" + is64Bit + "]"; + return "[family=" + family + ", version=" + version + ", is64Bit=" + is64Bit + "]"; } @Override diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index f956a9fe1d..c03791bbd0 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -557,10 +557,10 @@ public class TemplateBuilderImpl implements TemplateBuilder { } protected Hardware resolveSize(Ordering hardwareOrdering, final Iterable images) { - Set hardwaresl = hardwares.get(); + Set hardwarel = hardwares.get(); Hardware hardware; try { - Iterable hardwaresThatAreCompatibleWithOurImages = filter(hardwaresl, + Iterable hardwaresThatAreCompatibleWithOurImages = filter(hardwarel, new Predicate() { @Override public boolean apply(final Hardware hardware) { @@ -582,7 +582,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { }); hardware = hardwareOrdering.max(filter(hardwaresThatAreCompatibleWithOurImages, hardwarePredicate)); } catch (NoSuchElementException exception) { - throw new NoSuchElementException("hardwares don't support any images: " + toString() + "\n" + hardwaresl + throw new NoSuchElementException("hardware don't support any images: " + toString() + "\n" + hardwarel + "\n" + images); } logger.debug("<< matched hardware(%s)", hardware); diff --git a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java index 57b0aef3f1..2e1db1224d 100644 --- a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java +++ b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java @@ -57,7 +57,7 @@ public interface ComputeServiceConstants { public static class ReferenceData { @Inject(optional = true) @Named(PROPERTY_OS_VERSION_MAP_JSON) - public String osVersionMapJson = "{\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; + public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; } @Singleton diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index b1902166d5..7af92b8b42 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -105,6 +105,8 @@ public class ComputeServiceUtils { * @return null if group cannot be parsed */ public static String parseGroupFromName(String from) { + if (from == null) + return null; Matcher matcher = DELIMETED_BY_HYPHEN_ENDING_IN_HYPHEN_HEX.matcher(from); return matcher.find() ? matcher.group(1) : null; } diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index b2611b7fd8..2bf2cd7473 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -160,8 +160,8 @@ public abstract class BaseComputeServiceLiveTest { if (context != null) context.close(); Properties props = setupProperties(); - context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), props); + context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, ImmutableSet.of( + new Log4JLoggingModule(), getSshModule()), props); client = context.getComputeService(); } @@ -182,7 +182,7 @@ public abstract class BaseComputeServiceLiveTest { ComputeServiceContext context = null; try { context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, "MOMMA", "MIA", - ImmutableSet. of(new Log4JLoggingModule())); + ImmutableSet. of(new Log4JLoggingModule())); context.getComputeService().listNodes(); } catch (AuthorizationException e) { throw e; @@ -207,7 +207,7 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, expectedExceptions = NoSuchElementException.class) public void testCorrectExceptionRunningNodesNotFound() throws Exception { client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), buildScript(new OperatingSystem.Builder() - .family(OsFamily.UBUNTU).description("ffoo").build())); + .family(OsFamily.UBUNTU).description("ffoo").build())); } // since surefire and eclipse don't otherwise guarantee the order, we are @@ -231,17 +231,17 @@ public abstract class BaseComputeServiceLiveTest { OperatingSystem os = get(nodes, 0).getOperatingSystem(); try { Map responses = runScriptWithCreds(group, os, new Credentials( - good.identity, "romeo")); + good.identity, "romeo")); assert false : "shouldn't pass with a bad password\n" + responses; } catch (RunScriptOnNodesException e) { assert getRootCause(e).getMessage().contains("Auth fail") : e; } for (Entry response : client.runScriptOnNodesMatching( - runningInGroup(group), Statements.exec("echo hello"), - overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet()) + runningInGroup(group), Statements.exec("echo hello"), + overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet()) assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": " - + response.getValue(); + + response.getValue(); runScriptWithCreds(group, os, good); @@ -298,7 +298,8 @@ public abstract class BaseComputeServiceLiveTest { // template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) // .runScript(buildScript(template.getImage().getOperatingSystem())); template.getOptions().runScript( - Statements.newStatementList(AdminAccess.standard(), buildScript(template.getImage().getOperatingSystem()))); + Statements.newStatementList(AdminAccess.standard(), + buildScript(template.getImage().getOperatingSystem()))); } protected void checkImageIdMatchesTemplate(NodeMetadata node) { @@ -309,8 +310,8 @@ public abstract class BaseComputeServiceLiveTest { protected void checkOsMatchesTemplate(NodeMetadata node) { if (node.getOperatingSystem() != null) assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String - .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), - node.getOperatingSystem()); + .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node + .getOperatingSystem()); } void assertLocationSameOrChild(Location test, Location expected) { @@ -342,10 +343,10 @@ public abstract class BaseComputeServiceLiveTest { } protected Map runScriptWithCreds(final String group, OperatingSystem os, - Credentials creds) throws RunScriptOnNodesException { + Credentials creds) throws RunScriptOnNodesException { try { return client.runScriptOnNodesMatching(runningInGroup(group), buildScript(os), overrideCredentialsWith(creds) - .nameTask("runScriptWithCreds")); + .nameTask("runScriptWithCreds")); } catch (SshException e) { throw e; } @@ -375,16 +376,16 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testGet() throws Exception { - Map metadataMap = newLinkedHashMap(uniqueIndex( - filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))), - new Function() { + Map metadataMap = newLinkedHashMap(uniqueIndex(filter(client + .listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))), + new Function() { - @Override - public String apply(NodeMetadata from) { - return from.getId(); - } + @Override + public String apply(NodeMetadata from) { + return from.getId(); + } - })); + })); for (NodeMetadata node : nodes) { metadataMap.remove(node.getId()); NodeMetadata metadata = client.getNodeMetadata(node.getId()); @@ -403,7 +404,7 @@ public abstract class BaseComputeServiceLiveTest { protected void assertNodeZero(Collection metadataSet) { assert metadataSet.size() == 0 : String.format("nodes left in set: [%s] which didn't match set: [%s]", - metadataSet, nodes); + metadataSet, nodes); } @Test(enabled = true, dependsOnMethods = "testGet") @@ -491,12 +492,12 @@ public abstract class BaseComputeServiceLiveTest { } template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 600).inboundPorts(22, 8080)) - .build(); + .build(); // note this is a dependency on the template resolution template.getOptions().runScript( - RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage() - .getOperatingSystem())); + RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage() + .getOperatingSystem())); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); @@ -530,26 +531,26 @@ public abstract class BaseComputeServiceLiveTest { assert location != location.getParent() : location; assert location.getScope() != null : location; switch (location.getScope()) { - case PROVIDER: - assertProvider(location); - break; - case REGION: - assertProvider(location.getParent()); - break; - case ZONE: - Location provider = location.getParent().getParent(); - // zone can be a direct descendant of provider - if (provider == null) - provider = location.getParent(); - assertProvider(provider); - break; - case HOST: - Location provider2 = location.getParent().getParent().getParent(); - // zone can be a direct descendant of provider - if (provider2 == null) - provider2 = location.getParent().getParent(); - assertProvider(provider2); - break; + case PROVIDER: + assertProvider(location); + break; + case REGION: + assertProvider(location.getParent()); + break; + case ZONE: + Location provider = location.getParent().getParent(); + // zone can be a direct descendant of provider + if (provider == null) + provider = location.getParent(); + assertProvider(provider); + break; + case HOST: + Location provider2 = location.getParent().getParent().getParent(); + // zone can be a direct descendant of provider + if (provider2 == null) + provider2 = location.getParent().getParent(); + assertProvider(provider2); + break; } } } @@ -582,10 +583,10 @@ public abstract class BaseComputeServiceLiveTest { public void testListSizes() throws Exception { for (Hardware hardware : client.listHardwareProfiles()) { - assert hardware.getProviderId() != null; - assert getCores(hardware) > 0; - assert hardware.getVolumes().size() >= 0; - assert hardware.getRam() > 0; + assert hardware.getProviderId() != null : hardware; + assert getCores(hardware) > 0 : hardware; + assert hardware.getVolumes().size() >= 0 : hardware; + assert hardware.getRam() > 0 : hardware; assertEquals(hardware.getType(), ComputeType.HARDWARE); } } @@ -637,7 +638,7 @@ public abstract class BaseComputeServiceLiveTest { assertEquals(hello.getOutput().trim(), "hello"); ExecResponse exec = ssh.exec("java -version"); assert exec.getError().indexOf("1.6") != -1 || exec.getOutput().indexOf("1.6") != -1 : exec + "\n" - + ssh.exec("cat /tmp/bootstrap/stdout.log /tmp/bootstrap/stderr.log"); + + ssh.exec("cat /tmp/bootstrap/stdout.log /tmp/bootstrap/stderr.log"); } finally { if (ssh != null) ssh.disconnect(); diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index 1d0f88031a..c393d92700 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -167,7 +167,7 @@ public abstract class BaseTemplateBuilderLiveTest { Template defaultTemplate = context.getComputeService().templateBuilder().build(); Template template = context.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId()) - .build(); + .locationId(defaultTemplate.getLocation().getId()).build(); assertEquals(template.getImage(), defaultTemplate.getImage()); } diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index d1d3527fb9..08ac377dbb 100755 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -743,34 +743,7 @@ public class RestAnnotationProcessor { || TypeLiteral.get(method.getGenericReturnType()).equals(futureHttpResponseLiteral)) { return Key.get((Class) IdentityFunction.class); } else if (getAcceptHeadersOrNull(method).contains(MediaType.APPLICATION_JSON)) { - Type returnVal; - if (method.getReturnType().getTypeParameters().length == 0) { - returnVal = method.getReturnType(); - } else if (method.getReturnType().equals(ListenableFuture.class)) { - ParameterizedType futureType = ((ParameterizedType) method.getGenericReturnType()); - returnVal = futureType.getActualTypeArguments()[0]; - if (returnVal instanceof WildcardType) - returnVal = WildcardType.class.cast(returnVal).getUpperBounds()[0]; - } else { - returnVal = method.getGenericReturnType(); - } - ParameterizedType parserType; - if (method.isAnnotationPresent(Unwrap.class)) { - int depth = method.getAnnotation(Unwrap.class).depth(); - Class edgeCollection = method.getAnnotation(Unwrap.class).edgeCollection(); - if (depth == 1 && edgeCollection == Map.class) - parserType = Types.newParameterizedType(UnwrapOnlyJsonValue.class, returnVal); - else if (depth == 2 && edgeCollection == Map.class) - parserType = Types.newParameterizedType(UnwrapOnlyNestedJsonValue.class, returnVal); - else if (depth == 3 && edgeCollection == Set.class) - parserType = Types.newParameterizedType(UnwrapOnlyNestedJsonValueInSet.class, returnVal); - else - throw new IllegalStateException(String.format( - "depth(%d) edgeCollection(%s) not yet supported for @Unwrap", depth, edgeCollection)); - } else { - parserType = Types.newParameterizedType(ParseJson.class, returnVal); - } - return (Key>) Key.get(parserType); + return getJsonParserKeyForMethod(method); } else if (method.getReturnType().equals(String.class) || TypeLiteral.get(method.getGenericReturnType()).equals(futureStringLiteral)) { return Key.get(ReturnStringIf2xx.class); @@ -784,6 +757,47 @@ public class RestAnnotationProcessor { return Key.get(annotation.value()); } + public static Key> getJsonParserKeyForMethod(Method method) { + Type returnVal = getReturnTypeForMethod(method); + return getJsonParserKeyForMethodAnType(method, returnVal); + } + + public static Type getReturnTypeForMethod(Method method) { + Type returnVal; + if (method.getReturnType().getTypeParameters().length == 0) { + returnVal = method.getReturnType(); + } else if (method.getReturnType().equals(ListenableFuture.class)) { + ParameterizedType futureType = ((ParameterizedType) method.getGenericReturnType()); + returnVal = futureType.getActualTypeArguments()[0]; + if (returnVal instanceof WildcardType) + returnVal = WildcardType.class.cast(returnVal).getUpperBounds()[0]; + } else { + returnVal = method.getGenericReturnType(); + } + return returnVal; + } + + @SuppressWarnings( { "unchecked", "rawtypes" }) + public static Key> getJsonParserKeyForMethodAnType(Method method, Type returnVal) { + ParameterizedType parserType; + if (method.isAnnotationPresent(Unwrap.class)) { + int depth = method.getAnnotation(Unwrap.class).depth(); + Class edgeCollection = method.getAnnotation(Unwrap.class).edgeCollection(); + if (depth == 1 && edgeCollection == Map.class) + parserType = Types.newParameterizedType(UnwrapOnlyJsonValue.class, returnVal); + else if (depth == 2 && edgeCollection == Map.class) + parserType = Types.newParameterizedType(UnwrapOnlyNestedJsonValue.class, returnVal); + else if (depth == 3 && edgeCollection == Set.class) + parserType = Types.newParameterizedType(UnwrapOnlyNestedJsonValueInSet.class, returnVal); + else + throw new IllegalStateException(String.format("depth(%d) edgeCollection(%s) not yet supported for @Unwrap", + depth, edgeCollection)); + } else { + parserType = Types.newParameterizedType(ParseJson.class, returnVal); + } + return (Key>) Key.get(parserType); + } + public static Class> getSaxResponseParserClassOrNull(Method method) { XMLResponseParser annotation = method.getAnnotation(XMLResponseParser.class); if (annotation != null) { diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 664ee1076a..27b3da4a8f 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -126,8 +126,8 @@ openhosting-east1.contextbuilder=org.jclouds.openhosting.OpenHostingEast1Context cloudsigma-zrh.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaZurichPropertiesBuilder cloudsigma-zrh.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder -ibmdev.propertiesbuilder=org.jclouds.ibmdev.IBMDeveloperCloudPropertiesBuilder -ibmdev.contextbuilder=org.jclouds.ibmdev.IBMDeveloperCloudContextBuilder +ibm-smartcloud.propertiesbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudPropertiesBuilder +ibm-smartcloud.contextbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudContextBuilder stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder # example of where to change your endpoint diff --git a/core/src/test/java/org/jclouds/json/BaseParserTest.java b/core/src/test/java/org/jclouds/json/BaseParserTest.java index c9fd77926e..423099f4e0 100644 --- a/core/src/test/java/org/jclouds/json/BaseParserTest.java +++ b/core/src/test/java/org/jclouds/json/BaseParserTest.java @@ -20,18 +20,24 @@ package org.jclouds.json; import static org.testng.Assert.assertEquals; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; +import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; +import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; import com.google.common.base.Function; +import com.google.common.base.Throwables; import com.google.inject.Guice; import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; -import com.google.inject.util.Types; /** * @@ -39,22 +45,41 @@ import com.google.inject.util.Types; */ public abstract class BaseParserTest { + @Retention(value = RetentionPolicy.RUNTIME) + @Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) + @Qualifier + public @interface Nested { + + } + + @SuppressWarnings("unchecked") + protected Function parser(Injector i) { + try { + return (Function) i.getInstance(RestAnnotationProcessor.getJsonParserKeyForMethod(getClass() + .getMethod("expected"))); + } catch (Exception e) { + Throwables.propagate(e); + return null; + } + } + @Test public void test() { - T expects = expected(); - - Function parser = getParser(getInjector()); - T response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(getClass() - .getResourceAsStream(resource())))); + Function parser = parser(injector()); + T response = parser.apply(new HttpResponse(200, "ok", payload())); compare(expects, response); } + protected Payload payload() { + return Payloads.newInputStreamPayload(getClass().getResourceAsStream(resource())); + } + public void compare(T expects, T response) { assertEquals(response.toString(), expects.toString()); } - protected Injector getInjector() { + protected Injector injector() { return Guice.createInjector(new GsonModule() { @Override @@ -67,15 +92,9 @@ public abstract class BaseParserTest { } - @SuppressWarnings("unchecked") - protected Function getParser(Injector i) { - return (Function) i.getInstance(Key.get(TypeLiteral.get( - Types.newParameterizedType(UnwrapOnlyNestedJsonValue.class, type())).getType())); + protected String resource() { + throw new IllegalStateException("please define resource such as \"/testaddresses.json\""); } - public abstract Class type(); - - public abstract String resource(); - public abstract T expected(); } diff --git a/core/src/test/java/org/jclouds/json/BaseSetParserTest.java b/core/src/test/java/org/jclouds/json/BaseSetParserTest.java index b966abd745..a781cc3219 100644 --- a/core/src/test/java/org/jclouds/json/BaseSetParserTest.java +++ b/core/src/test/java/org/jclouds/json/BaseSetParserTest.java @@ -22,15 +22,7 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; - -import com.google.common.base.Function; import com.google.common.collect.ImmutableSortedSet; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; -import com.google.inject.util.Types; /** * @@ -38,15 +30,6 @@ import com.google.inject.util.Types; */ public abstract class BaseSetParserTest extends BaseParserTest, T> { - @SuppressWarnings("unchecked") - // crazy stuff due to type erasure - @Override - protected Function> getParser(Injector i) { - return (Function>) i.getInstance(Key.get(TypeLiteral.get( - Types.newParameterizedType(UnwrapOnlyNestedJsonValue.class, Types - .newParameterizedType(Set.class, type()))).getType())); - } - public void compare(Set expects, Set response) { assertEquals(ImmutableSortedSet.copyOf(response).toString(), ImmutableSortedSet.copyOf(expects).toString()); } diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java index e93fcae313..44dffb8673 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java @@ -39,11 +39,6 @@ import com.google.inject.Injector; @Test(groups = "unit") public class UnwrapLoadBalancerTest extends BaseItemParserTest { - @Override - public Class type() { - return LoadBalancer.class; - } - @Override public String resource() { return "/getloadbalancer.json"; @@ -73,7 +68,7 @@ public class UnwrapLoadBalancerTest extends BaseItemParserTest { } @Override - protected Function getParser(Injector i) { + protected Function parser(Injector i) { return i.getInstance(UnwrapLoadBalancer.class).setRegion("DFW"); } } diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java index 9a55b7a3fb..c34aa7c3ba 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java @@ -39,11 +39,6 @@ import com.google.inject.Injector; @Test(groups = "unit") public class UnwrapLoadBalancersTest extends BaseSetParserTest { - @Override - public Class type() { - return LoadBalancer.class; - } - @Override public String resource() { return "/listloadbalancers.json"; @@ -70,7 +65,7 @@ public class UnwrapLoadBalancersTest extends BaseSetParserTest { } @Override - protected Function> getParser(Injector i) { + protected Function> parser(Injector i) { return i.getInstance(UnwrapLoadBalancers.class).setRegion("DFW"); } } diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java index cf724aaaf6..d0f807fe47 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java @@ -28,6 +28,7 @@ import org.jclouds.cloudstack.domain.Account.Type; 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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -40,8 +41,9 @@ import com.google.inject.Injector; */ @Test(groups = "unit") public class ListAccountsResponseTest extends BaseSetParserTest { + @Override - protected Injector getInjector() { + protected Injector injector() { return Guice.createInjector(new CloudStackParserModule(), new GsonModule() { @Override @@ -54,17 +56,13 @@ public class ListAccountsResponseTest extends BaseSetParserTest { } - @Override - public Class type() { - return Account.class; - } - @Override public String resource() { return "/listaccountsresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet. of(Account .builder() diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListCapabilitiesResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListCapabilitiesResponseTest.java index cadd85ba81..af47962e3f 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListCapabilitiesResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListCapabilitiesResponseTest.java @@ -20,6 +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.testng.annotations.Test; /** @@ -29,17 +30,13 @@ import org.testng.annotations.Test; @Test(groups = "unit") public class ListCapabilitiesResponseTest extends BaseItemParserTest { - @Override - public Class type() { - return Capabilities.class; - } - @Override public String resource() { return "/listcapabilitiesresponse.json"; } @Override + @Unwrap(depth = 2) public Capabilities expected() { return Capabilities.builder().securityGroupsEnabled(true).sharedTemplatesEnabled(true).cloudStackVersion("2.2") .build(); diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListDiskOfferingsResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListDiskOfferingsResponseTest.java index abc60c8e72..84374214b5 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListDiskOfferingsResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListDiskOfferingsResponseTest.java @@ -23,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -34,17 +35,13 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListDiskOfferingsResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return DiskOffering.class; - } - @Override public String resource() { return "/listdiskofferingsresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet. of( DiskOffering.builder().id(3).domainId(1).domain("ROOT").name("Small").displayText("Small Disk, 5 GB") diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHypervisorsResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHypervisorsResponseTest.java index 4789abdc8a..7327b40efd 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHypervisorsResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHypervisorsResponseTest.java @@ -36,11 +36,6 @@ import com.google.inject.Injector; @Test(groups = "unit") public class ListHypervisorsResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return String.class; - } - @Override public String resource() { return "/listhypervisorsresponse.json"; @@ -52,7 +47,7 @@ public class ListHypervisorsResponseTest extends BaseSetParserTest { } @Override - protected Function> getParser(Injector injector) { + protected Function> parser(Injector injector) { return injector.getInstance(ParseNamesFromHttpResponse.class); } } diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworkOfferingsResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworkOfferingsResponseTest.java index f4239adfa0..5aa82177bb 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworkOfferingsResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworkOfferingsResponseTest.java @@ -23,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -34,17 +35,13 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListNetworkOfferingsResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return NetworkOffering.class; - } - @Override public String resource() { return "/listnetworkofferingsresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet. of( NetworkOffering.builder().id(7).name("DefaultDirectNetworkOffering").displayText("Direct") diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworksResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworksResponseTest.java index 590de865c1..f552794b45 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworksResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListNetworksResponseTest.java @@ -26,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -41,17 +42,13 @@ import com.google.common.collect.ImmutableSortedSet; @Test(groups = "unit") public class ListNetworksResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return Network.class; - } - @Override public String resource() { return "/listnetworksresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet . of(Network diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSCategoriesResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSCategoriesResponseTest.java index 8723068115..4dfae11817 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSCategoriesResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSCategoriesResponseTest.java @@ -49,13 +49,7 @@ public class ListOSCategoriesResponseTest extends BaseItemParserTest> getParser(Injector injector) { + protected Function> parser(Injector injector) { return injector.getInstance(ParseIdToNameFromHttpResponse.class); } - - @SuppressWarnings( { "unchecked", "rawtypes" }) - @Override - public Class> type() { - return (Class) Map.class; - } } diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSTypesResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSTypesResponseTest.java index e78735c083..091c806403 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSTypesResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListOSTypesResponseTest.java @@ -19,9 +19,12 @@ package org.jclouds.cloudstack.parse; import java.util.Set; + import org.jclouds.cloudstack.domain.OSType; import org.jclouds.json.BaseSetParserTest; +import org.jclouds.rest.annotations.Unwrap; import org.testng.annotations.Test; + import com.google.common.collect.ImmutableSet; /** @@ -30,17 +33,14 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "unit") public class ListOSTypesResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return OSType.class; - } - + @Override public String resource() { return "/listostypesresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet. builder().add( OSType.builder().id(69).OSCategoryId(7).description("Asianux 3(32-bit)").build()).add( diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPortForwardingRulesResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPortForwardingRulesResponseTest.java index 114213b148..0712f81db2 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPortForwardingRulesResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPortForwardingRulesResponseTest.java @@ -22,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -33,17 +34,13 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListPortForwardingRulesResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return PortForwardingRule.class; - } - @Override public String resource() { return "/listportforwardingrulesresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet. of( PortForwardingRule.builder().id(15).privatePort(22).protocol("tcp").publicPort(2022).virtualMachineId(3) diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPublicIPAddressesResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPublicIPAddressesResponseTest.java index 298fa7efe1..de8281871d 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPublicIPAddressesResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListPublicIPAddressesResponseTest.java @@ -23,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -34,17 +35,14 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListPublicIPAddressesResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return PublicIPAddress.class; - } @Override public String resource() { return "/listpublicipaddressesresponse.json"; } - + @Override + @Unwrap(depth = 2) public Set 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) diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListSecurityGroupsResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListSecurityGroupsResponseTest.java index 3959c2f721..3848613348 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListSecurityGroupsResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListSecurityGroupsResponseTest.java @@ -23,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -34,17 +35,13 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListSecurityGroupsResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return SecurityGroup.class; - } - @Override public String resource() { return "/listsecuritygroupsresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet . builder() diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListServiceOfferingsResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListServiceOfferingsResponseTest.java index 591d2028e9..55ae22a4f9 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListServiceOfferingsResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListServiceOfferingsResponseTest.java @@ -24,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -35,17 +36,13 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListServiceOfferingsResponseTest extends BaseSetParserTest { - @Override - public Class type() { - return ServiceOffering.class; - } - @Override public String resource() { return "/listserviceofferingsresponse.json"; } @Override + @Unwrap(depth = 2) public Set expected() { return ImmutableSet. of( ServiceOffering.builder().id(1).name("Small Instance") diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListTemplatesResponseTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListTemplatesResponseTest.java index 3811c8eb45..80ff5b544c 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListTemplatesResponseTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListTemplatesResponseTest.java @@ -25,6 +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.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -36,11 +37,6 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class ListTemplatesResponseTest extends BaseSetParserTest