Issue 695: Additional objects for rest of VirtualMachineConfigurationOptions

This commit is contained in:
Jason King 2011-11-23 13:21:15 +00:00
parent 42926bd5ad
commit 1a2db01330
7 changed files with 739 additions and 9 deletions

View File

@ -0,0 +1,134 @@
/**
* 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.tmrk.enterprisecloud.domain;
import javax.xml.bind.annotation.XmlElement;
/**
* <xs:complexType name="ConfigurationOptionRange">
* @author Jason King
*/
public class ConfigurationOptionRange {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromConfigurationOptionRange(this);
}
public static class Builder {
private int minimum;
private int maximum;
private int stepFactor;
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange#getMinimum
*/
public Builder minimum(int minimum) {
this.minimum = minimum;
return this;
}
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange#getMaximum
*/
public Builder maximum(int maximum) {
this.maximum = maximum;
return this;
}
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange#getStepFactor
*/
public Builder stepFactor(int stepFactor) {
this.stepFactor = stepFactor;
return this;
}
public ConfigurationOptionRange build() {
return new ConfigurationOptionRange(minimum, maximum,stepFactor);
}
public Builder fromConfigurationOptionRange(ConfigurationOptionRange in) {
return minimum(in.getMinimum()).maximum(in.getMaximum()).stepFactor(in.getStepFactor());
}
}
@XmlElement(name = "Minimum")
private int minimum;
@XmlElement(name = "Maximum")
private int maximum;
@XmlElement(name = "StepFactor")
private int stepFactor;
private ConfigurationOptionRange(int minimum, int maximum, int stepFactor) {
this.minimum = minimum;
this.maximum = maximum;
this.stepFactor = stepFactor;
}
private ConfigurationOptionRange() {
//For JAXB
}
public int getMinimum() {
return minimum;
}
public int getMaximum() {
return maximum;
}
public int getStepFactor() {
return stepFactor;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConfigurationOptionRange that = (ConfigurationOptionRange) o;
if (maximum != that.maximum) return false;
if (minimum != that.minimum) return false;
if (stepFactor != that.stepFactor) return false;
return true;
}
@Override
public int hashCode() {
int result = minimum;
result = 31 * result + maximum;
result = 31 * result + stepFactor;
return result;
}
@Override
public String toString() {
return "[minimum="+ minimum +", maximum="+ maximum +", stepFactor="+stepFactor+"]";
}
}

View File

@ -0,0 +1,167 @@
/**
* 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.tmrk.enterprisecloud.domain;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* <xs:complexType name="CustomizationOption">
* @author Jason King
*/
public class CustomizationOption {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromConfigurationOptionRange(this);
}
public static class Builder {
private CustomizationType type;
private boolean canPowerOn;
private boolean passwordRequired;
private boolean sshKeyRequired;
/**
* @see CustomizationOption#getType
*/
public Builder type(CustomizationType type) {
this.type = type;
return this;
}
/**
* @see CustomizationOption#canPowerOn
*/
public Builder canPowerOn(boolean canPowerOn) {
this.canPowerOn = canPowerOn;
return this;
}
/**
* @see CustomizationOption#isPasswordRequired()
*/
public Builder passwordRequired(boolean passwordRequired) {
this.passwordRequired = passwordRequired;
return this;
}
/**
* @see CustomizationOption#isSshKeyRequired()
*/
public Builder sshKeyRequired(boolean sshKeyRequired) {
this.sshKeyRequired = sshKeyRequired;
return this;
}
public CustomizationOption build() {
return new CustomizationOption(type, canPowerOn, passwordRequired,sshKeyRequired);
}
public Builder fromConfigurationOptionRange(CustomizationOption in) {
return type(in.getType()).canPowerOn(in.canPowerOn()).passwordRequired(in.isPasswordRequired()).sshKeyRequired(in.isSshKeyRequired());
}
}
@XmlElement(name = "Type")
private CustomizationType type;
@XmlElement(name = "CanPowerOn")
private boolean canPowerOn;
@XmlElement(name = "PasswordRequired")
private boolean passwordRequired;
@XmlElement(name = "SshKeyRequired")
private boolean sshKeyRequired;
private CustomizationOption(CustomizationType type, boolean canPowerOn, boolean passwordRequired, boolean sshKeyRequired) {
this.type = checkNotNull(type,"type");
this.canPowerOn = canPowerOn;
this.passwordRequired = passwordRequired;
this.sshKeyRequired = sshKeyRequired;
}
private CustomizationOption() {
//For JAXB
}
public CustomizationType getType() {
return type;
}
public boolean canPowerOn() {
return canPowerOn;
}
public boolean isPasswordRequired() {
return passwordRequired;
}
public boolean isSshKeyRequired() {
return sshKeyRequired;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CustomizationOption that = (CustomizationOption) o;
if (canPowerOn != that.canPowerOn) return false;
if (passwordRequired != that.passwordRequired) return false;
if (sshKeyRequired != that.sshKeyRequired) return false;
if (type != that.type) return false;
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (canPowerOn ? 1 : 0);
result = 31 * result + (passwordRequired ? 1 : 0);
result = 31 * result + (sshKeyRequired ? 1 : 0);
return result;
}
@Override
public String toString() {
return "[type="+type+", canPowerOn="+ canPowerOn +", passwordRequired="+ passwordRequired +", sshKeyRequired="+sshKeyRequired+"]";
}
@XmlEnum
public enum CustomizationType {
@XmlEnumValue("Linux")
LINUX,
@XmlEnumValue("Windows")
WINDOWS;
}
}

