From 4c835851de0477711bff0c36fb916b90a13c56cf Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 27 Nov 2011 11:30:19 -0500 Subject: [PATCH] fixed some quality issues --- ...indSnapshotPolicyScheduleToQueryParam.java | 3 +- .../org/jclouds/cloudstack/domain/Volume.java | 10 ++--- .../cloudstack/options/ListISOsOptions.java | 4 +- .../options/ListVMGroupsOptions.java | 5 +-- .../options/ListVolumesOptions.java | 2 +- .../options/RegisterISOOptions.java | 1 - .../features/SnapshotClientLiveTest.java | 39 +++++++------------ .../ParseAsyncJobFromHttpResponseTest.java | 9 ++++- 8 files changed, 33 insertions(+), 40 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindSnapshotPolicyScheduleToQueryParam.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindSnapshotPolicyScheduleToQueryParam.java index 15b7f5f5c1..4b84f614b3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindSnapshotPolicyScheduleToQueryParam.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindSnapshotPolicyScheduleToQueryParam.java @@ -44,11 +44,10 @@ public class BindSnapshotPolicyScheduleToQueryParam implements Binder { this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider"); } - @SuppressWarnings("unchecked") @Override public R bindToRequest(R request, Object input) { checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule"); - SnapshotPolicySchedule schedule = (SnapshotPolicySchedule) input; + SnapshotPolicySchedule schedule = SnapshotPolicySchedule.class.cast(input); R modifiedResult = ModifyRequest.addQueryParam(request, "intervaltype", schedule.getInterval(), uriBuilderProvider.get()); modifiedResult = ModifyRequest.addQueryParam(modifiedResult, "schedule", schedule.getTime(), uriBuilderProvider.get()); return modifiedResult; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java index e533e6c1cb..3c7a44258c 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Volume.java @@ -63,6 +63,7 @@ public class Volume implements Comparable { private long snapshotId; private String state; private String storage; + // TODO enum private String storageType; private VolumeType type; private long virtualMachineId; @@ -223,11 +224,10 @@ public class Volume implements Comparable { } public Volume build() { - return new Volume(id, attached, created, destroyed, deviceId, diskOfferingDisplayText, - diskOfferingId, diskOfferingName, domain, domainId, hypervisor, isExtractable, - jobId, jobStatus, name, serviceOfferingDisplayText, serviceOfferingId, - serviceOfferingName, size, snapshotId, state, storage, storage, type, virtualMachineId, - vmDisplayName, vmName, vmState, zoneId, zoneName); + return new Volume(id, attached, created, destroyed, deviceId, diskOfferingDisplayText, diskOfferingId, + diskOfferingName, domain, domainId, hypervisor, isExtractable, jobId, jobStatus, name, + serviceOfferingDisplayText, serviceOfferingId, serviceOfferingName, size, snapshotId, state, storage, + storageType, type, virtualMachineId, vmDisplayName, vmName, vmState, zoneId, zoneName); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListISOsOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListISOsOptions.java index e66f80a337..9ec41646c7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListISOsOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListISOsOptions.java @@ -18,9 +18,9 @@ */ package org.jclouds.cloudstack.options; -import com.google.common.collect.ImmutableSet; import org.jclouds.cloudstack.domain.ISO; -import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; /** * Options for the ISO listISOs method. diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVMGroupsOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVMGroupsOptions.java index 1d1355d3b3..da8a29aaf3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVMGroupsOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVMGroupsOptions.java @@ -18,11 +18,10 @@ */ package org.jclouds.cloudstack.options; -import com.google.common.collect.ImmutableSet; -import org.jclouds.cloudstack.domain.NetworkType; -import org.jclouds.cloudstack.domain.TrafficType; import org.jclouds.http.options.BaseHttpRequestOptions; +import com.google.common.collect.ImmutableSet; + /** * Options used to control what VMGroups information is returned * diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java index f875f5a74e..8ed8e09266 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListVolumesOptions.java @@ -147,7 +147,7 @@ public class ListVolumesOptions extends AccountInDomainOptions { */ public static ListVolumesOptions isRecursive(boolean recursive) { ListVolumesOptions options = new ListVolumesOptions(); - return isRecursive(recursive); + return options.isRecursive(recursive); } /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/RegisterISOOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/RegisterISOOptions.java index 59999ff879..e1c5f539a8 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/RegisterISOOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/RegisterISOOptions.java @@ -19,7 +19,6 @@ package org.jclouds.cloudstack.options; import com.google.common.collect.ImmutableSet; -import org.jclouds.http.options.BaseHttpRequestOptions; /** * Options for the ISO registerISO method. diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotClientLiveTest.java index 9aed65b862..e394a313a6 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotClientLiveTest.java @@ -18,22 +18,24 @@ */ package org.jclouds.cloudstack.features; +import static com.google.common.collect.Iterables.find; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNotSame; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; + +import java.util.Set; + +import org.jclouds.cloudstack.domain.AsyncCreateResponse; +import org.jclouds.cloudstack.domain.Snapshot; +import org.jclouds.cloudstack.options.ListSnapshotsOptions; +import org.testng.annotations.Test; + import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import org.jclouds.cloudstack.domain.AsyncCreateResponse; -import org.jclouds.cloudstack.domain.Snapshot; -import org.jclouds.cloudstack.domain.Volume; -import org.jclouds.cloudstack.domain.Zone; -import org.jclouds.cloudstack.options.ListSnapshotsOptions; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.annotation.Nullable; -import java.util.Set; - -import static com.google.common.collect.Iterables.find; -import static org.testng.AssertJUnit.*; /** * Tests behavior of {@code SnapshotClient} @@ -42,17 +44,6 @@ import static org.testng.AssertJUnit.*; */ @Test(groups = "live", singleThreaded = true, testName = "SnapshotClientLiveTest") public class SnapshotClientLiveTest extends BaseCloudStackClientLiveTest { - protected String prefix = System.getProperty("user.name"); - - private long zoneId; - - @BeforeMethod(groups = "live") - public void setZoneId() { - Set zones = client.getZoneClient().listZones(); - assertNotNull(zones); - assertFalse(zones.isEmpty()); - zoneId = Iterables.get(zones, 0).getId(); - } public void testListSnapshots() { Set snapshots = client.getSnapshotClient().listSnapshots(); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java index 8e6b539ff2..f4178ba968 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java @@ -23,7 +23,12 @@ import static org.testng.Assert.assertTrue; import java.io.InputStream; -import org.jclouds.cloudstack.domain.*; +import org.jclouds.cloudstack.domain.AsyncJob; +import org.jclouds.cloudstack.domain.AsyncJobError; +import org.jclouds.cloudstack.domain.IPForwardingRule; +import org.jclouds.cloudstack.domain.PublicIPAddress; +import org.jclouds.cloudstack.domain.Template; +import org.jclouds.cloudstack.domain.TemplateExtraction; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.domain.JsonBall; import org.jclouds.http.HttpResponse; @@ -188,7 +193,7 @@ public class ParseAsyncJobFromHttpResponseTest { public void testOverloadedKeyName() { InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-createtemplate.json"); ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class); - AsyncJob response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + AsyncJob response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); assertTrue(response.getResult() instanceof Template, "response expected to be Template, actually is "+response.getResult().getClass()); is = getClass().getResourceAsStream("/queryasyncjobresultresponse-extracttemplate.json");