Repository: jclouds
Updated Branches:
  refs/heads/master 59a0014bd -> 042074169


JCLOUDS-1102: Fix. Rackspace returns a new structure for volume types.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/74a2a268
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/74a2a268
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/74a2a268

Branch: refs/heads/master
Commit: 74a2a2683f27f69f996aa2f63fca5bed125e3677
Parents: 59a0014
Author: Oleg <[email protected]>
Authored: Wed Mar 30 23:52:27 2016 +0300
Committer: Ignasi Barrera <[email protected]>
Committed: Fri Apr 1 14:48:12 2016 +0200

----------------------------------------------------------------------
 .../openstack/cinder/v1/domain/VolumeType.java  | 28 +++++++++++---------
 .../v1/features/VolumeTypeApiExpectTest.java    | 17 +++++++++++-
 .../test/resources/volume_type_list_simple.json | 18 +++++++++++++
 3 files changed, 50 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/74a2a268/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/domain/VolumeType.java
----------------------------------------------------------------------
diff --git 
a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/domain/VolumeType.java
 
b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/domain/VolumeType.java
index 596b984..6990381 100644
--- 
a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/domain/VolumeType.java
+++ 
b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/domain/VolumeType.java
@@ -16,20 +16,18 @@
  */
 package org.jclouds.openstack.cinder.v1.domain;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import org.jclouds.javax.annotation.Nullable;
 
+import javax.inject.Named;
 import java.beans.ConstructorProperties;
 import java.util.Date;
 import java.util.Map;
 
-import javax.inject.Named;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
  * An Openstack Cinder Volume Type.
@@ -89,7 +87,10 @@ public class VolumeType {
        * @see VolumeType#getExtraSpecs()
        */
       public T extraSpecs(Map<String, String> extraSpecs) {
-         this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, 
"extraSpecs"));     
+         if (extraSpecs != null)
+         {
+            this.extraSpecs = ImmutableMap.copyOf(extraSpecs);
+         }
          return self();
       }
 
@@ -126,12 +127,15 @@ public class VolumeType {
    @ConstructorProperties({
       "id", "name", "created_at", "updated_at", "extra_specs"
    })
-   protected VolumeType(String id, String name, @Nullable Date created, 
@Nullable Date updated, Map<String, String> extraSpecs) {
+   protected VolumeType(String id, String name, @Nullable Date created, 
@Nullable Date updated, @Nullable Map<String, String> extraSpecs) {
       this.id = checkNotNull(id, "id");
       this.name = checkNotNull(name, "name");
       this.created = Optional.fromNullable(created);
       this.updated = Optional.fromNullable(updated);
-      this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, 
"extraSpecs"));     
+      if (extraSpecs == null)
+         this.extraSpecs = ImmutableMap.of();
+      else
+         this.extraSpecs = ImmutableMap.copyOf(extraSpecs);
    }
 
    public String getId() {

http://git-wip-us.apache.org/repos/asf/jclouds/blob/74a2a268/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git 
a/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApiExpectTest.java
 
b/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApiExpectTest.java
index 2166ef3..28b1e59 100644
--- 
a/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApiExpectTest.java
+++ 
b/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApiExpectTest.java
@@ -48,7 +48,7 @@ public class VolumeTypeApiExpectTest extends 
BaseCinderApiExpectTest {
       ).getVolumeTypeApi("RegionOne");
 
       Set<? extends VolumeType> types = api.list().toSet();
-      assertEquals(types, ImmutableSet.of(testVolumeType()));
+      assertEquals(types, testVolumeTypes());
    }
 
    public void testGetVolumeType() {
@@ -72,4 +72,19 @@ public class VolumeTypeApiExpectTest extends 
BaseCinderApiExpectTest {
             .extraSpecs(ImmutableMap.of("test", "value1", "test1", "wibble"))
             .build();
    }
+   public Set<VolumeType> testVolumeTypes() {
+      VolumeType firstVolumeType = testVolumeType();
+      VolumeType secondVolumeTypeWithEmptyExtraSpecs = VolumeType.builder()
+              .id("2")
+              .name("jclouds-test-2")
+              .created(dateService.iso8601SecondsDateParse("2012-05-10 
12:33:06"))
+              .build();
+      VolumeType thirdVolumeTypeWithNullableExtraSpecs = VolumeType.builder()
+              .id("3")
+              .name("jclouds-test-3")
+              .created(dateService.iso8601SecondsDateParse("2012-05-10 
12:33:06"))
+              .extraSpecs(null)
+              .build();
+      return ImmutableSet.of(firstVolumeType, 
secondVolumeTypeWithEmptyExtraSpecs, thirdVolumeTypeWithNullableExtraSpecs);
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/74a2a268/apis/openstack-cinder/src/test/resources/volume_type_list_simple.json
----------------------------------------------------------------------
diff --git 
a/apis/openstack-cinder/src/test/resources/volume_type_list_simple.json 
b/apis/openstack-cinder/src/test/resources/volume_type_list_simple.json
index 02eb792..ce7408c 100644
--- a/apis/openstack-cinder/src/test/resources/volume_type_list_simple.json
+++ b/apis/openstack-cinder/src/test/resources/volume_type_list_simple.json
@@ -11,6 +11,24 @@
             },
             "deleted_at": null,
             "id": 1
+        },
+        {
+            "name": "jclouds-test-2",
+            "deleted": false,
+            "created_at": "2012-05-10 12:33:06",
+            "updated_at": null,
+            "extra_specs": {},
+            "deleted_at": null,
+            "id": 2
+        },
+        {
+            "name": "jclouds-test-3",
+            "deleted": false,
+            "created_at": "2012-05-10 12:33:06",
+            "updated_at": null,
+            "extra_specs": null,
+            "deleted_at": null,
+            "id": 3
         }
     ]
 }

Reply via email to