View File

@ -0,0 +1,156 @@
/**
* 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.tmrk.enterprisecloud.domain.hardware;
import javax.xml.bind.annotation.XmlElement;
/**
* <xs:complexType name="DiskConfigurationOption">
* @author Jason King
*/
public class DiskConfigurationOption {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromConfigurationOptionRange(this);
}
public static class Builder {
private int minimum;
private int maximum;
private DiskConfigurationOptionRange systemDisk;
private DiskConfigurationOptionRange dataDisk;
/**
* @see DiskConfigurationOption#getMinimum()
*/
public Builder minimum(int minimum) {
this.minimum = minimum;
return this;
}
/**
* @see DiskConfigurationOption#getMaximum()
*/
public Builder maximum(int maximum) {
this.maximum = maximum;
return this;
}
/**
* @see DiskConfigurationOption#getSystemDisk()
*/
public Builder systemDisk(DiskConfigurationOptionRange systemDisk) {
this.systemDisk = systemDisk;
return this;
}
/**
* @see DiskConfigurationOption#getDataDisk()
*/
public Builder dataDisk(DiskConfigurationOptionRange dataDisk) {
this.dataDisk = dataDisk;
return this;
}
public DiskConfigurationOption build() {
return new DiskConfigurationOption(minimum, maximum, systemDisk, dataDisk);
}
public Builder fromConfigurationOptionRange(DiskConfigurationOption in) {
return minimum(in.getMinimum()).maximum(in.getMaximum()).systemDisk(in.getSystemDisk()).dataDisk(in.getDataDisk());
}
}
@XmlElement(name = "Minimum")
private int minimum;
@XmlElement(name = "Maximum")
private int maximum;
@XmlElement(name = "SystemDisk")
private DiskConfigurationOptionRange systemDisk;
@XmlElement(name = "DataDisk")
private DiskConfigurationOptionRange dataDisk;
private DiskConfigurationOption(int minimum, int maximum, DiskConfigurationOptionRange systemDisk, DiskConfigurationOptionRange dataDisk) {
this.minimum = minimum;
this.maximum = maximum;
this.systemDisk = systemDisk;
this.dataDisk = dataDisk;
}
private DiskConfigurationOption() {
//For JAXB
}
public int getMinimum() {
return minimum;
}
public int getMaximum() {
return maximum;
}
public DiskConfigurationOptionRange getSystemDisk() {
return systemDisk;
}
public DiskConfigurationOptionRange getDataDisk() {
return dataDisk;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DiskConfigurationOption that = (DiskConfigurationOption) o;
if (maximum != that.maximum) return false;
if (minimum != that.minimum) return false;
if (dataDisk != null ? !dataDisk.equals(that.dataDisk) : that.dataDisk != null)
return false;
if (systemDisk != null ? !systemDisk.equals(that.systemDisk) : that.systemDisk != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = minimum;
result = 31 * result + maximum;
result = 31 * result + (systemDisk != null ? systemDisk.hashCode() : 0);
result = 31 * result + (dataDisk != null ? dataDisk.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "[minimum="+minimum+", maximum="+ maximum +", systemDisk="+ systemDisk +", dataDisk="+dataDisk+"]";
}
}

View File

@ -0,0 +1,122 @@
/**
* 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.tmrk.enterprisecloud.domain.hardware;
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange;
import javax.xml.bind.annotation.XmlElement;
/**
* <xs:complexType name="DiskConfigurationOptionRange">
* @author Jason King
*/
public class DiskConfigurationOptionRange {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromConfigurationOptionRange(this);
}
public static class Builder {
private ResourceCapacityRange resourceCapacityRange;
private double monthlyCost;
/**
* @see DiskConfigurationOptionRange#getResourceCapacityRange
*/
public Builder resourceCapacityRange(ResourceCapacityRange resourceCapacityRange) {
this.resourceCapacityRange = resourceCapacityRange;
return this;
}
/**
* @see DiskConfigurationOptionRange#getMonthlyCost()
*/
public Builder monthlyCost(double monthlyCost) {
this.monthlyCost = monthlyCost;
return this;
}
public DiskConfigurationOptionRange build() {
return new DiskConfigurationOptionRange(resourceCapacityRange, monthlyCost);
}
public Builder fromConfigurationOptionRange(DiskConfigurationOptionRange in) {
return resourceCapacityRange(in.getResourceCapacityRange()).monthlyCost(in.getMonthlyCost());
}
}
@XmlElement(name = "ResourceCapacityRange")
private ResourceCapacityRange resourceCapacityRange;
@XmlElement(name = "MonthlyCost")
private double monthlyCost;
private DiskConfigurationOptionRange(ResourceCapacityRange resourceCapacityRange, double monthlyCost) {
this.resourceCapacityRange = resourceCapacityRange;
this.monthlyCost = monthlyCost;
}
private DiskConfigurationOptionRange() {
//For JAXB
}
public ResourceCapacityRange getResourceCapacityRange() {
return resourceCapacityRange;
}
public double getMonthlyCost() {
return monthlyCost;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DiskConfigurationOptionRange that = (DiskConfigurationOptionRange) o;
if (Double.compare(that.monthlyCost, monthlyCost) != 0) return false;
if (resourceCapacityRange != null ? !resourceCapacityRange.equals(that.resourceCapacityRange) : that.resourceCapacityRange != null)
return false;
return true;
}
@Override
public int hashCode() {
int result;
long temp;
result = resourceCapacityRange != null ? resourceCapacityRange.hashCode() : 0;
temp = monthlyCost != +0.0d ? Double.doubleToLongBits(monthlyCost) : 0L;
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public String toString() {
return "[resourceCapacityRange="+resourceCapacityRange+", monthlyCost="+monthlyCost+"]";
}
}

View File

@ -19,7 +19,8 @@
package org.jclouds.tmrk.enterprisecloud.domain.vm; package org.jclouds.tmrk.enterprisecloud.domain.vm;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange; import org.jclouds.tmrk.enterprisecloud.domain.*;
import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOption;
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -48,8 +49,21 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
} }
public static class Builder extends BaseResource.Builder<VirtualMachineConfigurationOptions> { public static class Builder extends BaseResource.Builder<VirtualMachineConfigurationOptions> {
//TODO There are additional fields
protected ConfigurationOptionRange processor;
protected ResourceCapacityRange memory; protected ResourceCapacityRange memory;
protected DiskConfigurationOption disk;
protected ConfigurationOptionRange networkAdapter;
protected CustomizationOption customization;
//TODO ComputeMatrix field
/**
* @see VirtualMachineConfigurationOptions#getProcessor
*/
public Builder processor(ConfigurationOptionRange processor) {
this.processor = processor;
return this;
}
/** /**
* @see VirtualMachineConfigurationOptions#getMemory * @see VirtualMachineConfigurationOptions#getMemory
@ -59,13 +73,41 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
return this; return this;
} }
/**
* @see VirtualMachineConfigurationOptions#getDisk
*/
public Builder disk(DiskConfigurationOption disk) {
this.disk = disk;
return this;
}
/**
* @see VirtualMachineConfigurationOptions#getNetworkAdapter
*/
public Builder networkAdapter(ConfigurationOptionRange networkAdapter) {
this.networkAdapter = networkAdapter;
return this;
}
/**
* @see VirtualMachineConfigurationOptions#getCustomization
*/
public Builder customization(CustomizationOption customization) {
this.customization = customization;
return this;
}
@Override @Override
public VirtualMachineConfigurationOptions build() { public VirtualMachineConfigurationOptions build() {
return new VirtualMachineConfigurationOptions(href, type, memory); return new VirtualMachineConfigurationOptions(href, type, processor, memory, disk, networkAdapter, customization);
} }
public Builder fromVirtualMachineConfigurationOptions(VirtualMachineConfigurationOptions in) { public Builder fromVirtualMachineConfigurationOptions(VirtualMachineConfigurationOptions in) {
return fromResource(in).memory(in.getMemory()); return fromResource(in).processor(in.getProcessor())
.memory(in.getMemory())
.disk(in.getDisk())
.networkAdapter(in.getNetworkAdapter())
.customization(in.getCustomization());
} }
/** /**
@ -94,12 +136,29 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
} }
@XmlElement(name = "Processor", required = false)
private ConfigurationOptionRange processor;
@XmlElement(name = "Memory", required = false) @XmlElement(name = "Memory", required = false)
private ResourceCapacityRange memory; private ResourceCapacityRange memory;
private VirtualMachineConfigurationOptions(URI href, String type, @Nullable ResourceCapacityRange memory) { @XmlElement(name = "Disk", required = false)
private DiskConfigurationOption disk;
@XmlElement(name = "NetworkAdapter", required = false)
private ConfigurationOptionRange networkAdapter;
@XmlElement(name = "Customization", required = false)
private CustomizationOption customization;
private VirtualMachineConfigurationOptions(URI href, String type, @Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
@Nullable DiskConfigurationOption disk, @Nullable ConfigurationOptionRange networkAdapter, @Nullable CustomizationOption customization) {
super(href, type); super(href, type);
this.processor = processor;
this.memory = memory; this.memory = memory;
this.disk = disk;
this.networkAdapter = networkAdapter;
this.customization = customization;
} }
private VirtualMachineConfigurationOptions() { private VirtualMachineConfigurationOptions() {
@ -108,12 +167,44 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
/** /**
* *
* @return memory capacity range * @return processor configuration option range
*/
public ConfigurationOptionRange getProcessor() {
return processor;
}
/**
*
* @return memory capacity configuration range
*/ */
public ResourceCapacityRange getMemory() { public ResourceCapacityRange getMemory() {
return memory; return memory;
} }
/**
*
* @return disk configuration option
*/
public DiskConfigurationOption getDisk() {
return disk;
}
/**
*
* @return network adapter configuration range
*/
public ConfigurationOptionRange getNetworkAdapter() {
return networkAdapter;
}
/**
*
* @return customization option
*/
public CustomizationOption getCustomization() {
return customization;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@ -122,8 +213,16 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
VirtualMachineConfigurationOptions that = (VirtualMachineConfigurationOptions) o; VirtualMachineConfigurationOptions that = (VirtualMachineConfigurationOptions) o;
if (customization != null ? !customization.equals(that.customization) : that.customization != null)
return false;
if (disk != null ? !disk.equals(that.disk) : that.disk != null)
return false;
if (memory != null ? !memory.equals(that.memory) : that.memory != null) if (memory != null ? !memory.equals(that.memory) : that.memory != null)
return false; return false;
if (networkAdapter != null ? !networkAdapter.equals(that.networkAdapter) : that.networkAdapter != null)
return false;
if (processor != null ? !processor.equals(that.processor) : that.processor != null)
return false;
return true; return true;
} }
@ -131,12 +230,16 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); int result = super.hashCode();
result = 31 * result + (processor != null ? processor.hashCode() : 0);
result = 31 * result + (memory != null ? memory.hashCode() : 0); result = 31 * result + (memory != null ? memory.hashCode() : 0);
result = 31 * result + (disk != null ? disk.hashCode() : 0);
result = 31 * result + (networkAdapter != null ? networkAdapter.hashCode() : 0);
result = 31 * result + (customization != null ? customization.hashCode() : 0);
return result; return result;
} }
@Override @Override
public String string() { public String string() {
return super.string()+", memory="+memory; return super.string()+", memory="+memory+", disk="+disk+", processor="+processor+", networkAdapter="+networkAdapter+", customization="+customization;
} }
} }

