mirror of https://github.com/apache/jclouds.git
A few test & template extraction fixes
This commit is contained in:
parent
8370a20654
commit
89e575f2b3
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -151,6 +152,11 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public TemplateExtraction build() {
|
||||
return new TemplateExtraction(id, accountId, created, extractId,
|
||||
extractMode, name, state, status, storageType, uploadPercentage,
|
||||
url,zoneId, zoneName);
|
||||
}
|
||||
}
|
||||
|
||||
private long id;
|
||||
|
@ -169,9 +175,33 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
|||
private String url;
|
||||
@SerializedName("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")
|
||||
private String zoneName;
|
||||
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
|
@ -270,23 +300,48 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
throw new RuntimeException("FIXME: Implement me");
|
||||
public boolean equals(Object obj) {
|
||||
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
|
||||
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
|
||||
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
|
||||
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 Template template;
|
||||
|
||||
@Test
|
||||
public void testListTemplates() throws Exception {
|
||||
Set<Template> response = client.getTemplateClient().listTemplates();
|
||||
assert null != response;
|
||||
|
@ -56,6 +57,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
for (Template template : response) {
|
||||
Template newDetails = Iterables.getOnlyElement(client.getTemplateClient().listTemplates(
|
||||
zoneId(template.getZoneId()).id(template.getId())));
|
||||
Logger.CONSOLE.info("Checking template: " + template);
|
||||
|
||||
assertEquals(template, newDetails);
|
||||
assertEquals(template, client.getTemplateClient().getTemplateInZone(template.getId(), template.getZoneId()));
|
||||
assert template.getId() > 0 : template;
|
||||
|
@ -68,7 +71,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
assert template.getAccount() != null : template;
|
||||
assert template.getZone() != null : 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.getHypervisor() != null : template;
|
||||
assert template.getDomain() != null : template;
|
||||
|
@ -112,19 +116,6 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
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")
|
||||
public void testExtractTemplate() throws Exception {
|
||||
// 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);
|
||||
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