Issue 830: Updates to VAppClientLiveTest and Checks, and changes to associated domain objects

This commit is contained in:
Andrew Donald Kennedy 2012-03-16 00:32:38 +00:00
parent a9bceb9027
commit 78b5a16e29
16 changed files with 1017 additions and 707 deletions

View File

@ -63,7 +63,7 @@ import com.google.common.collect.Sets;
* </pre>
*/
@XmlRootElement(name = "LeaseSettingsSection")
@XmlType(name = "LeaseSettingsSection")
@XmlType(name = "LeaseSettingsSectionType")
public class LeaseSettingsSection extends SectionType {
public static Builder<?> builder() {
@ -142,7 +142,6 @@ public class LeaseSettingsSection extends SectionType {
return self();
}
@Override
public LeaseSettingsSection build() {
return new LeaseSettingsSection(this);
@ -194,17 +193,14 @@ public class LeaseSettingsSection extends SectionType {
}
/**
* Gets the value of the link property.
* Gets the value of the links property.
*/
public Set<Link> getLinks() {
return Collections.unmodifiableSet(this.links);
return Collections.unmodifiableSet(links);
}
/**
* Gets the value of the deploymentLeaseInSeconds property.
*
* @return possible object is
* {@link Integer }
*/
public Integer getDeploymentLeaseInSeconds() {
return deploymentLeaseInSeconds;
@ -212,9 +208,6 @@ public class LeaseSettingsSection extends SectionType {
/**
* Gets the value of the storageLeaseInSeconds property.
*
* @return possible object is
* {@link Integer }
*/
public Integer getStorageLeaseInSeconds() {
return storageLeaseInSeconds;
@ -235,7 +228,7 @@ public class LeaseSettingsSection extends SectionType {
}
/**
* @return the value of the href property.
* Gets the value of the href property.
*/
public URI getHref() {
return href;
@ -243,9 +236,6 @@ public class LeaseSettingsSection extends SectionType {
/**
* Gets the value of the type property.
*
* @return possible object is
* {@link String }
*/
public String getType() {
return type;
@ -259,13 +249,13 @@ public class LeaseSettingsSection extends SectionType {
return false;
LeaseSettingsSection that = LeaseSettingsSection.class.cast(o);
return super.equals(that) &&
equal(links, that.links) &&
equal(deploymentLeaseInSeconds, that.deploymentLeaseInSeconds) &&
equal(storageLeaseInSeconds, that.storageLeaseInSeconds) &&
equal(deploymentLeaseExpiration, that.deploymentLeaseExpiration) &&
equal(storageLeaseExpiration, that.storageLeaseExpiration) &&
equal(href, that.href) &&
equal(type, that.type);
equal(this.links, that.links) &&
equal(this.deploymentLeaseInSeconds, that.deploymentLeaseInSeconds) &&
equal(this.storageLeaseInSeconds, that.storageLeaseInSeconds) &&
equal(this.deploymentLeaseExpiration, that.deploymentLeaseExpiration) &&
equal(this.storageLeaseExpiration, that.storageLeaseExpiration) &&
equal(this.href, that.href) &&
equal(this.type, that.type);
}
@Override

View File

@ -21,8 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
@ -35,8 +34,8 @@ import com.google.common.base.Objects;
* &lt;complexType name="ScreenTicket" /&gt;
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ScreenTicket")
@XmlRootElement(name = "ScreenTicket")
@XmlType(name = "ScreenTicketType")
public class ScreenTicket {
public static Builder builder() {

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -16,14 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.*;
import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
@ -32,20 +30,14 @@ import com.google.common.base.Objects;
* Represents vApp/VM undeployment parameters.
*
* <pre>
* &lt;complexType name="UndeployVAppParams">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="UndeployPowerAction" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;complexType name="UndeployVAppParamsType" /&gt;
* </pre>
*
* @author grkvlt@apache.org
* @since 0.9
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UndeployVAppParams")
@XmlRootElement(name = "UndeployVAppParams")
@XmlType(name = "UndeployVAppParamsType")
public class UndeployVAppParams {
public static Builder builder() {

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -16,38 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/**
* Represents vApp Template upload parameters.
* <p/>
* <p/>
* <p>Java class for UploadVAppTemplateParams complex type.
* <p/>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p/>
*
* <pre>
* &lt;complexType name="UploadVAppTemplateParams">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
* &lt;attribute name="transferFormat" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="manifestRequired" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;complexType name="UploadVAppTemplateParamsType" /&gt;
* </pre>
*
* @author grkvlt@apache.org
* @since 0.9
*/
@XmlType(name = "UploadVAppTemplateParams")
@XmlRootElement(name = "UploadVAppTemplateParams")
@XmlType(name = "UploadVAppTemplateParamsType")
public class UploadVAppTemplateParams extends ParamsType {
public static Builder<?> builder() {
return new ConcreteBuilder();

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Objects.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
@ -30,7 +31,7 @@ import com.google.common.base.Objects;
/**
* @author grkvlt@apache.org
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "VMWareTools")
@XmlType(name = "VMWareTools")
public class VMWareTools {

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -18,7 +18,6 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.ovf;
import javax.xml.bind.annotation.XmlRootElement;
/**

View File

@ -135,7 +135,7 @@ public abstract class SectionType {
if (getClass() != obj.getClass())
return false;
SectionType other = (SectionType) obj;
return Objects.equal(info, other.info) && Objects.equal(required, other.required);
return Objects.equal(this.info, other.info) && Objects.equal(this.required, other.required);
}
@Override

View File

@ -1,15 +1,25 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.08 at 02:47:44 PM GMT
//
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud.director.v1_5.domain.ovf;
import static com.google.common.base.Objects.equal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -74,7 +84,7 @@ public class StartupSection extends SectionType {
}
@XmlElement(name = "Item")
private List<StartupSectionItem> item;
private List<StartupSectionItem> items;
@XmlAnyElement(lax = true)
private List<Object> any;
@ -84,50 +94,22 @@ public class StartupSection extends SectionType {
public StartupSection(Builder<?> builder) {
super(builder);
this.item = (item != null) ? ImmutableList.<StartupSectionItem>copyOf(builder.item) : Collections.<StartupSectionItem>emptyList();
this.items = (items != null) ? ImmutableList.<StartupSectionItem>copyOf(builder.item) : Collections.<StartupSectionItem>emptyList();
this.any = (any != null) ? ImmutableList.<Object>copyOf(builder.any) : Collections.<Object>emptyList();
}
/**
* Gets the value of the item property.
* <p>
* This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned
* list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the item property.
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getItem().add(newItem);
* </pre>
* <p>
* Objects of the following type(s) are allowed in the list {@link StartupSectionItem }
*/
public List<StartupSectionItem> getItem() {
if (item == null) {
item = new ArrayList<StartupSectionItem>();
}
return this.item;
return items;
}
/**
* Gets the value of the any property.
* <p>
* This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned
* list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the any property.
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getAny().add(newItem);
* </pre>
* <p>
* Objects of the following type(s) are allowed in the list {@link Object } {@link Element }
*/
public List<Object> getAny() {
if (any == null) {
any = new ArrayList<Object>();
}
return this.any;
return any;
}
@Override
@ -138,16 +120,16 @@ public class StartupSection extends SectionType {
return false;
StartupSection that = StartupSection.class.cast(o);
return super.equals(that) &&
equal(this.item, that.item) && equal(this.any, that.any);
equal(this.items, that.items) && equal(this.any, that.any);
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), item, any);
return Objects.hashCode(super.hashCode(), items, any);
}
@Override
public ToStringHelper string() {
return super.string().add("item", item).add("any", any);
return super.string().add("item", items).add("any", any);
}
}

View File

@ -345,7 +345,7 @@ public interface VAppAsyncClient {
@Consumes(TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> ejectMedia(@EndpointParam URI vAppURI,
ListenableFuture<Task> ejectMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
@ -357,7 +357,7 @@ public interface VAppAsyncClient {
@Consumes(TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> insertMedia(@EndpointParam URI vAppURI,
ListenableFuture<Task> insertMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
@ -396,7 +396,7 @@ public interface VAppAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI vAppURI);
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyNetworkConnectionSection(URI, NetworkConnectionSection)
@ -407,7 +407,7 @@ public interface VAppAsyncClient {
@Consumes(TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> modifyNetworkConnectionSection(@EndpointParam URI vAppURI,
ListenableFuture<Task> modifyNetworkConnectionSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) NetworkConnectionSection section);
/**
@ -428,7 +428,7 @@ public interface VAppAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<OperatingSystemSection> getOperatingSystemSection(@EndpointParam URI vAppURI);
ListenableFuture<OperatingSystemSection> getOperatingSystemSection(@EndpointParam URI vmURI);
/**
* @see VAppClient#modifyOperatingSystemSection(URI, OperatingSystemSection)
@ -439,7 +439,7 @@ public interface VAppAsyncClient {
@Consumes(TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> modifyOperatingSystemSection(@EndpointParam URI vAppURI,
ListenableFuture<Task> modifyOperatingSystemSection(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) OperatingSystemSection section);
/**

View File

@ -420,7 +420,7 @@ public interface VAppClient {
*
* @since 0.9
*/
Task ejectMedia(URI vAppURI, MediaInsertOrEjectParams mediaParams);
Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* Inserts a media into a VM.
@ -431,7 +431,7 @@ public interface VAppClient {
*
* @since 0.9
*/
Task insertMedia(URI vAppURI, MediaInsertOrEjectParams mediaParams);
Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* @return synchronous access to {@link Metadata} features
@ -440,7 +440,7 @@ public interface VAppClient {
MetadataClient.Writeable getMetadataClient();
/**
* Retrieves the network configuration section of a VM.
* Retrieves the network config section of a vApp or vApp template.
*
* <pre>
* GET /vApp/{id}/networkConfigSection
@ -448,10 +448,10 @@ public interface VAppClient {
*
* @since 0.9
*/
NetworkConfigSection getNetworkConfigSection(URI vAppURI);
NetworkConfigSection getNetworkConfigSection(URI vmURI);
/**
* Modifies the network configuration section of a VM.
* Modifies the network config section of a vApp.
*
* <pre>
* PUT /vApp/{id}/networkConfigSection
@ -459,7 +459,7 @@ public interface VAppClient {
*
* @since 0.9
*/
Task modifyNetworkConfigSection(URI vAppURI, NetworkConfigSection section);
Task modifyNetworkConfigSection(URI vmURI, NetworkConfigSection section);
/**
* Retrieves the network connection section of a VM.
@ -470,7 +470,7 @@ public interface VAppClient {
*
* @since 0.9
*/
NetworkConnectionSection getNetworkConnectionSection(URI vAppURI);
NetworkConnectionSection getNetworkConnectionSection(URI vmURI);
/**
* Modifies the network connection section of a VM.
@ -481,10 +481,10 @@ public interface VAppClient {
*
* @since 0.9
*/
Task modifyNetworkConnectionSection(URI vAppURI, NetworkConnectionSection section);
Task modifyNetworkConnectionSection(URI vmURI, NetworkConnectionSection section);
/**
* Retrieves the network section of a VM.
* Retrieves the network section of a vApp or vApp template.
*
* <pre>
* GET /vApp/{id}/networkSection
@ -503,7 +503,7 @@ public interface VAppClient {
*
* @since 0.9
*/
OperatingSystemSection getOperatingSystemSection(URI vAppURI);
OperatingSystemSection getOperatingSystemSection(URI vmURI);
/**
* Modifies the operating system section of a VM.
@ -514,7 +514,7 @@ public interface VAppClient {
*
* @since 0.9
*/
Task modifyOperatingSystemSection(URI vAppURI, OperatingSystemSection section);
Task modifyOperatingSystemSection(URI vmURI, OperatingSystemSection section);
/**
* Retrieves the owner of a vApp.

View File

@ -20,27 +20,22 @@ package org.jclouds.vcloud.director.v1_5.predicates;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import com.google.common.base.Predicate;
/**
* Predicates handy when working with Reference Types
* Predicates for working with {@link Reference} collections.
*
* @author Adrian Cole
*/
public class ReferenceTypePredicates {
/**
* matches references of the given name
* Matches {@link Reference}s of the given name.
*
* @param <T>
* type of the ReferenceType, ex. {@link Link}
* @param name
* ex. {@code context.getApi().getCurrentSession().getOrg()}
* @param T type of the reference, for example {@link Link}
* @param name value of the name attribute of the referenced object
* @return predicate that will match references of the given name
*/
public static <T extends Reference> Predicate<T> nameEquals(final String name) {
@ -60,12 +55,10 @@ public class ReferenceTypePredicates {
}
/**
* matches references of the given type
* Matches {@link Reference}s of the given type.
*
* @param <T>
* type of the ReferenceType, ex. {@link Link}
* @param type
* ex. {@link VCloudDirectorMediaType#CATALOG}
* @param T type of the reference, for example {@link Link}
* @param type the media type string of the referenced object, for example {@link VCloudDirectorMediaType#CATALOG}
* @return predicate that will match references of the given type
* @see VCloudDirectorMediaType
*/

View File

@ -23,9 +23,15 @@ package org.jclouds.vcloud.director.v1_5;
*/
public class VCloudDirectorLiveTestConstants {
/* regular expressions for pattern matching */
public static final String MAC_ADDRESS_PATTERN = "^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$";
/* Error code 200 indicates success. */
public static final String OK = "ERR-200: ok";
/* Error codes from 100 to 199 reflect parsing and other errors in domain objects. */
/* Error codes from 100 to 199 reflect parsing and other errors in domain object fields and attributes. */
public static final String REF_REQ_LIVE = "ERR-101: %s reference required to perform live tests";
@ -53,7 +59,7 @@ public class VCloudDirectorLiveTestConstants {
public static final String TASK_COMPLETE_TIMELY = "ERR-113: Task %s should complete in a timely fashion";
public static final String NOT_NULL_OBJECT_FMT = "ERR-114: The %s field of the %s must not be null";
public static final String NOT_NULL_OBJ_FIELD_FMT = "ERR-114: The %s field of the %s must not be null";
public static final String NOT_EMPTY_OBJECT_FMT = "ERR-115: One or more %s fields of the %s must be present";
@ -74,6 +80,12 @@ public class VCloudDirectorLiveTestConstants {
public static final String OBJ_FIELD_CLONE = "ERR-123: %s %s must be a clone of \"%s\" (%s)";
public static final String OBJ_FIELD_EMPTY_TO_DELETE = "ERR-124: %s must have no %s to be deleted (%s)";
public static final String NOT_NULL_OBJ_FMT = "ERR-125: The %s object must not be null";
public static final String NOT_EMPTY_STRING_FMT = "ERR-126: The %s field must not be an empty string";
public static final String MATCHES_STRING_FMT = "ERR-127: The %s field must match the pattern \"%s\"";
/* Error codes from 300 to 399 reflect entities and their links and relationship errors. */

View File

@ -19,9 +19,13 @@
package org.jclouds.vcloud.director.v1_5.domain;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MAC_ADDRESS_PATTERN;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MATCHES_STRING_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_BE_WELL_FORMED_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_CONTAIN_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_EMPTY_STRING_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJ_FIELD_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJ_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_REQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
@ -56,7 +60,9 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.Network;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualSystem;
import org.jclouds.vcloud.director.v1_5.domain.ovf.environment.EnvironmentType;
@ -85,7 +91,7 @@ public class Checks {
public static void checkEntityType(EntityType entity) {
// Check required fields
assertNotNull(entity.getName(), String.format(NOT_NULL_OBJECT_FMT, "Name", "EntityType"));
assertNotNull(entity.getName(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Name", "EntityType"));
// Check optional fields
// NOTE description cannot be checked
@ -109,7 +115,7 @@ public class Checks {
public static void checkReferenceType(Reference reference, Collection<String> validTypes) {
// Check required fields
assertNotNull(reference.getHref(), String.format(NOT_NULL_OBJECT_FMT, "Href", "ReferenceType"));
assertNotNull(reference.getHref(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Href", "ReferenceType"));
// Check optional fields
String id = reference.getId();
@ -164,7 +170,7 @@ public class Checks {
public static void checkLink(Link link) {
// Check required fields
assertNotNull(link.getRel(), String.format(NOT_NULL_OBJECT_FMT, "Rel", "Link"));
assertNotNull(link.getRel(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Rel", "Link"));
assertTrue(Link.Rel.ALL.contains(link.getRel()), String.format(REQUIRED_VALUE_OBJECT_FMT, "Rel", "Link", link.getRel(), Iterables.toString(Link.Rel.ALL)));
// Check parent type
@ -173,7 +179,7 @@ public class Checks {
public static void checkTask(Task task) {
// Check required fields
assertNotNull(task.getStatus(), String.format(NOT_NULL_OBJECT_FMT, "Status", "Task"));
assertNotNull(task.getStatus(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Status", "Task"));
assertTrue(Task.Status.ALL.contains(task.getStatus()), String.format(REQUIRED_VALUE_OBJECT_FMT, "Status", "Task", task.getStatus(), Iterables.toString(Task.Status.ALL)));
// Check optional fields
@ -228,8 +234,8 @@ public class Checks {
public static void checkMetadataEntry(MetadataEntry metadataEntry) {
// Check required fields
assertNotNull(metadataEntry.getKey(), String.format(NOT_NULL_OBJECT_FMT, "Key", "MetadataEntry"));
assertNotNull(metadataEntry.getValue(), String.format(NOT_NULL_OBJECT_FMT, "Value", "MetadataEntry"));
assertNotNull(metadataEntry.getKey(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Key", "MetadataEntry"));
assertNotNull(metadataEntry.getValue(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Value", "MetadataEntry"));
// Check parent type
checkResourceType(metadataEntry);
@ -237,7 +243,7 @@ public class Checks {
public static void checkMetadataValue(MetadataValue metadataValue) {
// Check required elements and attributes
assertNotNull(metadataValue.getValue(), String.format(NOT_NULL_OBJECT_FMT, "Value", "MetadataValue"));
assertNotNull(metadataValue.getValue(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Value", "MetadataValue"));
// Check parent type
checkResourceType(metadataValue);
@ -249,9 +255,9 @@ public class Checks {
public static void checkError(Error error) {
// Check required fields
assertNotNull(error.getMessage(), String.format(NOT_NULL_OBJECT_FMT, "Message", "Error"));
assertNotNull(error.getMajorErrorCode(), String.format(NOT_NULL_OBJECT_FMT, "MajorErrorCode", "Error"));
assertNotNull(error.getMinorErrorCode(), String.format(NOT_NULL_OBJECT_FMT, "MinorErrorCode", "Error"));
assertNotNull(error.getMessage(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Message", "Error"));
assertNotNull(error.getMajorErrorCode(), String.format(NOT_NULL_OBJ_FIELD_FMT, "MajorErrorCode", "Error"));
assertNotNull(error.getMinorErrorCode(), String.format(NOT_NULL_OBJ_FIELD_FMT, "MinorErrorCode", "Error"));
// NOTE vendorSpecificErrorCode cannot be checked
// NOTE stackTrace cannot be checked
@ -259,7 +265,7 @@ public class Checks {
public static void checkOrg(Org org) {
// Check required elements and attributes
assertNotNull(org.getFullName(), String.format(NOT_NULL_OBJECT_FMT, "FullName", "Org"));
assertNotNull(org.getFullName(), String.format(NOT_NULL_OBJ_FIELD_FMT, "FullName", "Org"));
// Check parent type
checkEntityType(org);
@ -267,7 +273,7 @@ public class Checks {
public static void checkAdminOrg(AdminOrg org) {
// required
assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJECT_FMT, "settings", "AdminOrg"));
assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJ_FIELD_FMT, "settings", "AdminOrg"));
// optional
if (org.getGroups() != null) {
@ -405,7 +411,7 @@ public class Checks {
public static void checkNetworkFeatures(NetworkFeatures features) {
// Check optional fields
if (features.getNetworkServices() != null) {
for (NetworkServiceType service : features.getNetworkServices()) {
for (NetworkServiceType<?> service : features.getNetworkServices()) {
checkNetworkService(service);
}
}
@ -456,12 +462,14 @@ public class Checks {
}
public static void checkIpAddress(String ip) {
InetAddresses.isInetAddress(ip);
// Check the string is a valid IP address
assertTrue(InetAddresses.isInetAddress(ip), String.format(CONDITION_FMT, "IpAddress", "a valid IP address", ip));
}
private static void checkMacAddress(String macAddress) {
assertNotNull(macAddress, String.format(NOT_NULL_OBJECT_FMT, "macAddress", ""));
assertTrue(macAddress.matches("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$"));
// Check the string is a valid MAC address
assertNotNull(macAddress, String.format(NOT_EMPTY_STRING_FMT, "macAddress"));
assertTrue(macAddress.matches(MAC_ADDRESS_PATTERN), String.format(MATCHES_STRING_FMT, "macAddress", MAC_ADDRESS_PATTERN));
}
public static void checkComputeCapacity(ComputeCapacity computeCapacity) {
@ -493,7 +501,6 @@ public class Checks {
assertNotNull(capacity.getLimit(), "The limit attribute of a CapacityWithUsage must be set");
assertTrue(capacity.getLimit() >= 0, "Limit must be greater than or equal to 0");
// Check optional fields
if (capacity.getAllocated() != null) {
assertTrue(capacity.getAllocated() >= 0, "allocated must be greater than or equal to 0");
@ -615,7 +622,7 @@ public class Checks {
public static void checkVAppTemplate(VAppTemplate template) {
// Check required fields
assertNotNull(template.getName(), String.format(NOT_NULL_OBJECT_FMT, "Name", "VAppTemplate"));
assertNotNull(template.getName(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Name", "VAppTemplate"));
// Check optional fields
Owner owner = template.getOwner();
@ -810,16 +817,16 @@ public class Checks {
// NOTE canPublishCatalogs cannot be checked
// NOTE useServerBootSequence cannot be checked
if (settings.getDeployedVMQuota() != null) {
assertTrue(settings.getDeployedVMQuota() >= 0, String.format(
OBJ_FIELD_GTE_0, "deployedVMQuota", "port", settings.getDeployedVMQuota()));
assertTrue(settings.getDeployedVMQuota() >= 0,
String.format(OBJ_FIELD_GTE_0, "deployedVMQuota", "port", settings.getDeployedVMQuota()));
}
if (settings.getStoredVmQuota() != null) {
assertTrue(settings.getStoredVmQuota() >= 0, String.format(
OBJ_FIELD_GTE_0, "storedVmQuota", "port", settings.getStoredVmQuota()));
assertTrue(settings.getStoredVmQuota() >= 0,
String.format(OBJ_FIELD_GTE_0, "storedVmQuota", "port", settings.getStoredVmQuota()));
}
if (settings.getDelayAfterPowerOnSeconds() != null) {
assertTrue(settings.getDelayAfterPowerOnSeconds() >= 0, String.format(
OBJ_FIELD_GTE_0, "delayAfterPowerOnSeconds", "port", settings.getDelayAfterPowerOnSeconds()));
assertTrue(settings.getDelayAfterPowerOnSeconds() >= 0,
String.format(OBJ_FIELD_GTE_0, "delayAfterPowerOnSeconds", "port", settings.getDelayAfterPowerOnSeconds()));
}
// parent type
@ -830,8 +837,9 @@ public class Checks {
// Check optional fields
// NOTE customUsersOu cannot be checked
if (settings.getLdapMode() != null) {
assertTrue(LdapMode.ALL.contains(settings.getLdapMode()), String.format(REQUIRED_VALUE_OBJECT_FMT,
"LdapMode", "OrdLdapSettings", settings.getLdapMode(), Iterables.toString(OrgLdapSettings.LdapMode.ALL)));
assertTrue(LdapMode.ALL.contains(settings.getLdapMode()),
String.format(REQUIRED_VALUE_OBJECT_FMT, "LdapMode", "OrdLdapSettings", settings.getLdapMode(),
Iterables.toString(OrgLdapSettings.LdapMode.ALL)));
}
if (settings.getCustomOrgLdapSettings() != null) {
checkCustomOrgLdapSettings(settings.getCustomOrgLdapSettings());
@ -845,17 +853,17 @@ public class Checks {
// required
assertNotNull(settings.getHostName(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "hostName"));
assertNotNull(settings.getPort(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "port"));
assertTrue(settings.getPort() >= 0, String.format(
OBJ_FIELD_GTE_0, "CustomOrgLdapSettings", "port", settings.getPort()));
assertTrue(settings.getPort() >= 0,
String.format(OBJ_FIELD_GTE_0, "CustomOrgLdapSettings", "port", settings.getPort()));
assertNotNull(settings.getAuthenticationMechanism(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "authenticationMechanism"));
assertTrue(AuthenticationMechanism.ALL.contains(settings.getAuthenticationMechanism()), String.format(REQUIRED_VALUE_OBJECT_FMT,
"AuthenticationMechanism", "CustomOrdLdapSettings", settings.getAuthenticationMechanism(),
Iterables.toString(CustomOrgLdapSettings.AuthenticationMechanism.ALL)));
assertTrue(AuthenticationMechanism.ALL.contains(settings.getAuthenticationMechanism()),
String.format(REQUIRED_VALUE_OBJECT_FMT, "AuthenticationMechanism", "CustomOrdLdapSettings", settings.getAuthenticationMechanism(),
Iterables.toString(CustomOrgLdapSettings.AuthenticationMechanism.ALL)));
assertNotNull(settings.isGroupSearchBaseEnabled(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "isGroupSearchBaseEnabled"));
assertNotNull(settings.getConnectorType(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "connectorType"));
assertTrue(ConnectorType.ALL.contains(settings.getConnectorType()), String.format(REQUIRED_VALUE_OBJECT_FMT,
"ConnectorType", "CustomOrdLdapSettings", settings.getConnectorType(),
Iterables.toString(CustomOrgLdapSettings.ConnectorType.ALL)));
assertTrue(ConnectorType.ALL.contains(settings.getConnectorType()),
String.format(REQUIRED_VALUE_OBJECT_FMT, "ConnectorType", "CustomOrdLdapSettings", settings.getConnectorType(),
Iterables.toString(CustomOrgLdapSettings.ConnectorType.ALL)));
assertNotNull(settings.getUserAttributes(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "userAttributes"));
checkUserAttributes("CustomOrdLdapSettings", settings.getUserAttributes());
assertNotNull(settings.getGroupAttributes(), String.format(OBJ_FIELD_REQ, "CustomOrgLdapSettings", "groupAttributes"));
@ -901,13 +909,16 @@ public class Checks {
public static void checkPasswordPolicySettings(OrgPasswordPolicySettings settings) {
// required
assertNotNull(settings.isAccountLockoutEnabled(), String.format(OBJ_FIELD_REQ, "OrgPasswordPolicySettings", "isAccountLockoutEnabled"));
assertNotNull(settings.getInvalidLoginsBeforeLockout(), String.format(OBJ_FIELD_REQ, "OrgPasswordPolicySettings", "invalidLoginsBeforeLockout"));
assertTrue(settings.getInvalidLoginsBeforeLockout() >= 0, String.format(
OBJ_FIELD_GTE_0, "OrgPasswordPolicySettings", "storageLeaseSeconds", settings.getInvalidLoginsBeforeLockout()));
assertNotNull(settings.getAccountLockoutIntervalMinutes(), String.format(OBJ_FIELD_REQ, "OrgPasswordPolicySettings", "accountLockoutIntervalMinutes"));
assertTrue(settings.getAccountLockoutIntervalMinutes() >= 0, String.format(
OBJ_FIELD_GTE_0, "OrgPasswordPolicySettings", "accountLockoutIntervalMinutes", settings.getAccountLockoutIntervalMinutes()));
assertNotNull(settings.isAccountLockoutEnabled(),
String.format(OBJ_FIELD_REQ, "OrgPasswordPolicySettings", "isAccountLockoutEnabled"));
assertNotNull(settings.getInvalidLoginsBeforeLockout(),
String.format(OBJ_FIELD_REQ, "OrgPasswordPolicySettings", "invalidLoginsBeforeLockout"));
assertTrue(settings.getInvalidLoginsBeforeLockout() >= 0,
String.format(OBJ_FIELD_GTE_0, "OrgPasswordPolicySettings", "storageLeaseSeconds", settings.getInvalidLoginsBeforeLockout()));
assertNotNull(settings.getAccountLockoutIntervalMinutes(),
String.format(OBJ_FIELD_REQ, "OrgPasswordPolicySettings", "accountLockoutIntervalMinutes"));
assertTrue(settings.getAccountLockoutIntervalMinutes() >= 0,
String.format(OBJ_FIELD_GTE_0, "OrgPasswordPolicySettings", "accountLockoutIntervalMinutes", settings.getAccountLockoutIntervalMinutes()));
// parent type
checkResourceType(settings);
@ -917,12 +928,12 @@ public class Checks {
// Check optional fields
// NOTE deleteOnStorageLeaseExpiration cannot be checked
if (settings.getStorageLeaseSeconds() != null) {
assertTrue(settings.getStorageLeaseSeconds() >= 0, String.format(
OBJ_FIELD_GTE_0, "OrgLeaseSettings", "storageLeaseSeconds", settings.getStorageLeaseSeconds()));
assertTrue(settings.getStorageLeaseSeconds() >= 0,
String.format(OBJ_FIELD_GTE_0, "OrgLeaseSettings", "storageLeaseSeconds", settings.getStorageLeaseSeconds()));
}
if (settings.getDeploymentLeaseSeconds() != null) {
assertTrue(settings.getDeploymentLeaseSeconds() >= 0, String.format(
OBJ_FIELD_GTE_0, "OrgLeaseSettings", "deploymentLeaseSeconds", settings.getDeploymentLeaseSeconds()));
assertTrue(settings.getDeploymentLeaseSeconds() >= 0,
String.format(OBJ_FIELD_GTE_0, "OrgLeaseSettings", "deploymentLeaseSeconds", settings.getDeploymentLeaseSeconds()));
}
// parent type
@ -933,8 +944,8 @@ public class Checks {
// Check optional fields
// NOTE deleteOnStorageLeaseExpiration cannot be checked
if (settings.getStorageLeaseSeconds() != null) {
assertTrue(settings.getStorageLeaseSeconds() >= 0, String.format(
OBJ_FIELD_GTE_0, "OrgVAppTemplateLeaseSettings", "storageLeaseSeconds", settings.getStorageLeaseSeconds()));
assertTrue(settings.getStorageLeaseSeconds() >= 0,
String.format(OBJ_FIELD_GTE_0, "OrgVAppTemplateLeaseSettings", "storageLeaseSeconds", settings.getStorageLeaseSeconds()));
}
// parent type
@ -965,12 +976,12 @@ public class Checks {
checkEmailAddress(user.getAlertEmail());
}
if (user.getStoredVmQuota() != null) {
assertTrue(user.getStoredVmQuota() >= 0, String.format(OBJ_FIELD_GTE_0,
"User", "storedVmQuota", user.getStoredVmQuota()));
assertTrue(user.getStoredVmQuota() >= 0,
String.format(OBJ_FIELD_GTE_0, "User", "storedVmQuota", user.getStoredVmQuota()));
}
if (user.getDeployedVmQuota() != null) {
assertTrue(user.getDeployedVmQuota() >= 0, String.format(OBJ_FIELD_GTE_0,
"User", "deployedVmQuota", user.getDeployedVmQuota()));
assertTrue(user.getDeployedVmQuota() >= 0,
String.format(OBJ_FIELD_GTE_0, "User", "deployedVmQuota", user.getDeployedVmQuota()));
}
if (user.getRole() != null) {
checkReferenceType(user.getRole());
@ -986,99 +997,174 @@ public class Checks {
}
public static void checkTelephone(String number) {
// TODO: regex validate telephone
// TODO regex validate telephone
}
public static void checkCustomizationSection(CustomizationSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "CustomizationSection", ""));
public static void checkScreenTicket(ScreenTicket ticket) {
// NOTE the value field cannot be checked
}
public static void checkCustomizationSection(CustomizationSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "CustomizationSection"));
// Check optional fields
if (val.getLinks() != null) {
for (Link link : val.getLinks()) {
if (section.getLinks() != null) {
for (Link link : section.getLinks()) {
checkLink(link);
}
}
if (val.getType() != null) {
checkType(val.getType());
}
if (val.getHref() != null) {
checkHref(val.getHref());
}
if (section.getType() != null) checkType(section.getType());
if (section.getHref() != null) checkHref(section.getHref());
checkOvfSectionType(val);
// Check parent type
checkOvfSectionType(section);
}
public static void checkProductSectionList(ProductSectionList val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "ProductSectionList", ""));
public static void checkProductSectionList(ProductSectionList sections) {
assertNotNull(sections, String.format(NOT_NULL_OBJ_FMT, "ProductSectionList"));
for (ProductSection productSection : val) {
for (ProductSection productSection : sections) {
checkOvfProductSection(productSection);
}
checkResourceType(val);
// Check parent type
checkResourceType(sections);
}
public static void checkGuestCustomizationSection(GuestCustomizationSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "GuestCustomizationSection", ""));
public static void checkGuestCustomizationSection(GuestCustomizationSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "NetworkConfigSection"));
if (!val.isJoinDomainEnabled()) {
assertFalse(val.isUseOrgSettings());
assertNull(val.getDomainName());
assertNull(val.getDomainUserName());
assertNull(val.getDomainUserPassword());
if (!section.isJoinDomainEnabled()) {
assertFalse(section.isUseOrgSettings());
assertNull(section.getDomainName());
assertNull(section.getDomainUserName());
assertNull(section.getDomainUserPassword());
}
if (!val.isAdminPasswordEnabled()) {
assertFalse(val.isAdminPasswordAuto());
assertFalse(val.isResetPasswordRequired());
if (val.isAdminPasswordAuto()) {
assertNull(val.getAdminPassword());
if (!section.isAdminPasswordEnabled()) {
assertFalse(section.isAdminPasswordAuto());
assertFalse(section.isResetPasswordRequired());
if (section.isAdminPasswordAuto()) {
assertNull(section.getAdminPassword());
}
}
checkOvfSectionType(val);
// Check parent type
checkOvfSectionType(section);
}
public static void checkLeaseSettingsSection(LeaseSettingsSection val) {
if (val.getLinks() != null) {
for (Link link : val.getLinks()) {
public static void checkLeaseSettingsSection(LeaseSettingsSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "LeaseSettingsSection"));
if (section.getLinks() != null) {
for (Link link : section.getLinks()) {
checkLink(link);
}
}
checkOvfSectionType(val);
// Check parent type
checkOvfSectionType(section);
}
public static void checkNetworkConfigSection(NetworkConfigSection val) {
if (val.getNetworkConfigs() != null) {
for (VAppNetworkConfiguration networkConfig : val.getNetworkConfigs()) {
public static void checkNetworkConfigSection(NetworkConfigSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "NetworkConfigSection"));
if (section.getNetworkConfigs() != null) {
for (VAppNetworkConfiguration networkConfig : section.getNetworkConfigs()) {
checkVAppNetworkConfig(networkConfig);
}
}
if (val.getLinks() != null) {
for (Link link : val.getLinks()) {
if (section.getLinks() != null) {
for (Link link : section.getLinks()) {
checkLink(link);
}
}
if (val.getHref() != null) {
checkHref(val.getHref());
if (section.getHref() != null) {
checkHref(section.getHref());
}
checkOvfSectionType(val);
// Check parent type
checkOvfSectionType(section);
}
public static void checkNetworkSection(NetworkSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "NetworkSection"));
// Check optional fields
if (section.getNetworks() != null) {
for (Network network : section.getNetworks()) {
checkNetwork(network);
}
}
// Check parent type
checkOvfSectionType(section);
}
public static void checkNetwork(Network network) {
assertNotNull(network, String.format(NOT_NULL_OBJ_FMT, "Network"));
// Check optional fields
// NOTE name field cannot be checked
// NOTE description field cannot be checked
}
public static void checkOperatingSystemSection(OperatingSystemSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "OperatingSystemSection"));
// Check optional fields
// NOTE id field cannot be checked
// NOTE version field cannot be checked
// NOTE description field cannot be checked
// Check parent type
checkOvfSectionType(section);
}
public static void checkRuntimeInfoSection(RuntimeInfoSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "RuntimeInfoSection"));
// Check optional fields
VMWareTools tools = section.getVMWareTools();
if (tools != null) checkVMWareTools(tools);
// NOTE does this mean anything?
for (Object any : section.getAny()) {
assertNotNull(any);
}
// Check parent type
checkOvfSectionType(section);
}
public static void checkVMWareTools(VMWareTools tools) {
assertNotNull(tools, String.format(NOT_NULL_OBJ_FMT, "VMWareTools"));
// Check required fields
assertNotNull(tools.getVersion(), String.format(NOT_NULL_OBJ_FIELD_FMT, "version", "VMWareTools"));
assertFalse(tools.getVersion().isEmpty(), String.format(NOT_EMPTY_STRING_FMT, "VMWareTools.version"));
}
public static void checkStartupSection(StartupSection section) {
// TODO
// Check parent type
checkOvfSectionType(section);
}
private static void checkVAppNetworkConfig(VAppNetworkConfiguration val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VAppNetworkConfiguration", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "VAppNetworkConfiguration"));
// required fields
assertNotNull(val.getNetworkName(), String.format(NOT_NULL_OBJECT_FMT, "NetworkName", "VAppNetworkConfiguration"));
assertNotNull(val.getNetworkName(), String.format(NOT_NULL_OBJ_FIELD_FMT, "NetworkName", "VAppNetworkConfiguration"));
checkNetworkConfiguration(val.getConfiguration());
checkResourceType(val);
}
public static void checkNetworkConnectionSection(NetworkConnectionSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VAppConnectionSection", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "VAppConnectionSection"));
// Check optional fields
if (val.getLinks() != null) {
@ -1102,11 +1188,11 @@ public class Checks {
}
private static void checkNetworkConnection(NetworkConnection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "NetworkConnection", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "NetworkConnection"));
// Check required fields
assertNotNull(val.getNetwork(), String.format(NOT_NULL_OBJECT_FMT, "Network", "NetworkConnection"));
assertNotNull(val.getIpAddressAllocationMode(), String.format(NOT_NULL_OBJECT_FMT, "IpAddressAllocationMode", "NetworkConnection"));
assertNotNull(val.getNetwork(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Network", "NetworkConnection"));
assertNotNull(val.getIpAddressAllocationMode(), String.format(NOT_NULL_OBJ_FIELD_FMT, "IpAddressAllocationMode", "NetworkConnection"));
IpAddressAllocationMode mode = NetworkConnection.IpAddressAllocationMode.valueOf(val.getIpAddressAllocationMode());
assertTrue(NetworkConnection.IpAddressAllocationMode.ALL.contains(mode),
String.format(REQUIRED_VALUE_OBJECT_FMT, "IpAddressAllocationMode", "NetworkConnection", val.getIpAddressAllocationMode(), Iterables.toString(NetworkConnection.IpAddressAllocationMode.ALL)));
@ -1122,17 +1208,28 @@ public class Checks {
if (val.getMACAddress() != null) {
checkMacAddress(val.getMACAddress());
}
// FIXME Missing?
//val.getVCloudExtension();
}
public static void checkRASD(RASD rasd) {
// Check fields
// TODO
}
public static void checkRasdItemsList(RasdItemsList items) {
// Check fields
// TODO
for (RASD item : items.getItems()) {
checkRASD(item);
}
}
public static void checkOvfSectionType(SectionType section) {
assertNotNull(section, String.format(NOT_NULL_OBJECT_FMT, "SectionType", ""));
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "SectionType"));
}
public static void checkOvfProductSection(ProductSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "ProductSection", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "ProductSection"));
if (val.getProperties() != null) {
for (org.jclouds.vcloud.director.v1_5.domain.ovf.Property property : val.getProperties()) {
@ -1140,15 +1237,16 @@ public class Checks {
}
}
// Check parent type
checkOvfSectionType(val);
}
private static void checkOvfProperty(org.jclouds.vcloud.director.v1_5.domain.ovf.Property val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Property", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "Property"));
}
public static void checkOvfNetworkSection(NetworkSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "NetworkSection", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "NetworkSection"));
if (val.getNetworks() != null) {
for (Network network : val.getNetworks()) {
@ -1160,11 +1258,11 @@ public class Checks {
}
private static void checkOvfNetwork(Network val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Network", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "Network"));
}
public static void checkOvfEnvelope(Envelope val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Envelope", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "Envelope"));
if (val.getDiskSections() != null) {
for (DiskSection diskSection : val.getDiskSections()) {
@ -1182,7 +1280,7 @@ public class Checks {
}
private static void checkOvfVirtualSystem(VirtualSystem val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VirtualSystem", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "VirtualSystem"));
if (val.getProductSections() != null) {
for (ProductSection productSection : val.getProductSections()) {
@ -1199,47 +1297,54 @@ public class Checks {
}
}
private static void checkOvfDiskSection(DiskSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "DiskSection", ""));
private static void checkOvfDiskSection(DiskSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "DiskSection"));
if (val.getDisks() != null) {
for (Disk disk : val.getDisks()) {
if (section.getDisks() != null) {
for (Disk disk : section.getDisks()) {
checkOvfDisk(disk);
}
}
// Check parent type
checkOvfSectionType(section);
}
private static void checkOvfDisk(Disk val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Disk", ""));
private static void checkOvfDisk(Disk disk) {
assertNotNull(disk, String.format(NOT_NULL_OBJ_FMT, "Disk"));
}
private static void checkOvfOperationSystemSection(OperatingSystemSection val) {
checkOvfSectionType(val);
}
private static void checkOvfVirtualHardwareSection(VirtualHardwareSection val) {
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VirtualHardwareSection", ""));
private static void checkOvfOperationSystemSection(OperatingSystemSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "OperatingSystemSection"));
if (val.getItems() != null) {
for (ResourceAllocationSettingData item : val.getItems()) {
// Check parent type
checkOvfSectionType(section);
}
private static void checkOvfVirtualHardwareSection(VirtualHardwareSection section) {
assertNotNull(section, String.format(NOT_NULL_OBJ_FMT, "VirtualHardwareSection"));
if (section.getItems() != null) {
for (ResourceAllocationSettingData item : section.getItems()) {
checkCimResourceAllocationSettingData(item);
}
}
if (val.getSystem() != null) {
checkCimVirtualSystemSettingData(val.getSystem());
if (section.getSystem() != null) {
checkCimVirtualSystemSettingData(section.getSystem());
}
checkOvfSectionType(val);
// Check parent type
checkOvfSectionType(section);
}
private static void checkCimVirtualSystemSettingData(VirtualSystemSettingData val) {
// TODO Could do more assertions...
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VirtualSystemSettingData", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "VirtualSystemSettingData"));
}
private static void checkCimResourceAllocationSettingData(ResourceAllocationSettingData val) {
// TODO Could do more assertions...
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "ResouorceAllocatoinSettingData", ""));
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "ResouorceAllocatoinSettingData"));
}
public static void checkAdminVdc(AdminVdc vdc) {

View File

@ -18,12 +18,15 @@
*/
package org.jclouds.vcloud.director.v1_5.internal;
import static org.testng.Assert.assertNotNull;
import java.net.URI;
import java.util.Properties;
import javax.inject.Inject;
import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.date.DateService;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext;
@ -41,6 +44,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
@ -50,6 +54,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.Guice;
import com.google.inject.Module;
/**
@ -69,6 +74,14 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
provider = "vcloud-director";
}
protected static DateService dateService;
@BeforeGroups("live")
protected static void setupDateService() {
dateService = Guice.createInjector().getInstance(DateService.class);
assertNotNull(dateService);
}
// NOTE Implement as required to populate xxxClient fields, or NOP
public abstract void setupRequiredClients() throws Exception;

View File

@ -54,7 +54,7 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
protected static DateService dateService;
@BeforeGroups("unit")
protected static void setUpInjector() {
protected static void setupDateService() {
dateService = Guice.createInjector().getInstance(DateService.class);
assertNotNull(dateService);
}