View File

@ -33,7 +33,9 @@ import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.BaseRestClientTest;
import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange; import org.jclouds.tmrk.enterprisecloud.domain.*;
import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOption;
import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOptionRange;
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity; import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineConfigurationOptions; import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineConfigurationOptions;
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient;
@ -50,6 +52,8 @@ import static org.jclouds.io.Payloads.newInputStreamPayload;
import static org.jclouds.rest.RestContextFactory.contextSpec; import static org.jclouds.rest.RestContextFactory.contextSpec;
import static org.jclouds.rest.RestContextFactory.createContextBuilder; import static org.jclouds.rest.RestContextFactory.createContextBuilder;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/** /**
* Tests behavior of JAXB parsing for VirtualMachineConfigurationOptions * Tests behavior of JAXB parsing for VirtualMachineConfigurationOptions
@ -95,7 +99,17 @@ public class VirtualMachineConfigurationOptionsJAXBParsingTest extends BaseRestC
InputStream is = getClass().getResourceAsStream("/virtualMachineConfigurationOptions.xml"); InputStream is = getClass().getResourceAsStream("/virtualMachineConfigurationOptions.xml");
VirtualMachineConfigurationOptions virtualMachineConfigurationOptions = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is))); VirtualMachineConfigurationOptions virtualMachineConfigurationOptions = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
assertProcessorOptions(virtualMachineConfigurationOptions.getProcessor());
assertMemoryOptions(virtualMachineConfigurationOptions.getMemory()); assertMemoryOptions(virtualMachineConfigurationOptions.getMemory());
assertDiskConfigurationOption(virtualMachineConfigurationOptions.getDisk());
assertNetworkAdapterOptions(virtualMachineConfigurationOptions.getNetworkAdapter());
assertCustomizationOption(virtualMachineConfigurationOptions.getCustomization());
}
private void assertProcessorOptions(ConfigurationOptionRange processor) {
assertEquals(processor.getMinimum(),1);
assertEquals(processor.getMaximum(),8);
assertEquals(processor.getStepFactor(),1);
} }
private void assertMemoryOptions(ResourceCapacityRange memory) { private void assertMemoryOptions(ResourceCapacityRange memory) {
@ -103,4 +117,38 @@ public class VirtualMachineConfigurationOptionsJAXBParsingTest extends BaseRestC
assertEquals(memory.getMaximumSize(), ResourceCapacity.builder().value(261120).unit("MB").build()); assertEquals(memory.getMaximumSize(), ResourceCapacity.builder().value(261120).unit("MB").build());
assertEquals(memory.getStepFactor(), ResourceCapacity.builder().value(4).unit("MB").build()); assertEquals(memory.getStepFactor(), ResourceCapacity.builder().value(4).unit("MB").build());
} }
private void assertNetworkAdapterOptions(ConfigurationOptionRange networkAdapter) {
assertEquals(networkAdapter.getMinimum(),1);
assertEquals(networkAdapter.getMaximum(),4);
assertEquals(networkAdapter.getStepFactor(),1);
}
private void assertCustomizationOption(CustomizationOption customization) {
assertEquals(customization.getType(), CustomizationOption.CustomizationType.LINUX);
assertFalse(customization.canPowerOn());
assertFalse(customization.isPasswordRequired());
assertTrue(customization.isSshKeyRequired());
}
private void assertDiskConfigurationOption(DiskConfigurationOption diskConfigurationOption) {
assertEquals(diskConfigurationOption.getMinimum(),1);
assertEquals(diskConfigurationOption.getMaximum(), 15);
ResourceCapacityRange systemDiskRange = ResourceCapacityRange.builder()
.minimumSize(ResourceCapacity.builder().value(1).unit("GB").build())
.maximumSize(ResourceCapacity.builder().value(512).unit("GB").build())
.stepFactor(ResourceCapacity.builder().value(1).unit("GB").build())
.build();
assertEquals(diskConfigurationOption.getSystemDisk(), DiskConfigurationOptionRange.builder().resourceCapacityRange(systemDiskRange).monthlyCost(0).build());
ResourceCapacityRange dataDiskRange = ResourceCapacityRange.builder()
.minimumSize(ResourceCapacity.builder().value(1).unit("GB").build())
.maximumSize(ResourceCapacity.builder().value(512).unit("GB").build())
.stepFactor(ResourceCapacity.builder().value(2).unit("GB").build())
.build();
assertEquals(diskConfigurationOption.getDataDisk(), DiskConfigurationOptionRange.builder().resourceCapacityRange(dataDiskRange).monthlyCost(0).build());
}
} }

View File

@ -53,7 +53,7 @@
</MaximumSize> </MaximumSize>
<StepFactor> <StepFactor>
<Unit>GB</Unit> <Unit>GB</Unit>
<Value>1</Value> <Value>2</Value>
</StepFactor> </StepFactor>
</ResourceCapacityRange> </ResourceCapacityRange>
<MonthlyCost>0</MonthlyCost> <MonthlyCost>0</MonthlyCost>