mirror of https://github.com/apache/jclouds.git
Merge pull request #188 from andreisavu/template-fixes
A few test & template extraction fixes
This commit is contained in:
commit
9a8dc49a78
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.domain;
|
package org.jclouds.cloudstack.domain;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -151,6 +152,11 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TemplateExtraction build() {
|
||||||
|
return new TemplateExtraction(id, accountId, created, extractId,
|
||||||
|
extractMode, name, state, status, storageType, uploadPercentage,
|
||||||
|
url,zoneId, zoneName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
@ -169,9 +175,33 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
||||||
private String url;
|
private String url;
|
||||||
@SerializedName("zoneid")
|
@SerializedName("zoneid")
|
||||||
private long zoneId;
|
private long zoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new TemplateExtraction instance
|
||||||
|
*/
|
||||||
|
public TemplateExtraction(long id, long accountId, Date created, long extractId,
|
||||||
|
ExtractMode extractMode, String name, String state, String status,
|
||||||
|
String storageType, int uploadPercentage, String url,
|
||||||
|
long zoneId, String zoneName) {
|
||||||
|
this.id = id;
|
||||||
|
this.accountId = accountId;
|
||||||
|
this.created = created;
|
||||||
|
this.extractId = extractId;
|
||||||
|
this.extractMode = extractMode;
|
||||||
|
this.name = name;
|
||||||
|
this.state = state;
|
||||||
|
this.status = status;
|
||||||
|
this.storageType = storageType;
|
||||||
|
this.uploadPercentage = uploadPercentage;
|
||||||
|
this.url = url;
|
||||||
|
this.zoneId = zoneId;
|
||||||
|
this.zoneName = zoneName;
|
||||||
|
}
|
||||||
|
|
||||||
@SerializedName("zonename")
|
@SerializedName("zonename")
|
||||||
private String zoneName;
|
private String zoneName;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* present only for serializer
|
* present only for serializer
|
||||||
*/
|
*/
|
||||||
|
@ -270,23 +300,48 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object obj) {
|
||||||
throw new RuntimeException("FIXME: Implement me");
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TemplateExtraction other = (TemplateExtraction) obj;
|
||||||
|
return id == other.id
|
||||||
|
&& accountId == other.accountId
|
||||||
|
&& Objects.equal(created, other.created)
|
||||||
|
&& extractId == other.extractId
|
||||||
|
&& Objects.equal(extractMode, other.extractMode)
|
||||||
|
&& Objects.equal(name, other.name)
|
||||||
|
&& Objects.equal(state, other.state)
|
||||||
|
&& Objects.equal(status, other.status)
|
||||||
|
&& Objects.equal(storageType, other.storageType)
|
||||||
|
&& uploadPercentage == other.uploadPercentage
|
||||||
|
&& Objects.equal(url, other.url)
|
||||||
|
&& zoneId == other.zoneId
|
||||||
|
&& Objects.equal(zoneName, other.zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
throw new RuntimeException("FIXME: Implement me");
|
return Objects.hashCode(id, accountId, created, extractId, extractMode,
|
||||||
|
name, state, status, storageType, uploadPercentage, url, zoneId, zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
throw new RuntimeException("FIXME: Implement me");
|
return "[id=" + id + ", accountId=" + accountId + ", created=" + created
|
||||||
|
+ ", extractId=" + extractId + ", extractMode=" + extractMode
|
||||||
|
+ ", name=" + name + ", state=" + state + ", status=" + status
|
||||||
|
+ ", storageType=" + storageType + ", uploadPercentage=" + uploadPercentage
|
||||||
|
+ ", url=" + url + ", zoneId=" + zoneId + ", zoneName=" + zoneName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(TemplateExtraction other) {
|
public int compareTo(TemplateExtraction other) {
|
||||||
throw new RuntimeException("FIXME: Implement me");
|
return new Long(id).compareTo(other.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private VirtualMachine vm;
|
private VirtualMachine vm;
|
||||||
private Template template;
|
private Template template;
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testListTemplates() throws Exception {
|
public void testListTemplates() throws Exception {
|
||||||
Set<Template> response = client.getTemplateClient().listTemplates();
|
Set<Template> response = client.getTemplateClient().listTemplates();
|
||||||
assert null != response;
|
assert null != response;
|
||||||
|
@ -56,6 +57,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
for (Template template : response) {
|
for (Template template : response) {
|
||||||
Template newDetails = Iterables.getOnlyElement(client.getTemplateClient().listTemplates(
|
Template newDetails = Iterables.getOnlyElement(client.getTemplateClient().listTemplates(
|
||||||
zoneId(template.getZoneId()).id(template.getId())));
|
zoneId(template.getZoneId()).id(template.getId())));
|
||||||
|
Logger.CONSOLE.info("Checking template: " + template);
|
||||||
|
|
||||||
assertEquals(template, newDetails);
|
assertEquals(template, newDetails);
|
||||||
assertEquals(template, client.getTemplateClient().getTemplateInZone(template.getId(), template.getZoneId()));
|
assertEquals(template, client.getTemplateClient().getTemplateInZone(template.getId(), template.getZoneId()));
|
||||||
assert template.getId() > 0 : template;
|
assert template.getId() > 0 : template;
|
||||||
|
@ -68,7 +71,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
assert template.getAccount() != null : template;
|
assert template.getAccount() != null : template;
|
||||||
assert template.getZone() != null : template;
|
assert template.getZone() != null : template;
|
||||||
assert template.getZoneId() > 0 : template;
|
assert template.getZoneId() > 0 : template;
|
||||||
assert template.getStatus() == null : template;
|
assert (template.getStatus() == null ||
|
||||||
|
template.getStatus().equals("Download Complete")) : template;
|
||||||
assert template.getType() != null && template.getType() != Template.Type.UNRECOGNIZED : template;
|
assert template.getType() != null && template.getType() != Template.Type.UNRECOGNIZED : template;
|
||||||
assert template.getHypervisor() != null : template;
|
assert template.getHypervisor() != null : template;
|
||||||
assert template.getDomain() != null : template;
|
assert template.getDomain() != null : template;
|
||||||
|
@ -112,19 +116,6 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
assertNotNull(template);
|
assertNotNull(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
|
||||||
protected void tearDown() {
|
|
||||||
if (vm != null) {
|
|
||||||
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vm.getId())) : vm;
|
|
||||||
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())) : vm;
|
|
||||||
assert virtualMachineDestroyed.apply(vm);
|
|
||||||
}
|
|
||||||
if (template != null) {
|
|
||||||
client.getTemplateClient().deleteTemplate(template.getId());
|
|
||||||
}
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testCreateTemplate")
|
@Test(enabled = true, dependsOnMethods = "testCreateTemplate")
|
||||||
public void testExtractTemplate() throws Exception {
|
public void testExtractTemplate() throws Exception {
|
||||||
// Initiate the extraction and wait for it to complete
|
// Initiate the extraction and wait for it to complete
|
||||||
|
@ -185,4 +176,19 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, template.getId(), client, jobComplete, virtualMachineRunning);
|
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, template.getId(), client, jobComplete, virtualMachineRunning);
|
||||||
assertNotNull(vm);
|
assertNotNull(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@AfterGroups(groups = "live")
|
||||||
|
protected void tearDown() {
|
||||||
|
if (vm != null) {
|
||||||
|
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vm.getId())) : vm;
|
||||||
|
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())) : vm;
|
||||||
|
assert virtualMachineDestroyed.apply(vm);
|
||||||
|
}
|
||||||
|
if (template != null) {
|
||||||
|
client.getTemplateClient().deleteTemplate(template.getId());
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue