You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2013/09/16 10:06:06 UTC

git commit: JCLOUDS-277: Made the description in org.jclouds.compute.domain.Image nullable

Updated Branches:
  refs/heads/master b2016703a -> 1fc5806ec


JCLOUDS-277: Made the description in org.jclouds.compute.domain.Image nullable


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

Branch: refs/heads/master
Commit: 1fc5806ec9fdae248b9e7de5267d52eb8b09d193
Parents: b201670
Author: JoshVote <jj...@gmail.com>
Authored: Tue Sep 10 16:22:04 2013 +0800
Committer: Andrew Phillips <an...@apache.org>
Committed: Mon Sep 16 09:05:28 2013 +0100

----------------------------------------------------------------------
 .../java/org/jclouds/compute/domain/Image.java  |  2 +
 .../jclouds/compute/domain/ImageBuilder.java    |  4 +-
 .../compute/domain/internal/ImageImpl.java      |  4 +-
 .../compute/domain/ImageBuilderTest.java        | 42 ++++++++++++++++++++
 4 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1fc5806e/compute/src/main/java/org/jclouds/compute/domain/Image.java
----------------------------------------------------------------------
diff --git a/compute/src/main/java/org/jclouds/compute/domain/Image.java b/compute/src/main/java/org/jclouds/compute/domain/Image.java
index c7b4210..260b4a7 100644
--- a/compute/src/main/java/org/jclouds/compute/domain/Image.java
+++ b/compute/src/main/java/org/jclouds/compute/domain/Image.java
@@ -18,6 +18,7 @@ package org.jclouds.compute.domain;
 
 import org.jclouds.compute.domain.internal.ImageImpl;
 import org.jclouds.domain.LoginCredentials;
+import org.jclouds.javax.annotation.Nullable;
 
 import com.google.common.annotations.Beta;
 import com.google.inject.ImplementedBy;
@@ -68,6 +69,7 @@ public interface Image extends ComputeMetadataIncludingStatus<Image.Status> {
    /**
     * Description of the image.
     */
+   @Nullable
    String getDescription();
 
    /**

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1fc5806e/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java
----------------------------------------------------------------------
diff --git a/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java
index a35bd93..3c19c0c 100644
--- a/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java
+++ b/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java
@@ -62,8 +62,8 @@ public class ImageBuilder extends ComputeMetadataBuilder {
       return this;
    }
 
-   public ImageBuilder description(String description) {
-      this.description = checkNotNull(description, "description");
+   public ImageBuilder description(@Nullable String description) {
+      this.description = description;
       return this;
    }
 

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1fc5806e/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java
----------------------------------------------------------------------
diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java
index ddb23df..7de3c77 100644
--- a/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java
+++ b/compute/src/main/java/org/jclouds/compute/domain/internal/ImageImpl.java
@@ -46,14 +46,14 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
 
    public ImageImpl(String providerId, String name, String id, Location location, URI uri,
             Map<String, String> userMetadata, Set<String> tags, OperatingSystem operatingSystem, Image.Status status,
-            @Nullable String backendStatus, String description, @Nullable String version,
+            @Nullable String backendStatus, @Nullable String description, @Nullable String version,
             @Nullable LoginCredentials defaultCredentials) {
       super(ComputeType.IMAGE, providerId, name, id, location, uri, userMetadata, tags);
       this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem");
       this.status = checkNotNull(status, "status");
       this.backendStatus = backendStatus;
       this.version = version;
-      this.description = checkNotNull(description, "description");
+      this.description = description;
       this.defaultCredentials = defaultCredentials;
    }
 

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1fc5806e/compute/src/test/java/org/jclouds/compute/domain/ImageBuilderTest.java
----------------------------------------------------------------------
diff --git a/compute/src/test/java/org/jclouds/compute/domain/ImageBuilderTest.java b/compute/src/test/java/org/jclouds/compute/domain/ImageBuilderTest.java
new file mode 100644
index 0000000..c1f60d8
--- /dev/null
+++ b/compute/src/test/java/org/jclouds/compute/domain/ImageBuilderTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.compute.domain;
+
+import static org.testng.Assert.assertNull;
+
+import org.jclouds.compute.domain.Image.Status;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for org.jclouds.compute.domain.ImageBuilder
+ *
+ */
+@Test(testName = "ImageBuilderTest")
+public class ImageBuilderTest {
+    
+    /**
+     * Ensures that an explicitly set null Image description results in no errors.
+     */
+    public void testNullDescription() {
+        Image img = new ImageBuilder().id("test-id")
+                .description(null)
+                .status(Status.AVAILABLE)
+                .operatingSystem(new OperatingSystem(OsFamily.CLOUD_LINUX, null, null, null, "os-description", true))
+                .build();
+        assertNull(img.getDescription());
+    }
+}