mirror of https://github.com/apache/jclouds.git
JCLOUDS-277: Made the description in org.jclouds.compute.domain.Image nullable
This commit is contained in:
parent
b2016703ad
commit
1fc5806ec9
|
@ -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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue