From 89e575f2b38a40187eec49c10c108604334db23d Mon Sep 17 00:00:00 2001 From: andreisavu Date: Wed, 23 Nov 2011 17:51:34 +0200 Subject: [PATCH] A few test & template extraction fixes --- .../cloudstack/domain/TemplateExtraction.java | 65 +++++++++++++++++-- .../features/TemplateClientLiveTest.java | 34 ++++++---- 2 files changed, 80 insertions(+), 19 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateExtraction.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateExtraction.java index 5972ea53dd..48197be699 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateExtraction.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateExtraction.java @@ -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 { 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 { 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 { } @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); } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java index 9c7d11cc57..eeab3c9511 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java @@ -48,6 +48,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest { private VirtualMachine vm; private Template template; + @Test public void testListTemplates() throws Exception { Set