mirror of https://github.com/apache/jclouds.git
Issue 830: Fix get/modifyOperatingSystemSection tests
This commit is contained in:
parent
f90135097f
commit
2af8ec527f
|
@ -28,6 +28,8 @@ public class VCloudDirectorConstants {
|
|||
/** The XML namespace used by the clients. */
|
||||
public static final String VCLOUD_1_5_NS = "http://www.vmware.com/vcloud/v1.5";
|
||||
|
||||
public static final String VCLOUD_VMW_NS = "ihttp://www.vmware.com/schema/ovf";
|
||||
|
||||
public static final String VCLOUD_OVF_NS = "http://schemas.dmtf.org/ovf/envelope/1";
|
||||
|
||||
public static final String VCLOUD_OVF_ENV_NS = "http://schemas.dmtf.org/ovf/environment/1";
|
||||
|
|
|
@ -18,11 +18,24 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain.ovf;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* An OperatingSystemSection specifies the operating system installed on a virtual machine.
|
||||
|
@ -48,6 +61,10 @@ public class OperatingSystemSection extends SectionType {
|
|||
private Integer id;
|
||||
private String description;
|
||||
private String version;
|
||||
private String osType;
|
||||
private URI href;
|
||||
private String type;
|
||||
private Set<Link> links;
|
||||
|
||||
/**
|
||||
* @see OperatingSystemSection#getId()
|
||||
|
@ -73,6 +90,48 @@ public class OperatingSystemSection extends SectionType {
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OperatingSystemSection#getOsType()
|
||||
*/
|
||||
public B osType(String osType) {
|
||||
this.osType = osType;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OperatingSystemSection#getHref()
|
||||
*/
|
||||
public B href(URI href) {
|
||||
this.href = href;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OperatingSystemSection#getType()
|
||||
*/
|
||||
public B type(String type) {
|
||||
this.type = type;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OperatingSystemSection#getLinks()
|
||||
*/
|
||||
public B links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
public B link(Link link) {
|
||||
if (links == null)
|
||||
links = Sets.newLinkedHashSet();
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -82,22 +141,35 @@ public class OperatingSystemSection extends SectionType {
|
|||
}
|
||||
|
||||
public B fromOperatingSystemSection(OperatingSystemSection in) {
|
||||
return id(in.getId()).info(in.getInfo()).description(in.getDescription());
|
||||
return fromSectionType(in).id(in.getId()).version(in.getVersion()).description(in.getDescription())
|
||||
.osType(in.getOsType()).href(in.getHref()).type(in.getType()).links(in.getLinks());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
@XmlAttribute(required = true)
|
||||
protected Integer id;
|
||||
@XmlAttribute
|
||||
protected String version;
|
||||
@XmlElement
|
||||
protected String description;
|
||||
@XmlAttribute(namespace = VCLOUD_VMW_NS)
|
||||
protected String osType;
|
||||
@XmlAttribute(namespace = VCLOUD_1_5_NS)
|
||||
private URI href;
|
||||
@XmlAttribute(namespace = VCLOUD_1_5_NS)
|
||||
private String type;
|
||||
@XmlElement(name = "Link", namespace = VCLOUD_1_5_NS)
|
||||
private Set<Link> links;
|
||||
|
||||
public OperatingSystemSection(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.id = builder.id;
|
||||
this.description = builder.description;
|
||||
this.version = builder.version;
|
||||
this.osType = builder.osType;
|
||||
this.href = builder.href;
|
||||
this.type = builder.type;
|
||||
this.links = builder.links;
|
||||
}
|
||||
|
||||
protected OperatingSystemSection() {
|
||||
|
@ -105,29 +177,65 @@ public class OperatingSystemSection extends SectionType {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ovf id
|
||||
* Gets the OVF id
|
||||
*
|
||||
* @see org.jclouds.vcloud.director.v1_5.domain.cim.OSType#getCode()
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return description or null
|
||||
* Gets the description or null
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the osType
|
||||
*/
|
||||
public String getOsType() {
|
||||
return osType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the URI to the entity.
|
||||
*
|
||||
* @see ResourceType#getHref()
|
||||
*/
|
||||
public URI getHref() {
|
||||
return href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the type of the the entity.
|
||||
*
|
||||
* @see ResourceType#getType()
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of optional links to an entity or operation associated with this object.
|
||||
*
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
public Set<Link> getLinks() {
|
||||
return links == null ? ImmutableSet.<Link>of() : Collections.unmodifiableSet(links);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), description);
|
||||
return Objects.hashCode(super.hashCode(), id, version, description, osType, href, type, links);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,13 +244,15 @@ public class OperatingSystemSection extends SectionType {
|
|||
if (obj == null) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
|
||||
OperatingSystemSection other = (OperatingSystemSection) obj;
|
||||
return super.equals(other) && Objects.equal(description, other.description);
|
||||
OperatingSystemSection that = (OperatingSystemSection) obj;
|
||||
return super.equals(that) &&
|
||||
equal(this.id, that.id) && equal(this.version, that.version) && equal(this.description, that.description) &&
|
||||
equal(this.osType, that.osType) && equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Objects.ToStringHelper string() {
|
||||
return super.string().add("description", description);
|
||||
return super.string().add("id", id).add("version", version).add("description", description).add("osType", osType)
|
||||
.add("href", href).add("links", links).add("type", type);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
|
|||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
|
||||
|
@ -41,6 +42,7 @@ import com.google.common.base.Objects;
|
|||
* @author Adrian Cole
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@XmlType(name = "Section_Type")
|
||||
@XmlSeeAlso({
|
||||
CustomizationSection.class,
|
||||
DeploymentOptionSection.class,
|
||||
|
@ -85,6 +87,22 @@ public abstract class SectionType {
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SectionType#isRequired()
|
||||
*/
|
||||
public B required() {
|
||||
this.required = Boolean.TRUE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SectionType#isRequired()
|
||||
*/
|
||||
public B notRequired() {
|
||||
this.required = Boolean.FALSE;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B fromSectionType(SectionType in) {
|
||||
return info(in.getInfo()).required(in.isRequired());
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.vcloud.director.v1_5.domain.ovf;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -54,14 +55,22 @@ public class StartupSection extends SectionType {
|
|||
|
||||
public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
|
||||
|
||||
private List<StartupSectionItem> item = Collections.emptyList();
|
||||
private List<StartupSectionItem> items = Collections.emptyList();
|
||||
private List<Object> any = Collections.emptyList();
|
||||
|
||||
/**
|
||||
* @see StartupSection#getItem()
|
||||
*/
|
||||
public B item(List<StartupSectionItem> item) {
|
||||
this.item = item;
|
||||
public B items(List<StartupSectionItem> items) {
|
||||
this.items = checkNotNull(items, "items");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see StartupSection#getItem()
|
||||
*/
|
||||
public B item(StartupSectionItem item) {
|
||||
this.items.add(checkNotNull(item, "item"));
|
||||
return self();
|
||||
}
|
||||
|
||||
|
@ -79,7 +88,7 @@ public class StartupSection extends SectionType {
|
|||
}
|
||||
|
||||
public B fromStartupSection(StartupSection in) {
|
||||
return fromSectionType(in).item(item).any(any);
|
||||
return fromSectionType(in).items(items).any(any);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +103,7 @@ public class StartupSection extends SectionType {
|
|||
|
||||
public StartupSection(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.items = (items != null) ? ImmutableList.<StartupSectionItem>copyOf(builder.item) : Collections.<StartupSectionItem>emptyList();
|
||||
this.items = (items != null) ? ImmutableList.<StartupSectionItem>copyOf(builder.items) : Collections.<StartupSectionItem>emptyList();
|
||||
this.any = (any != null) ? ImmutableList.<Object>copyOf(builder.any) : Collections.<Object>emptyList();
|
||||
}
|
||||
|
||||
|
@ -130,6 +139,6 @@ public class StartupSection extends SectionType {
|
|||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("item", items).add("any", any);
|
||||
return super.string().add("items", items).add("any", any);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ public interface VAppAsyncClient {
|
|||
* @see VAppClient#modifyNetworkConnectionSection(URI, NetworkConnectionSection)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/networkConfigSection")
|
||||
@Path("/networkConnectionSection")
|
||||
@Produces(NETWORK_CONFIG_SECTION)
|
||||
@Consumes(TASK)
|
||||
@JAXBResponseParser
|
||||
|
|
|
@ -480,6 +480,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
GuestCustomizationSection oldSection = vAppClient.getGuestCustomizationSection(vmURI);
|
||||
GuestCustomizationSection newSection = oldSection.toBuilder()
|
||||
.computerName("newComputerName")
|
||||
.adminPassword(null) // Not allowed
|
||||
.build();
|
||||
|
||||
// The method under test
|
||||
|
@ -689,6 +690,8 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.info("Changed OperatingSystemSection Description")
|
||||
.description("Changed OperatingSystemSection Description")
|
||||
.build();
|
||||
debug(newSection);
|
||||
assertNotNull(newSection.getId());
|
||||
|
||||
// The method under test
|
||||
Task modifyOperatingSystemSection = vAppClient.modifyOperatingSystemSection(vmURI, newSection);
|
||||
|
|
Loading…
Reference in New Issue