fixed some quality issues

This commit is contained in:
Adrian Cole 2011-11-27 11:30:19 -05:00
parent a530b5b5d6
commit 4c835851de
8 changed files with 33 additions and 40 deletions

View File

@ -44,11 +44,10 @@ public class BindSnapshotPolicyScheduleToQueryParam implements Binder {
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider"); this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
} }
@SuppressWarnings("unchecked")
@Override @Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) { public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule"); 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()); R modifiedResult = ModifyRequest.addQueryParam(request, "intervaltype", schedule.getInterval(), uriBuilderProvider.get());
modifiedResult = ModifyRequest.addQueryParam(modifiedResult, "schedule", schedule.getTime(), uriBuilderProvider.get()); modifiedResult = ModifyRequest.addQueryParam(modifiedResult, "schedule", schedule.getTime(), uriBuilderProvider.get());
return modifiedResult; return modifiedResult;

View File

@ -63,6 +63,7 @@ public class Volume implements Comparable<Volume> {
private long snapshotId; private long snapshotId;
private String state; private String state;
private String storage; private String storage;
// TODO enum
private String storageType; private String storageType;
private VolumeType type; private VolumeType type;
private long virtualMachineId; private long virtualMachineId;
@ -223,11 +224,10 @@ public class Volume implements Comparable<Volume> {
} }
public Volume build() { public Volume build() {
return new Volume(id, attached, created, destroyed, deviceId, diskOfferingDisplayText, return new Volume(id, attached, created, destroyed, deviceId, diskOfferingDisplayText, diskOfferingId,
diskOfferingId, diskOfferingName, domain, domainId, hypervisor, isExtractable, diskOfferingName, domain, domainId, hypervisor, isExtractable, jobId, jobStatus, name,
jobId, jobStatus, name, serviceOfferingDisplayText, serviceOfferingId, serviceOfferingDisplayText, serviceOfferingId, serviceOfferingName, size, snapshotId, state, storage,
serviceOfferingName, size, snapshotId, state, storage, storage, type, virtualMachineId, storageType, type, virtualMachineId, vmDisplayName, vmName, vmState, zoneId, zoneName);
vmDisplayName, vmName, vmState, zoneId, zoneName);
} }
} }

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.cloudstack.options; package org.jclouds.cloudstack.options;
import com.google.common.collect.ImmutableSet;
import org.jclouds.cloudstack.domain.ISO; import org.jclouds.cloudstack.domain.ISO;
import org.jclouds.http.options.BaseHttpRequestOptions;
import com.google.common.collect.ImmutableSet;
/** /**
* Options for the ISO listISOs method. * Options for the ISO listISOs method.

View File

@ -18,11 +18,10 @@
*/ */
package org.jclouds.cloudstack.options; 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 org.jclouds.http.options.BaseHttpRequestOptions;
import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what VMGroups information is returned * Options used to control what VMGroups information is returned
* *

View File

@ -147,7 +147,7 @@ public class ListVolumesOptions extends AccountInDomainOptions {
*/ */
public static ListVolumesOptions isRecursive(boolean recursive) { public static ListVolumesOptions isRecursive(boolean recursive) {
ListVolumesOptions options = new ListVolumesOptions(); ListVolumesOptions options = new ListVolumesOptions();
return isRecursive(recursive); return options.isRecursive(recursive);
} }
/** /**

View File

@ -19,7 +19,6 @@
package org.jclouds.cloudstack.options; package org.jclouds.cloudstack.options;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.jclouds.http.options.BaseHttpRequestOptions;
/** /**
* Options for the ISO registerISO method. * Options for the ISO registerISO method.

View File

@ -18,22 +18,24 @@
*/ */
package org.jclouds.cloudstack.features; 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.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; 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} * Tests behavior of {@code SnapshotClient}
@ -42,17 +44,6 @@ import static org.testng.AssertJUnit.*;
*/ */
@Test(groups = "live", singleThreaded = true, testName = "SnapshotClientLiveTest") @Test(groups = "live", singleThreaded = true, testName = "SnapshotClientLiveTest")
public class SnapshotClientLiveTest extends BaseCloudStackClientLiveTest { public class SnapshotClientLiveTest extends BaseCloudStackClientLiveTest {
protected String prefix = System.getProperty("user.name");
private long zoneId;
@BeforeMethod(groups = "live")
public void setZoneId() {
Set<Zone> zones = client.getZoneClient().listZones();
assertNotNull(zones);
assertFalse(zones.isEmpty());
zoneId = Iterables.get(zones, 0).getId();
}
public void testListSnapshots() { public void testListSnapshots() {
Set<Snapshot> snapshots = client.getSnapshotClient().listSnapshots(); Set<Snapshot> snapshots = client.getSnapshotClient().listSnapshots();

View File

@ -23,7 +23,12 @@ import static org.testng.Assert.assertTrue;
import java.io.InputStream; 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.date.internal.SimpleDateFormatDateService;
import org.jclouds.domain.JsonBall; import org.jclouds.domain.JsonBall;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
@ -188,7 +193,7 @@ public class ParseAsyncJobFromHttpResponseTest {
public void testOverloadedKeyName() { public void testOverloadedKeyName() {
InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-createtemplate.json"); InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-createtemplate.json");
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class); 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()); assertTrue(response.getResult() instanceof Template, "response expected to be Template, actually is "+response.getResult().getClass());
is = getClass().getResourceAsStream("/queryasyncjobresultresponse-extracttemplate.json"); is = getClass().getResourceAsStream("/queryasyncjobresultresponse-extracttemplate.json");