mirror of https://github.com/apache/jclouds.git
Fixing some issues with XmlEnum annotated types
This commit is contained in:
parent
d7bf98017b
commit
47cbbeef57
|
@ -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
|
||||
|
@ -37,15 +37,9 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a network connection.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>Java class for NetworkConnection complex type.
|
||||
* <p/>
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p/>
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="NetworkConnection">
|
||||
* <complexContent>
|
||||
|
@ -83,7 +77,7 @@ public class NetworkConnection {
|
|||
@XmlEnumValue("dhcp") DHCP("dhcp"),
|
||||
@XmlEnumValue("manual") MANUAL("manual"),
|
||||
@XmlEnumValue("none") NONE("none"),
|
||||
UNRECOGNIZED("unrecognized");
|
||||
@XmlEnumValue("") UNRECOGNIZED("unrecognized");
|
||||
|
||||
public static final List<IpAddressAllocationMode> ALL = ImmutableList.of(POOL, DHCP, MANUAL, NONE);
|
||||
|
||||
|
@ -126,7 +120,7 @@ public class NetworkConnection {
|
|||
private String externalIpAddress;
|
||||
private boolean isConnected;
|
||||
private String macAddress;
|
||||
private String ipAddressAllocationMode;
|
||||
private IpAddressAllocationMode ipAddressAllocationMode;
|
||||
private String network;
|
||||
private Boolean needsCustomization;
|
||||
|
||||
|
@ -173,11 +167,19 @@ public class NetworkConnection {
|
|||
/**
|
||||
* @see NetworkConnection#getIpAddressAllocationMode()
|
||||
*/
|
||||
public Builder ipAddressAllocationMode(String ipAddressAllocationMode) {
|
||||
public Builder ipAddressAllocationMode(IpAddressAllocationMode ipAddressAllocationMode) {
|
||||
this.ipAddressAllocationMode = ipAddressAllocationMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NetworkConnection#getIpAddressAllocationMode()
|
||||
*/
|
||||
public Builder ipAddressAllocationMode(String ipAddressAllocationMode) {
|
||||
this.ipAddressAllocationMode = IpAddressAllocationMode.valueOf(ipAddressAllocationMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NetworkConnection#getNetwork()
|
||||
*/
|
||||
|
@ -214,11 +216,11 @@ public class NetworkConnection {
|
|||
}
|
||||
|
||||
public NetworkConnection(int networkConnectionIndex, String ipAddress, String externalIpAddress, boolean connected,
|
||||
String macAddress, String ipAddressAllocationMode, String network, Boolean needsCustomization) {
|
||||
String macAddress, IpAddressAllocationMode ipAddressAllocationMode, String network, Boolean needsCustomization) {
|
||||
this.networkConnectionIndex = networkConnectionIndex;
|
||||
this.ipAddress = ipAddress;
|
||||
this.externalIpAddress = externalIpAddress;
|
||||
isConnected = connected;
|
||||
this.isConnected = connected;
|
||||
this.macAddress = macAddress;
|
||||
this.ipAddressAllocationMode = ipAddressAllocationMode;
|
||||
this.network = network;
|
||||
|
@ -241,7 +243,7 @@ public class NetworkConnection {
|
|||
@XmlElement(name = "MACAddress")
|
||||
protected String macAddress;
|
||||
@XmlElement(name = "IpAddressAllocationMode", required = true)
|
||||
protected String ipAddressAllocationMode;
|
||||
protected IpAddressAllocationMode ipAddressAllocationMode;
|
||||
@XmlAttribute(required = true)
|
||||
protected String network;
|
||||
@XmlAttribute
|
||||
|
@ -297,7 +299,7 @@ public class NetworkConnection {
|
|||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getIpAddressAllocationMode() {
|
||||
public IpAddressAllocationMode getIpAddressAllocationMode() {
|
||||
return ipAddressAllocationMode;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class UndeployVAppParams {
|
|||
@XmlEnumValue("suspend") SUSPEND("suspend"),
|
||||
@XmlEnumValue("shutdown") SHUTDOWN("shutdown"),
|
||||
@XmlEnumValue("force") FORCE("force"),
|
||||
UNRECOGNIZED("unrecognized");
|
||||
@XmlEnumValue("") UNRECOGNIZED("unrecognized");
|
||||
|
||||
public static final List<PowerAction> ALL = ImmutableList.of( POWER_OFF, SUSPEND, SHUTDOWN, FORCE );
|
||||
|
||||
|
@ -97,13 +97,21 @@ public class UndeployVAppParams {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
private String undeployPowerAction;
|
||||
private PowerAction undeployPowerAction;
|
||||
|
||||
/**
|
||||
* @see UndeployVAppParams#getUndeployPowerAction()
|
||||
*/
|
||||
public Builder undeployPowerAction(PowerAction undeployPowerAction) {
|
||||
this.undeployPowerAction = undeployPowerAction;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UndeployVAppParams#getUndeployPowerAction()
|
||||
*/
|
||||
public Builder undeployPowerAction(String undeployPowerAction) {
|
||||
this.undeployPowerAction = undeployPowerAction;
|
||||
this.undeployPowerAction = PowerAction.valueOf(undeployPowerAction);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -123,7 +131,7 @@ public class UndeployVAppParams {
|
|||
}
|
||||
|
||||
@XmlElement(name = "UndeployPowerAction")
|
||||
protected String undeployPowerAction;
|
||||
protected PowerAction undeployPowerAction;
|
||||
|
||||
/**
|
||||
* The specified action is applied to all VMs in the vApp.
|
||||
|
@ -140,7 +148,7 @@ public class UndeployVAppParams {
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public String getUndeployPowerAction() {
|
||||
public PowerAction getUndeployPowerAction() {
|
||||
return undeployPowerAction;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.R
|
|||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
@ -73,23 +74,22 @@ import org.jclouds.vcloud.director.v1_5.domain.network.NetworkServiceType;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.network.RouterInfo;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.network.SyslogServerSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection.IpAddressAllocationMode;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings.AuthenticationMechanism;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings.ConnectorType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapGroupAttributes;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings.LdapMode;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapUserAttributes;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings.AuthenticationMechanism;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings.ConnectorType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings.LdapMode;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.ContainerType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
|
@ -1255,9 +1255,8 @@ public class Checks {
|
|||
// Check required fields
|
||||
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)));
|
||||
assertNotEquals(val.getIpAddressAllocationMode(), NetworkConnection.IpAddressAllocationMode.UNRECOGNIZED,
|
||||
String.format(REQUIRED_VALUE_OBJECT_FMT, "IpAddressAllocationMode", "NetworkConnection", val.getIpAddressAllocationMode(), Iterables.toString(NetworkConnection.IpAddressAllocationMode.ALL)));
|
||||
|
||||
// Check optional fields
|
||||
if (val.getIpAddress() != null) {
|
||||
|
|
Loading…
Reference in New Issue