Repository: jclouds Updated Branches: refs/heads/1.9.x 7016b040d -> b4624161a
Make links nullable Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/b4624161 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/b4624161 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/b4624161 Branch: refs/heads/1.9.x Commit: b4624161ae844e280b3cde5465e3b59f54eb3751 Parents: 7016b04 Author: Arvind Nadendla <[email protected]> Authored: Sat Jun 18 23:49:38 2016 -0700 Committer: Zack Shoylev <[email protected]> Committed: Mon Jun 20 18:13:08 2016 -0500 ---------------------------------------------------------------------- .../jclouds/openstack/v2_0/domain/Resource.java | 9 ++++--- .../parse/ParseExtensionListNormalTest.java | 26 ++++++++++-------- .../test/resources/extension_list_normal.json | 28 +++++++++++++++++--- .../src/test/resources/flavor_new.json | 3 +-- 4 files changed, 45 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/b4624161/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java index 1824835..df5231a 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java @@ -49,7 +49,7 @@ public class Resource implements Comparable<Resource> { protected String id; protected String name; - protected Set<Link> links = ImmutableSet.of(); + protected Set<Link> links; /** * @see Resource#getId() @@ -71,12 +71,12 @@ public class Resource implements Comparable<Resource> { * @see Resource#getLinks() */ public T links(Set<Link> links) { - this.links = ImmutableSet.copyOf(checkNotNull(links, "links")); + this.links = links == null ? null : ImmutableSet.copyOf(links); return self(); } public T links(Link... in) { - return links(ImmutableSet.copyOf(in)); + return links(in == null ? null : ImmutableSet.copyOf(in)); } public Resource build() { @@ -108,7 +108,7 @@ public class Resource implements Comparable<Resource> { protected Resource(String id, @Nullable String name, @Nullable Set<Link> links) { this.id = checkNotNull(id, "id"); this.name = name; - this.links = links == null ? ImmutableSet.<Link>of() : ImmutableSet.copyOf(checkNotNull(links, "links")); + this.links = links == null ? null : ImmutableSet.copyOf(links); } /** @@ -132,6 +132,7 @@ public class Resource implements Comparable<Resource> { /** * @return the links of the id address allocated to the new server */ + @Nullable public Set<Link> getLinks() { return this.links; } http://git-wip-us.apache.org/repos/asf/jclouds/blob/b4624161/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java index 8bdef8a..8a65a29 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java @@ -27,6 +27,7 @@ import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; import org.jclouds.openstack.v2_0.domain.Extension; +import org.jclouds.openstack.v2_0.domain.Link; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; @@ -47,22 +48,25 @@ public class ParseExtensionListNormalTest extends BaseSetParserTest<Extension> { @Consumes(MediaType.APPLICATION_JSON) public Set<Extension> expected() { return ImmutableSet.of( - Extension.builder().alias("os-keypairs").name("Keypairs") - .namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00")) - .description("Keypair Support").build(), - Extension.builder().alias("os-volumes").name("Volumes") - .namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00")) - .description("Volumes support").build(), + Extension.builder().alias("os-keypairs").name("Keypairs").namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00")).description("Keypair Support") + .links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).build()) + .build(), + Extension.builder().alias("os-volumes").name("Volumes").namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1")) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00")).description("Volumes support") + .links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1")).build()) + .build(), Extension.builder().alias("security_groups").name("SecurityGroups") .namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1")) .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00")) - .description("Security group support").build(), + .description("Security group support") + .links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1")).build()) + .build(), Extension.builder().alias("os-floating-ips").name("Floating_ips") .namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00")) - .description("Floating IPs support").build()); + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00")).description("Floating IPs support") + .links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1")).build()) + .build()); } protected Injector injector() { http://git-wip-us.apache.org/repos/asf/jclouds/blob/b4624161/apis/openstack-nova/src/test/resources/extension_list_normal.json ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/resources/extension_list_normal.json b/apis/openstack-nova/src/test/resources/extension_list_normal.json index 211338d..e672575 100644 --- a/apis/openstack-nova/src/test/resources/extension_list_normal.json +++ b/apis/openstack-nova/src/test/resources/extension_list_normal.json @@ -3,7 +3,12 @@ { "updated": "2011-08-08T00:00:00+00:00", "name": "Keypairs", - "links": [], + "links": [ + { + "rel": "self", + "href": "http://docs.openstack.org/ext/keypairs/api/v1.1" + } + ], "namespace": "http://docs.openstack.org/ext/keypairs/api/v1.1", "alias": "os-keypairs", "description": "Keypair Support" @@ -11,7 +16,12 @@ { "updated": "2011-03-25T00:00:00+00:00", "name": "Volumes", - "links": [], + "links": [ + { + "rel": "self", + "href": "http://docs.openstack.org/ext/volumes/api/v1.1" + } + ], "namespace": "http://docs.openstack.org/ext/volumes/api/v1.1", "alias": "os-volumes", "description": "Volumes support" @@ -19,7 +29,12 @@ { "updated": "2011-07-21T00:00:00+00:00", "name": "SecurityGroups", - "links": [], + "links": [ + { + "rel": "self", + "href": "http://docs.openstack.org/ext/securitygroups/api/v1.1" + } + ], "namespace": "http://docs.openstack.org/ext/securitygroups/api/v1.1", "alias": "security_groups", "description": "Security group support" @@ -27,7 +42,12 @@ { "updated": "2011-06-16T00:00:00+00:00", "name": "Floating_ips", - "links": [], + "links": [ + { + "rel": "self", + "href": "http://docs.openstack.org/ext/floating_ips/api/v1.1" + } + ], "namespace": "http://docs.openstack.org/ext/floating_ips/api/v1.1", "alias": "os-floating-ips", "description": "Floating IPs support" http://git-wip-us.apache.org/repos/asf/jclouds/blob/b4624161/apis/openstack-nova/src/test/resources/flavor_new.json ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/resources/flavor_new.json b/apis/openstack-nova/src/test/resources/flavor_new.json index 8208993..b3fd7a6 100644 --- a/apis/openstack-nova/src/test/resources/flavor_new.json +++ b/apis/openstack-nova/src/test/resources/flavor_new.json @@ -4,7 +4,6 @@ "name": "128 MB Server", "ram": 128, "disk": 10, - "vcpus": 1, - "links": [] + "vcpus": 1 } }
