Repository: jclouds-labs
Updated Branches:
  refs/heads/master 436c001fb -> c4e36e72e


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java
 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java
index 4f03478..edb1d6a 100644
--- 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java
+++ 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/features/VolumeApi.java
@@ -16,13 +16,13 @@
  */
 package org.apache.jclouds.profitbricks.rest.features;
 
-import com.google.inject.Inject;
-import com.google.inject.TypeLiteral;
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Type;
+import java.net.URI;
 import java.util.List;
+
 import javax.inject.Named;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -30,6 +30,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+
 import 
org.apache.jclouds.profitbricks.rest.binder.volume.CreateSnapshotRequestBinder;
 import 
org.apache.jclouds.profitbricks.rest.binder.volume.CreateVolumeRequestBinder;
 import 
org.apache.jclouds.profitbricks.rest.binder.volume.RestoreSnapshotRequestBinder;
@@ -37,11 +38,12 @@ import 
org.apache.jclouds.profitbricks.rest.binder.volume.UpdateVolumeRequestBin
 import org.apache.jclouds.profitbricks.rest.domain.Snapshot;
 import org.apache.jclouds.profitbricks.rest.domain.Volume;
 import org.apache.jclouds.profitbricks.rest.domain.options.DepthOptions;
+import org.apache.jclouds.profitbricks.rest.functions.ParseRequestStatusURI;
+import org.apache.jclouds.profitbricks.rest.functions.RequestStatusURIParser;
 import org.apache.jclouds.profitbricks.rest.util.ParseId;
 import org.jclouds.Fallbacks;
 import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
 import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.http.functions.ParseJson;
 import org.jclouds.json.Json;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.MapBinder;
@@ -52,6 +54,9 @@ import org.jclouds.rest.annotations.ResponseParser;
 import org.jclouds.rest.annotations.SelectJson;
 import org.jclouds.util.Strings2;
 
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+
 @Path("/datacenters/{dataCenterId}/volumes")
 @RequestFilters(BasicAuthentication.class)
 public interface VolumeApi extends Closeable {
@@ -100,7 +105,8 @@ public interface VolumeApi extends Closeable {
    @DELETE
    @Path("/{volumeId}")
    @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
-   void deleteVolume(@PathParam("dataCenterId") String dataCenterId, 
@PathParam("volumeId") String volumeId);
+   @ResponseParser(ParseRequestStatusURI.class)
+   URI deleteVolume(@PathParam("dataCenterId") String dataCenterId, 
@PathParam("volumeId") String volumeId);
    
    @Named("volume:snapshot:create")
    @POST
@@ -111,17 +117,19 @@ public interface VolumeApi extends Closeable {
    @Named("volume:snapshot:restore")
    @POST
    @MapBinder(RestoreSnapshotRequestBinder.class)
-   void restoreSnapshot(@PayloadParam("snapshot") 
Volume.Request.RestoreSnapshotPayload payload);   
+   @ResponseParser(ParseRequestStatusURI.class)
+   URI restoreSnapshot(@PayloadParam("snapshot") 
Volume.Request.RestoreSnapshotPayload payload);   
    
-   static final class VolumeParser extends ParseJson<Volume> {
+   static final class VolumeParser extends RequestStatusURIParser<Volume> {
       
       final ParseId parseService;
       
-      @Inject VolumeParser(Json json, ParseId parseId) {
-         super(json, TypeLiteral.get(Volume.class));
+      @Inject VolumeParser(Json json, ParseId parseId, ParseRequestStatusURI 
parseRequestStatusURI) {
+         super(json, TypeLiteral.get(Volume.class), parseRequestStatusURI);
          this.parseService = parseId;
       }
       
+      @SuppressWarnings("unchecked")
       @Override
       public <V> V apply(InputStream stream, Type type) throws IOException {
          try {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/ParseRequestStatusURI.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/ParseRequestStatusURI.java
 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/ParseRequestStatusURI.java
new file mode 100644
index 0000000..e8070c3
--- /dev/null
+++ 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/ParseRequestStatusURI.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jclouds.profitbricks.rest.functions;
+
+import java.net.URI;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Function;
+import com.google.common.net.HttpHeaders;
+
+@Singleton
+public class ParseRequestStatusURI implements Function<HttpResponse, URI> {
+
+   @Override
+   @Nullable
+   public URI apply(HttpResponse input) {
+      String location = input.getFirstHeaderOrNull(HttpHeaders.LOCATION);
+      return location != null ? URI.create(location) : null;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/RequestStatusURIParser.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/RequestStatusURIParser.java
 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/RequestStatusURIParser.java
new file mode 100644
index 0000000..3a51d32
--- /dev/null
+++ 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/functions/RequestStatusURIParser.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jclouds.profitbricks.rest.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+
+import org.apache.jclouds.profitbricks.rest.domain.Trackable;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Get the response status URI, in case it is present.
+ */
+public class RequestStatusURIParser<T extends Trackable> extends ParseJson<T> {
+   
+   private final ParseRequestStatusURI parseRequestStatusURI;
+   protected URI requestStatusURI;
+
+   protected RequestStatusURIParser(Json json, TypeLiteral<T> type, 
ParseRequestStatusURI parseRequestStatusURI) {
+      super(json, type);
+      this.parseRequestStatusURI = checkNotNull(parseRequestStatusURI, 
"parseRequestStatusURI");
+   }
+
+   @Override
+   public T apply(HttpResponse from) {
+      T trackable = super.apply(from);
+      trackable.setRequestStatusUri(parseRequestStatusURI.apply(from));
+      return trackable;
+   }
+   
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ApiPredicatesModule.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ApiPredicatesModule.java
 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ApiPredicatesModule.java
deleted file mode 100644
index 2d1252a..0000000
--- 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ApiPredicatesModule.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jclouds.profitbricks.rest.util;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.base.Predicate;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Provides;
-import java.util.concurrent.TimeUnit;
-import javax.inject.Named;
-import javax.inject.Singleton;
-import org.apache.jclouds.profitbricks.rest.ProfitBricksApi;
-import static 
org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_MAX_PERIOD;
-import static 
org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PERIOD;
-import static 
org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
-import static 
org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_TIMEOUT;
-import org.apache.jclouds.profitbricks.rest.domain.ProvisioningState;
-import org.apache.jclouds.profitbricks.rest.domain.Server;
-import org.apache.jclouds.profitbricks.rest.ids.ServerRef;
-import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
-import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
-import static org.jclouds.util.Predicates2.retry;
-
-public class ApiPredicatesModule extends AbstractModule {
-
-   @Override
-   protected void configure() {
-   }
-
-   @Provides
-   @Singleton
-   @Named(POLL_PREDICATE_DATACENTER)
-   Predicate<String> provideDataCenterAvailablePredicate(final ProfitBricksApi 
api, ComputeConstants constants) {
-      return retry(new DataCenterProvisioningStatePredicate(
-              api, ProvisioningState.AVAILABLE),
-              constants.pollTimeout(), constants.pollPeriod(), 
constants.pollMaxPeriod(), TimeUnit.SECONDS);
-   }
-
-   @Provides
-   @Named(TIMEOUT_NODE_RUNNING)
-   Predicate<ServerRef> provideServerRunningPredicate(final ProfitBricksApi 
api, ComputeConstants constants) {
-      return retry(new ServerStatusPredicate(
-              api, Server.Status.RUNNING),
-              constants.pollTimeout(), constants.pollPeriod(), 
constants.pollMaxPeriod(), TimeUnit.SECONDS);
-   }
-
-   @Provides
-   @Named(TIMEOUT_NODE_SUSPENDED)
-   Predicate<ServerRef> provideServerSuspendedPredicate(final ProfitBricksApi 
api, ComputeConstants constants) {
-      return retry(new ServerStatusPredicate(
-              api, Server.Status.SHUTOFF),
-              constants.pollTimeout(), constants.pollPeriod(), 
constants.pollMaxPeriod(), TimeUnit.SECONDS);
-   }
-
-   static class DataCenterProvisioningStatePredicate implements 
Predicate<String> {
-
-      private final ProfitBricksApi api;
-      private final ProvisioningState expectedState;
-
-      public DataCenterProvisioningStatePredicate(ProfitBricksApi api, 
ProvisioningState expectedState) {
-         this.api = checkNotNull(api, "api must not be null");
-         this.expectedState = checkNotNull(expectedState, "expectedState must 
not be null");
-      }
-
-      @Override
-      public boolean apply(String input) {
-         checkNotNull(input, "datacenter id");
-         return 
api.dataCenterApi().getDataCenter(input).metadata().state().toString().equals(expectedState.toString());
-      }
-
-   }
-
-   static class ServerStatusPredicate implements Predicate<ServerRef> {
-
-      private final ProfitBricksApi api;
-      private final Server.Status expectedStatus;
-
-      public ServerStatusPredicate(ProfitBricksApi api, Server.Status 
expectedStatus) {
-         this.api = checkNotNull(api, "api must not be null");
-         this.expectedStatus = checkNotNull(expectedStatus, "expectedStatus 
must not be null");
-      }
-
-      @Override
-      public boolean apply(ServerRef serverRef) {
-         checkNotNull(serverRef, "serverRef");
-
-         Server server = api.serverApi().getServer(serverRef.dataCenterId(), 
serverRef.serverId());
-
-         if (server == null || server.properties().vmState() == null) {
-            return false;
-         }
-
-         return server.properties().vmState() == expectedStatus;
-      }
-
-   }
-
-   @Singleton
-   public static class ComputeConstants {
-
-      @Inject
-      @Named(POLL_TIMEOUT)
-      private String pollTimeout;
-
-      @Inject
-      @Named(POLL_PERIOD)
-      private String pollPeriod;
-
-      @Inject
-      @Named(POLL_MAX_PERIOD)
-      private String pollMaxPeriod;
-
-      public long pollTimeout() {
-         return Long.parseLong(pollTimeout);
-      }
-
-      public long pollPeriod() {
-         return Long.parseLong(pollPeriod);
-      }
-
-      public long pollMaxPeriod() {
-         return Long.parseLong(pollMaxPeriod);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ParseId.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ParseId.java
 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ParseId.java
index 594e105..2c46d9d 100644
--- 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ParseId.java
+++ 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/ParseId.java
@@ -35,6 +35,7 @@ public class ParseId {
       this.jsonBinder = checkNotNull(jsonBinder, "jsonBinder");
    }
    
+   @SuppressWarnings("serial")
    public String parseId (String json, String prefix, String key) {
          
       Type mapType = new TypeToken<Map<String, Object>>(){}.getType();

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/Trackables.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/Trackables.java
 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/Trackables.java
new file mode 100644
index 0000000..e501e20
--- /dev/null
+++ 
b/profitbricks-rest/src/main/java/org/apache/jclouds/profitbricks/rest/util/Trackables.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jclouds.profitbricks.rest.util;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import java.net.URI;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.apache.jclouds.profitbricks.rest.ProfitBricksApi;
+import org.apache.jclouds.profitbricks.rest.domain.RequestStatus;
+import org.apache.jclouds.profitbricks.rest.domain.Trackable;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Predicate;
+
+@Singleton
+public class Trackables {
+   private final ProfitBricksApi api;
+   private final Predicate<URI> requestCompletedPredicate;
+
+   @Inject
+   Trackables(ProfitBricksApi api, Predicate<URI> requestCompletedPredicate) {
+      this.api = api;
+      this.requestCompletedPredicate = requestCompletedPredicate;
+   }
+
+   public void waitUntilRequestCompleted(Trackable trackable) {
+      if (trackable.requestStatusUri().isPresent()) {
+         requestCompletedPredicate.apply(trackable.requestStatusUri().get());
+         RequestStatus status = 
api.getRequestStatus(trackable.requestStatusUri().get());
+
+         String entityName = trackable.getClass().getSimpleName();
+         if (entityName.contains("AutoValue")) {
+            entityName = entityName.substring(entityName.lastIndexOf('_') + 1);
+         }
+
+         checkState(RequestStatus.Status.DONE == status.metadata().status(), 
"%s creation failed: %s", entityName,
+               status.metadata().message());
+      }
+   }
+
+   public void waitUntilRequestCompleted(@Nullable URI uri) {
+      if (uri != null) {
+         requestCompletedPredicate.apply(uri);
+         RequestStatus status = api.getRequestStatus(uri);
+         checkState(RequestStatus.Status.DONE == status.metadata().status(), 
"Request %s failed: %s", uri, status
+               .metadata().message());
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinderTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinderTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinderTest.java
index 77124b0..e5f26a4 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinderTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachCdromRequestBinderTest.java
@@ -29,6 +29,7 @@ import org.testng.annotations.Test;
 @Test(groups = "unit", testName = "AttachCdromRequestBinderTest")
 public class AttachCdromRequestBinderTest extends BinderTestBase {
 
+   @SuppressWarnings("serial")
    @Test
    public void testCreatePayload() {
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinderTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinderTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinderTest.java
index 6d6c52c..55ea354 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinderTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/server/AttachVolumeRequestBinderTest.java
@@ -29,6 +29,7 @@ import org.testng.annotations.Test;
 @Test(groups = "unit", testName = "AttachVolumeRequestBinderTest")
 public class AttachVolumeRequestBinderTest  extends BinderTestBase {
 
+   @SuppressWarnings("serial")
    @Test
    public void testCreatePayload() {
       

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinderTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinderTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinderTest.java
index f0e543a..26c3d9b 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinderTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/CreateSnapshotRequestBinderTest.java
@@ -29,6 +29,7 @@ import org.testng.annotations.Test;
 @Test(groups = "unit", testName = "CreateSnapshotRequestBinderTest")
 public class CreateSnapshotRequestBinderTest extends BinderTestBase {
 
+   @SuppressWarnings("resource")
    @Test
    public void testCreatePayload() {
             

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinderTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinderTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinderTest.java
index 6627b71..d047e5e 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinderTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/binder/volume/UpdateVolumeRequestBinderTest.java
@@ -29,6 +29,7 @@ import org.testng.annotations.Test;
 @Test(groups = "unit", testName = "UpdateVolumeRequestBinderTest")
 public class UpdateVolumeRequestBinderTest extends BinderTestBase {
 
+   @SuppressWarnings("serial")
    @Test
    public void testCreatePayload() {
       

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/concurrent/ProvisioningManagerTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/concurrent/ProvisioningManagerTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/concurrent/ProvisioningManagerTest.java
index 08b90e4..575d8e9 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/concurrent/ProvisioningManagerTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/compute/concurrent/ProvisioningManagerTest.java
@@ -70,7 +70,7 @@ public class ProvisioningManagerTest {
       private final AtomicInteger completedJobs;
 
       public MockJob(long delay, String group, AtomicInteger completedJobs) {
-         super(sleepPredicate(delay), group, Suppliers.ofInstance((Object) 0));
+         super(sleepPredicate(delay), null, group, 
Suppliers.ofInstance((Object) 0));
          this.delay = delay;
          this.completedJobs = completedJobs;
       }
@@ -92,7 +92,7 @@ public class ProvisioningManagerTest {
    private static class ShutdownExecutorJob extends ProvisioningJob {
 
       public ShutdownExecutorJob(final ProvisioningManager manager, final 
AtomicInteger completedJobs) {
-         super(Predicates.<String>alwaysTrue(), "shutdown", new 
Supplier<Object>() {
+         super(Predicates.<String>alwaysTrue(), null, "shutdown", new 
Supplier<Object>() {
             @Override
             public Integer get() {
                try {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiLiveTest.java
index 83922ec..852d66a 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiLiveTest.java
@@ -60,6 +60,7 @@ public class DataCenterApiLiveTest extends 
BaseProfitBricksLiveTest {
       DataCenter dataCenter = createDataCenter();
       
       dataCenter = dataCenterApi().update(dataCenter.id(), 
"test-data-center2");
+      assertRequestCompleted(dataCenter);
       
       assertNotNull(dataCenter);
       assertEquals(dataCenter.properties().name(), "test-data-center2");

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java
index 22d5ae2..d5cf594 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/DataCenterApiMockTest.java
@@ -17,6 +17,8 @@
 package org.apache.jclouds.profitbricks.rest.features;
 
 import com.squareup.okhttp.mockwebserver.MockResponse;
+
+import java.net.URI;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
 import org.apache.jclouds.profitbricks.rest.domain.Location;
@@ -89,12 +91,14 @@ public class DataCenterApiMockTest extends 
BaseProfitBricksApiMockTest {
    public void testCreate() throws InterruptedException {
       server.enqueue(
               new 
MockResponse().setBody(stringFromResource("/datacenter/get.json"))
+                 .addHeader("Location", "http://foo/bar";)
       );
 
       DataCenter dataCenter = dataCenterApi().create("test-data-center", 
"example description", Location.US_LAS.getId());
 
       assertNotNull(dataCenter);
       assertNotNull(dataCenter.id());
+      assertEquals(dataCenter.requestStatusUri().get(), 
URI.create("http://foo/bar";));
 
       assertEquals(server.getRequestCount(), 1);
       assertSent(server, "POST", "/datacenters",
@@ -105,10 +109,10 @@ public class DataCenterApiMockTest extends 
BaseProfitBricksApiMockTest {
    @Test
    public void testUpdate() throws InterruptedException {
       server.enqueue(
-              new 
MockResponse().setBody(stringFromResource("/datacenter/get.json"))
+            new 
MockResponse().setBody(stringFromResource("/datacenter/get.json"))
       );
 
-      DataCenter dataCenter = dataCenterApi().update("some-id", "new name");
+      dataCenterApi().update("some-id", "new name");
 
       assertEquals(server.getRequestCount(), 1);
       assertSent(server, "PATCH", "/datacenters/some-id", "{\"name\": \"new 
name\"}");
@@ -116,9 +120,11 @@ public class DataCenterApiMockTest extends 
BaseProfitBricksApiMockTest {
 
    @Test
    public void testDelete() throws InterruptedException {
-      server.enqueue(response204());
+      server.enqueue(response204().addHeader("Location", "http://foo/bar";));
 
-      dataCenterApi().delete("some-id");
+      URI statusURI = dataCenterApi().delete("some-id");
+      
+      assertEquals(statusURI, URI.create("http://foo/bar";));
       assertEquals(server.getRequestCount(), 1);
       assertSent(server, "DELETE", "/datacenters/some-id");
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java
index 30912ca..1063145 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/FirewallApiLiveTest.java
@@ -18,6 +18,8 @@ package org.apache.jclouds.profitbricks.rest.features;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
+
+import java.net.URI;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
 import org.apache.jclouds.profitbricks.rest.domain.State;
@@ -55,6 +57,7 @@ public class FirewallApiLiveTest extends 
BaseProfitBricksLiveTest {
             .ram(1024)
             .build());
       
+      assertRequestCompleted(testServer);
       assertNodeAvailable(ServerRef.create(dataCenter.id(), testServer.id()));
             
       testNic = nicApi().create(
@@ -65,6 +68,7 @@ public class FirewallApiLiveTest extends 
BaseProfitBricksLiveTest {
               .lan(1)
               .build());
 
+      assertRequestCompleted(testNic);
       assertNicAvailable(testNic);
    }
    
@@ -89,6 +93,7 @@ public class FirewallApiLiveTest extends 
BaseProfitBricksLiveTest {
               .portRangeEnd(600)
               .build());
 
+      assertRequestCompleted(testFirewallRule);
       assertNotNull(testFirewallRule);
       assertEquals(testFirewallRule.properties().name(), "jclouds-firewall");
       assertFirewallRuleAvailable(testFirewallRule);
@@ -120,7 +125,7 @@ public class FirewallApiLiveTest extends 
BaseProfitBricksLiveTest {
    public void testUpdateFirewallRule() {
       assertDataCenterAvailable(dataCenter);
       
-      firewallApi().update(FirewallRule.Request.updatingBuilder()
+      FirewallRule updated = 
firewallApi().update(FirewallRule.Request.updatingBuilder()
               .dataCenterId(testFirewallRule.dataCenterId())
               .serverId(testServer.id())
               .nicId(testNic.id())
@@ -128,7 +133,7 @@ public class FirewallApiLiveTest extends 
BaseProfitBricksLiveTest {
               .name("apache-firewall")
               .build());
 
-      assertFirewallRuleAvailable(testFirewallRule);
+      assertFirewallRuleAvailable(updated);
       
       FirewallRule firewallRule = firewallApi().get(dataCenter.id(), 
testServer.id(), testNic.id(), testFirewallRule.id());
       
@@ -138,7 +143,8 @@ public class FirewallApiLiveTest extends 
BaseProfitBricksLiveTest {
 
    @Test(dependsOnMethods = "testUpdateFirewallRule")
    public void testDeleteFirewallRule() {
-      firewallApi().delete(testFirewallRule.dataCenterId(), testServer.id(), 
testNic.id(), testFirewallRule.id());
+      URI uri = firewallApi().delete(testFirewallRule.dataCenterId(), 
testServer.id(), testNic.id(), testFirewallRule.id());
+      assertRequestCompleted(uri);
       assertFirewallRuleRemoved(testFirewallRule);
    } 
    

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java
index c88ccda..5965f8c 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/IpblockApiLiveTest.java
@@ -17,6 +17,8 @@
 package org.apache.jclouds.profitbricks.rest.features;
 
 import com.google.common.base.Predicate;
+
+import java.net.URI;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.IpBlock;
 import org.apache.jclouds.profitbricks.rest.domain.Location;
@@ -42,13 +44,15 @@ public class IpblockApiLiveTest extends 
BaseProfitBricksLiveTest {
    public void setupTest() {
       testIpBlock = ipBlockApi().create(IpBlock.Request.creatingBuilder()
               .properties(IpBlock.PropertiesRequest.create("jclouds ipBlock", 
Location.US_LAS.getId(), 1)).build());
+      assertRequestCompleted(testIpBlock);
       assertIpBlockAvailable(testIpBlock);
    }
 
    @AfterClass(alwaysRun = true)
    public void teardownTest() {
       if (testIpBlock != null) {
-         ipBlockApi().delete(testIpBlock.id());
+         URI uri = ipBlockApi().delete(testIpBlock.id());
+         assertRequestCompleted(uri);
          assertIpBlockRemoved(testIpBlock);
 
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiLiveTest.java
index 44b260c..d49b8e0 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/LanApiLiveTest.java
@@ -16,28 +16,30 @@
  */
 package org.apache.jclouds.profitbricks.rest.features;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
 import java.util.List;
+
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
-import org.apache.jclouds.profitbricks.rest.domain.Snapshot;
-import org.apache.jclouds.profitbricks.rest.domain.State;
 import org.apache.jclouds.profitbricks.rest.domain.Lan;
+import org.apache.jclouds.profitbricks.rest.domain.State;
 import org.apache.jclouds.profitbricks.rest.internal.BaseProfitBricksLiveTest;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 
 @Test(groups = "live", testName = "LanApiLiveTest")
 public class LanApiLiveTest extends BaseProfitBricksLiveTest {
    
    private DataCenter dataCenter;
    private Lan testLan;
-   private Snapshot testSnapshot;
   
    @BeforeClass
    public void setupTest() {
@@ -60,6 +62,7 @@ public class LanApiLiveTest extends BaseProfitBricksLiveTest {
               .name("jclouds-lan")
               .build());
 
+      assertRequestCompleted(testLan);
       assertNotNull(testLan);
       assertEquals(testLan.properties().name(), "jclouds-lan");
       assertLanAvailable(testLan);
@@ -91,14 +94,15 @@ public class LanApiLiveTest extends 
BaseProfitBricksLiveTest {
    public void testUpdateLan() {
       assertDataCenterAvailable(dataCenter);
       
-      api.lanApi().update(
+      Lan updated = api.lanApi().update(
               Lan.Request.updatingBuilder()
               .dataCenterId(testLan.dataCenterId())
               .id(testLan.id())
               .isPublic(false)
               .build());
 
-      assertLanAvailable(testLan);
+      assertRequestCompleted(updated);
+      assertLanAvailable(updated);
       
       Lan lan = lanApi().get(dataCenter.id(), testLan.id());
       
@@ -107,7 +111,8 @@ public class LanApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testUpdateLan")
    public void testDeleteLan() {
-      lanApi().delete(testLan.dataCenterId(), testLan.id());
+      URI uri = lanApi().delete(testLan.dataCenterId(), testLan.id());
+      assertRequestCompleted(uri);
       assertLanRemoved(testLan);
    }
    

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiLiveTest.java
index ceb9ab3..16350d9 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/NicApiLiveTest.java
@@ -17,6 +17,8 @@
 package org.apache.jclouds.profitbricks.rest.features;
 
 import com.google.common.base.Predicate;
+
+import java.net.URI;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
 import org.apache.jclouds.profitbricks.rest.domain.Nic;
@@ -50,6 +52,7 @@ public class NicApiLiveTest extends BaseProfitBricksLiveTest {
             .ram(1024)
             .build());
       
+      assertRequestCompleted(testServer);
       assertNodeAvailable(ServerRef.create(dataCenter.id(), testServer.id()));
    }
    
@@ -71,6 +74,7 @@ public class NicApiLiveTest extends BaseProfitBricksLiveTest {
               .lan(1)
               .build());
 
+      assertRequestCompleted(testNic);
       assertNotNull(testNic);
       assertEquals(testNic.properties().name(), "jclouds-nic");
       assertNicAvailable(testNic);
@@ -98,7 +102,7 @@ public class NicApiLiveTest extends BaseProfitBricksLiveTest 
{
    public void testUpdateNic() {
       assertDataCenterAvailable(dataCenter);
       
-      nicApi().update(
+      Nic updated = nicApi().update(
               Nic.Request.updatingBuilder()
               .dataCenterId(testNic.dataCenterId())
               .serverId(testServer.id())
@@ -106,7 +110,8 @@ public class NicApiLiveTest extends 
BaseProfitBricksLiveTest {
               .name("apache-nic")
               .build());
 
-      assertNicAvailable(testNic);
+      assertRequestCompleted(updated);
+      assertNicAvailable(updated);
       
       Nic nic = nicApi().get(dataCenter.id(), testServer.id(), testNic.id());
       
@@ -116,7 +121,8 @@ public class NicApiLiveTest extends 
BaseProfitBricksLiveTest {
 
    @Test(dependsOnMethods = "testUpdateNic", alwaysRun = true)
    public void testDeleteNic() {
-      nicApi().delete(testNic.dataCenterId(), testServer.id(), testNic.id());
+      URI uri = nicApi().delete(testNic.dataCenterId(), testServer.id(), 
testNic.id());
+      assertRequestCompleted(uri);
       assertNicRemoved(testNic);
    } 
       

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java
index e81b8fb..2527547 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/ServerApiLiveTest.java
@@ -17,6 +17,8 @@
 package org.apache.jclouds.profitbricks.rest.features;
 
 import com.google.common.base.Predicate;
+
+import java.net.URI;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.CpuFamily;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
@@ -68,6 +70,7 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
               .ram(1024)
               .build());
       
+      assertRequestCompleted(testServer);
       assertNotNull(testServer);
       assertEquals(testServer.properties().name(), "jclouds-node");
       assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id()));
@@ -94,7 +97,7 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    public void testUpdateServer() {
       assertDataCenterAvailable(dataCenter);
       
-      api.serverApi().updateServer(
+      Server updated = api.serverApi().updateServer(
               Server.Request.updatingBuilder()
               .id(testServer.id())
               .dataCenterId(testServer.dataCenterId())
@@ -103,6 +106,7 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
               .cores(2)
               .build());
       
+      assertRequestCompleted(updated);
       assertNodeAvailable(ServerRef.create(dataCenter.id(), testServer.id()));
       assertDataCenterAvailable(dataCenter);
       assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id()));
@@ -114,7 +118,8 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testUpdateServer")
    public void testStopServer() {
-      serverApi().stopServer(testServer.dataCenterId(), testServer.id());
+      URI uri = serverApi().stopServer(testServer.dataCenterId(), 
testServer.id());
+      assertRequestCompleted(uri);
       assertNodeSuspended(ServerRef.create(dataCenter.id(), testServer.id()));
       
       Server server = serverApi().getServer(testServer.dataCenterId(), 
testServer.id());
@@ -123,7 +128,8 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testStopServer")
    public void testStartServer() {
-      serverApi().startServer(testServer.dataCenterId(), testServer.id());
+      URI uri = serverApi().startServer(testServer.dataCenterId(), 
testServer.id());
+      assertRequestCompleted(uri);
       assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id()));
       
       Server server = serverApi().getServer(testServer.dataCenterId(), 
testServer.id());
@@ -132,7 +138,8 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testStartServer")
    public void testRebootServer() {
-      serverApi().rebootServer(testServer.dataCenterId(), testServer.id());
+      URI uri = serverApi().rebootServer(testServer.dataCenterId(), 
testServer.id());
+      assertRequestCompleted(uri);
       assertNodeRunning(ServerRef.create(dataCenter.id(), testServer.id()));
       
       Server server = serverApi().getServer(testServer.dataCenterId(), 
testServer.id());
@@ -147,9 +154,7 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testListVolumes")
    public void testAttachVolume() {
-      
       Volume volume = createVolume(dataCenter);
-      
       assertVolumeAvailable(VolumeRef.create(dataCenter.id(), volume.id()));
       
       attachedVolume = serverApi().attachVolume(
@@ -160,6 +165,7 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
               .build()
       );
       
+      assertRequestCompleted(attachedVolume);
       assertVolumeAttached(testServer, volume.id());
       
       List<Volume> volumes = 
serverApi().listAttachedVolumes(testServer.dataCenterId(), testServer.id());
@@ -174,7 +180,8 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testGetVolume")
    public void testDetachVolume() {
-      serverApi().detachVolume(testServer.dataCenterId(), testServer.id(), 
attachedVolume.id());
+      URI uri = serverApi().detachVolume(testServer.dataCenterId(), 
testServer.id(), attachedVolume.id());
+      assertRequestCompleted(uri);
       assertVolumeDetached(testServer, attachedVolume.id());
    }
    
@@ -193,6 +200,7 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
               .imageId("7cb4b3a3-50c3-11e5-b789-52540066fee9")
               .build()
       );
+      assertRequestCompleted(attachedCdrom);
       assertEquals(attachedCdrom.properties().name(), 
"ubuntu-14.04.3-server-amd64.iso");
       assertCdromAvailable(testServer, attachedCdrom.id());
       
@@ -208,13 +216,15 @@ public class ServerApiLiveTest extends 
BaseProfitBricksLiveTest {
    
    @Test(dependsOnMethods = "testRetrieveAttachedCdrom")
    public void testDetachCdrom() {
-      serverApi().detachCdrom(testServer.dataCenterId(), testServer.id(), 
attachedCdrom.id());
+      URI uri = serverApi().detachCdrom(testServer.dataCenterId(), 
testServer.id(), attachedCdrom.id());
+      assertRequestCompleted(uri);
       assertCdromRemoved(testServer, attachedCdrom.id());
    }
    
    @Test(dependsOnMethods = "testDetachCdrom")
    public void testDeleteServer() {
-      serverApi().deleteServer(testServer.dataCenterId(), testServer.id());
+      URI uri = serverApi().deleteServer(testServer.dataCenterId(), 
testServer.id());
+      assertRequestCompleted(uri);
       assertNodeRemoved(ServerRef.create(dataCenter.id(), testServer.id()));
    }
    

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java
index c3ade07..b845f63 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/SnapshotApiLiveTest.java
@@ -18,9 +18,10 @@ package org.apache.jclouds.profitbricks.rest.features;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
+
+import java.net.URI;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
-import org.apache.jclouds.profitbricks.rest.domain.LicenceType;
 import org.apache.jclouds.profitbricks.rest.domain.ProvisioningState;
 import org.apache.jclouds.profitbricks.rest.domain.Snapshot;
 import org.apache.jclouds.profitbricks.rest.domain.State;
@@ -47,15 +48,7 @@ public class SnapshotApiLiveTest extends 
BaseProfitBricksLiveTest {
       dataCenter = createDataCenter();
       assertDataCenterAvailable(dataCenter);
 
-      testVolume = api.volumeApi().createVolume(
-              Volume.Request.creatingBuilder()
-              .dataCenterId(dataCenter.id())
-              .name("jclouds-volume")
-              .size(3)
-              .licenceType(LicenceType.LINUX)
-              .build()
-      );
-
+      testVolume = createVolume(dataCenter);
       assertNotNull(testVolume);
       assertVolumeAvailable(testVolume);
 
@@ -67,6 +60,7 @@ public class SnapshotApiLiveTest extends 
BaseProfitBricksLiveTest {
               .description("snapshot desc...")
               .build());
 
+      assertRequestCompleted(testSnapshot);
       assertSnapshotAvailable(testSnapshot);
    }
 
@@ -110,13 +104,15 @@ public class SnapshotApiLiveTest extends 
BaseProfitBricksLiveTest {
               .build()
       );
 
+      assertRequestCompleted(snapshot);
       assertVolumeAvailable(testVolume);
       assertEquals(snapshot.properties().name(), "test-snapshot new name");
    }
 
    @Test(dependsOnMethods = "testUpdateSnapshot")
    public void testDeleteSnapshot() {
-      api.volumeApi().deleteVolume(testVolume.dataCenterId(), testVolume.id());
+      URI uri = api.volumeApi().deleteVolume(testVolume.dataCenterId(), 
testVolume.id());
+      assertRequestCompleted(uri);
       assertVolumeRemoved(testVolume);
       snapshotApi().delete(testSnapshot.id());
       assertSnapshotRemoved(testSnapshot);

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java
index 98c8090..e6f244a 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/features/VolumeApiLiveTest.java
@@ -17,6 +17,8 @@
 package org.apache.jclouds.profitbricks.rest.features;
 
 import com.google.common.base.Predicate;
+
+import java.net.URI;
 import java.util.HashSet;
 import java.util.List;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
@@ -90,6 +92,7 @@ public class VolumeApiLiveTest extends 
BaseProfitBricksLiveTest {
               .sshKeys(sshKeys)
               .build());
 
+      assertRequestCompleted(testVolume);
       assertNotNull(testVolume);
       assertEquals(testVolume.properties().name(), "jclouds-volume");
       assertVolumeAvailable(testVolume);
@@ -123,7 +126,8 @@ public class VolumeApiLiveTest extends 
BaseProfitBricksLiveTest {
               .name("apache-volume")
               .build());
 
-      assertVolumeAvailable(testVolume);
+      assertRequestCompleted(volume);
+      assertVolumeAvailable(volume);
       assertEquals(volume.properties().name(), "apache-volume");
    }
 
@@ -137,24 +141,27 @@ public class VolumeApiLiveTest extends 
BaseProfitBricksLiveTest {
               .description("snapshot desc...")
               .build());
 
+      assertRequestCompleted(testSnapshot);
       assertSnapshotAvailable(testSnapshot);
    }
 
    @Test(dependsOnMethods = "testCreateSnapshot")
    public void testRestoreSnapshot() {
-      volumeApi().restoreSnapshot(
+      URI uri = volumeApi().restoreSnapshot(
               Volume.Request.restoreSnapshotBuilder()
               .dataCenterId(testVolume.dataCenterId())
               .volumeId(testVolume.id())
               .snapshotId(testSnapshot.id())
               .build()
       );
+      assertRequestCompleted(uri);
       assertVolumeAvailable(testVolume);
    }
 
    @Test(dependsOnMethods = "testRestoreSnapshot")
    public void testDeleteVolume() {
-      volumeApi().deleteVolume(testVolume.dataCenterId(), testVolume.id());
+      URI uri = volumeApi().deleteVolume(testVolume.dataCenterId(), 
testVolume.id());
+      assertRequestCompleted(uri);
       assertVolumeRemoved(testVolume);
       api.snapshotApi().delete(testSnapshot.id());
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java
index cbe8a62..bc36ef4 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksApiMockTest.java
@@ -16,29 +16,31 @@
  */
 package org.apache.jclouds.profitbricks.rest.internal;
 
-import com.google.common.base.Charsets;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.io.Resources;
 import static 
com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
-import com.google.gson.JsonParser;
-import com.google.inject.Module;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
+import static org.testng.Assert.assertEquals;
+
 import java.io.IOException;
 import java.util.Properties;
 import java.util.Set;
+
 import org.apache.jclouds.profitbricks.rest.ProfitBricksApi;
 import org.apache.jclouds.profitbricks.rest.ProfitBricksProviderMetadata;
 import org.jclouds.ContextBuilder;
 import org.jclouds.concurrent.config.ExecutorServiceModule;
-import org.jclouds.json.Json;
+import org.jclouds.http.filters.BasicAuthentication;
 import org.jclouds.rest.ApiContext;
-import static org.testng.Assert.assertEquals;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
-import org.jclouds.http.filters.BasicAuthentication;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.io.Resources;
+import com.google.gson.JsonParser;
+import com.google.inject.Module;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import com.squareup.okhttp.mockwebserver.RecordedRequest;
 
 public class BaseProfitBricksApiMockTest {
 
@@ -49,7 +51,6 @@ public class BaseProfitBricksApiMockTest {
 
    protected MockWebServer server;
    protected ProfitBricksApi api;
-   private Json json;
 
    // So that we can ignore formatting.
    private final JsonParser parser = new JsonParser();
@@ -64,7 +65,6 @@ public class BaseProfitBricksApiMockTest {
              .modules(modules)
              .overrides(overrides())
              .build();
-      json = ctx.utils().injector().getInstance(Json.class);
       api = ctx.getApi();
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java
index e1c3145..2766d48 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/internal/BaseProfitBricksLiveTest.java
@@ -16,37 +16,42 @@
  */
 package org.apache.jclouds.profitbricks.rest.internal;
 
-import com.google.common.base.Joiner;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Names;
+import static 
org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
+import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
+
 import org.apache.jclouds.profitbricks.rest.ProfitBricksApi;
 import 
org.apache.jclouds.profitbricks.rest.compute.config.ProfitBricksComputeServiceContextModule.ComputeConstants;
 import org.apache.jclouds.profitbricks.rest.config.ProfitBricksRateLimitModule;
-
-import static 
org.apache.jclouds.profitbricks.rest.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
 import org.apache.jclouds.profitbricks.rest.domain.DataCenter;
 import org.apache.jclouds.profitbricks.rest.domain.LicenceType;
 import org.apache.jclouds.profitbricks.rest.domain.Location;
-import static org.apache.jclouds.profitbricks.rest.domain.Location.US_LAS;
 import org.apache.jclouds.profitbricks.rest.domain.Nic;
 import org.apache.jclouds.profitbricks.rest.domain.Server;
 import org.apache.jclouds.profitbricks.rest.domain.State;
+import org.apache.jclouds.profitbricks.rest.domain.Trackable;
 import org.apache.jclouds.profitbricks.rest.domain.Volume;
 import org.apache.jclouds.profitbricks.rest.domain.VolumeType;
 import org.apache.jclouds.profitbricks.rest.ids.ServerRef;
 import org.apache.jclouds.profitbricks.rest.ids.VolumeRef;
+import org.apache.jclouds.profitbricks.rest.util.Trackables;
 import org.jclouds.apis.BaseApiLiveTest;
-import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
-import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
 import org.jclouds.util.Predicates2;
-import static org.testng.Assert.assertTrue;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.name.Names;
 
 public class BaseProfitBricksLiveTest extends BaseApiLiveTest<ProfitBricksApi> 
{
 
@@ -58,6 +63,7 @@ public class BaseProfitBricksLiveTest extends 
BaseApiLiveTest<ProfitBricksApi> {
    private Predicate<ServerRef> serverAvailable;
    private Predicate<ServerRef> serverRemoved;
    private Predicate<VolumeRef> volumeAvailable;
+   private Trackables trackables;
 
    ComputeConstants computeConstants;
 
@@ -72,10 +78,10 @@ public class BaseProfitBricksLiveTest extends 
BaseApiLiveTest<ProfitBricksApi> {
 
    @Override
    protected ProfitBricksApi create(Properties props, Iterable<Module> 
modules) {
-
       Injector injector = 
newBuilder().modules(modules).overrides(props).buildInjector();
 
       computeConstants = injector.getInstance(ComputeConstants.class);
+      trackables = injector.getInstance(Trackables.class);
 
       dataCenterAvailable = injector.getInstance(
               Key.get(new TypeLiteral<Predicate<String>>() {
@@ -171,6 +177,14 @@ public class BaseProfitBricksLiveTest extends 
BaseApiLiveTest<ProfitBricksApi> {
       assertTrue(volumeAvailable.apply(volumeRef),
               String.format("Volume %s wasn't available in the configured 
timeout", volumeRef.volumeId()));
    }
+   
+   protected void assertRequestCompleted(URI uri) {
+      trackables.waitUntilRequestCompleted(uri);
+   }
+   
+   protected void assertRequestCompleted(Trackable trackable) {
+      trackables.waitUntilRequestCompleted(trackable);
+   }
 
    protected void assertNicAvailable(Nic nic) {
       assertPredicate(new Predicate<Nic>() {
@@ -188,15 +202,18 @@ public class BaseProfitBricksLiveTest extends 
BaseApiLiveTest<ProfitBricksApi> {
    }
 
    protected DataCenter createDataCenter() {
-      return api.dataCenterApi().create("test-data-center", "example 
description", US_LAS.getId());
+      DataCenter datacenter = api.dataCenterApi().create("test-data-center", 
"example description", US_LAS.getId());
+      assertRequestCompleted(datacenter);
+      return api.dataCenterApi().getDataCenter(datacenter.id());
    }
 
    protected void deleteDataCenter(String id) {
-      api.dataCenterApi().delete(id);
+      URI statusURI = api.dataCenterApi().delete(id);
+      assertRequestCompleted(statusURI);
    }
 
    protected Volume createVolume(DataCenter dataCenter) {
-      return api.volumeApi().createVolume(
+      Volume volume = api.volumeApi().createVolume(
               Volume.Request.creatingBuilder()
               .dataCenterId(dataCenter.id())
               .name("jclouds-volume")
@@ -204,6 +221,8 @@ public class BaseProfitBricksLiveTest extends 
BaseApiLiveTest<ProfitBricksApi> {
               .type(VolumeType.HDD)
               .licenceType(LicenceType.LINUX)
               .build());
+      assertRequestCompleted(volume);
+      return api.volumeApi().getVolume(dataCenter.id(), volume.id());
    }
 
    protected String complexId(String... ids) {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c4e36e72/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/util/ParseIdTest.java
----------------------------------------------------------------------
diff --git 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/util/ParseIdTest.java
 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/util/ParseIdTest.java
index f1e0499..bd4b0d4 100644
--- 
a/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/util/ParseIdTest.java
+++ 
b/profitbricks-rest/src/test/java/org/apache/jclouds/profitbricks/rest/util/ParseIdTest.java
@@ -32,6 +32,7 @@ import org.testng.annotations.Test;
 @Test(groups = "unit", testName = "ParseIdTest")
 public class ParseIdTest {
 
+   @SuppressWarnings("serial")
    @Test
    public void testIdExtraction() throws IOException {
       String serverResult = 
Resources.toString(getClass().getResource("/server/get.json"), Charsets.UTF_8);

Reply via email to