You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2015/06/26 14:44:56 UTC
[21/50] [abbrv] jclouds git commit: Updated TargetHttpProxyOptions,
TargetPoolCreationOptions, UrlMapOptions to AutoValue + Builder
Updated TargetHttpProxyOptions, TargetPoolCreationOptions, UrlMapOptions to AutoValue + Builder
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/0f67b625
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/0f67b625
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/0f67b625
Branch: refs/heads/master
Commit: 0f67b6250579e7de749671bdfaacc2d8fba1e085
Parents: 2ba48dc
Author: Daniel Broudy <br...@google.com>
Authored: Fri Dec 19 13:29:09 2014 -0800
Committer: Ignasi Barrera <na...@apache.org>
Committed: Fri Jan 9 23:14:14 2015 +0100
----------------------------------------------------------------------
.../binders/TargetPoolCreationBinder.java | 75 ------
.../features/TargetHttpProxyApi.java | 1 +
.../features/TargetPoolApi.java | 5 +-
.../googlecomputeengine/features/UrlMapApi.java | 1 +
.../options/HttpHealthCheckCreationOptions.java | 2 +-
.../options/TargetHttpProxyOptions.java | 76 +++---
.../options/TargetPoolCreationOptions.java | 195 +++++++-------
.../options/UrlMapOptions.java | 264 +++++++++----------
.../binders/TargetPoolCreationBinderTest.java | 72 -----
.../features/ForwardingRuleApiLiveTest.java | 7 +-
.../GlobalForwardingRuleApiLiveTest.java | 4 +-
.../features/HttpHealthCheckApiLiveTest.java | 2 +-
.../features/HttpHealthCheckApiMockTest.java | 2 +-
.../features/TargetHttpProxyApiLiveTest.java | 19 +-
.../features/TargetHttpProxyApiMockTest.java | 15 ++
.../features/TargetPoolApiLiveTest.java | 19 +-
.../features/TargetPoolApiMockTest.java | 4 +-
.../features/UrlMapApiLiveTest.java | 38 +--
.../features/UrlMapApiMockTest.java | 13 +-
.../resources/target_http_proxy_insert.json | 5 +-
20 files changed, 326 insertions(+), 493 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinder.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinder.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinder.java
deleted file mode 100644
index 1d52859..0000000
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinder.java
+++ /dev/null
@@ -1,75 +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.jclouds.googlecomputeengine.binders;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
-import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions.SessionAffinityValue;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-
-public class TargetPoolCreationBinder extends BindToJsonPayload {
-
- @Inject TargetPoolCreationBinder(Json jsonBinder) {
- super(jsonBinder);
- }
-
- @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- TargetPoolCreationOptions options = (TargetPoolCreationOptions) postParams.get("options");
- String name = postParams.get("name").toString();
- TargetPoolBinderHelper targetPoolBinderHelper = new TargetPoolBinderHelper(name, options);
- return super.bindToRequest(request, targetPoolBinderHelper);
- }
-
- private class TargetPoolBinderHelper{
-
- /**
- * Values used to bind TargetPoolCreationOptions to json request.
- */
- @SuppressWarnings("unused")
- private String name;
- @SuppressWarnings("unused")
- private List<URI> healthChecks;
- @SuppressWarnings("unused")
- private List<URI> instances;
- @SuppressWarnings("unused")
- private SessionAffinityValue sessionAffinity;
- @SuppressWarnings("unused")
- private Float failoverRatio;
- @SuppressWarnings("unused")
- private URI backupPool;
- @SuppressWarnings("unused")
- private String description;
-
- private TargetPoolBinderHelper(String name, TargetPoolCreationOptions targetPoolCreationOptions){
- this.name = name;
- this.healthChecks = targetPoolCreationOptions.getHealthChecks();
- this.instances = targetPoolCreationOptions.getInstances();
- this.sessionAffinity = targetPoolCreationOptions.getSessionAffinity();
- this.failoverRatio = targetPoolCreationOptions.getFailoverRatio();
- this.backupPool = targetPoolCreationOptions.getBackupPool();
- this.description = targetPoolCreationOptions.getDescription();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApi.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApi.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApi.java
index abb0bf4..97c45d4 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApi.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApi.java
@@ -83,6 +83,7 @@ public interface TargetHttpProxyApi {
@Path("/global/targetHttpProxies")
Operation create(@BinderParam(BindToJsonPayload.class) TargetHttpProxyOptions targetHttpProxyOptions);
+ //TODO (broudy) : Should we remove this because it is redundant?
/**
* Creates a targetHttpProxy resource in the specified project using the given URI for the urlMap.
*
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
index e623c12..6d57086 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
@@ -38,7 +38,6 @@ import org.jclouds.googlecloud.domain.ListPage;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder;
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder;
-import org.jclouds.googlecomputeengine.binders.TargetPoolCreationBinder;
import org.jclouds.googlecomputeengine.domain.HealthStatus;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.TargetPool;
@@ -47,6 +46,7 @@ import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthFilter;
+import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@@ -82,8 +82,7 @@ public interface TargetPoolApi {
@Named("TargetPools:insert")
@POST
@Produces(APPLICATION_JSON)
- @MapBinder(TargetPoolCreationBinder.class)
- Operation create(@PayloadParam("name") String name, @PayloadParam("options") TargetPoolCreationOptions options);
+ Operation create(@BinderParam(BindToJsonPayload.class) TargetPoolCreationOptions options);
/** Deletes a target pool by name and returns the operation in progress, or null if not found. */
@Named("TargetPools:delete")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/UrlMapApi.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/UrlMapApi.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/UrlMapApi.java
index 25783d2..d77c542 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/UrlMapApi.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/UrlMapApi.java
@@ -113,6 +113,7 @@ public interface UrlMapApi {
/**
* Updates the specified urlMap resource, with patch semantics, with the data included in the request.
+ * Note:{@link UrlMapOptions.Builder#buildForPatch()} may be helpful.
*
* @param urlMapName the name urlMap to be updated.
* @param urlMapOptions the new urlMap options.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
index 1e49f2b..6902232 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java
@@ -161,7 +161,7 @@ public abstract class HttpHealthCheckCreationOptions {
* Useful when performing a PATCH operation and you do not want to overwrite
* unspecified values with the default values.
*/
- public HttpHealthCheckCreationOptions buildNoDefaults() {
+ public HttpHealthCheckCreationOptions buildForPatch() {
return HttpHealthCheckCreationOptions.create(host, requestPath, port,
checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java
index 94dd75a..0fa01c9 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java
@@ -16,60 +16,52 @@
*/
package org.jclouds.googlecomputeengine.options;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.net.URI;
import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
-public final class TargetHttpProxyOptions {
+import com.google.auto.value.AutoValue;
- private String name;
- @Nullable private String description;
- private URI urlMap;
+@AutoValue
+public abstract class TargetHttpProxyOptions {
- /**
- * Name of the TargetHttpProxy resource.
- * @return name, provided by the client.
- */
- public String getName(){
- return name;
- }
+ public abstract String name();
+ @Nullable public abstract String description();
+ public abstract URI urlMap();
- /**
- * @see TargetHttpProxyOptions#getName()
- */
- public TargetHttpProxyOptions name(String name) {
- this.name = name;
- return this;
+ @SerializedNames({ "name", "description", "urlMap"})
+ static TargetHttpProxyOptions create(String name, String description, URI urlMap) {
+ return new AutoValue_TargetHttpProxyOptions(name, description, urlMap);
}
- /**
- * An optional textual description of the TargetHttpProxy.
- * @return description, provided by the client.
- */
- public String getDescription(){
- return description;
+ TargetHttpProxyOptions() {
}
- /**
- * @see TargetHttpProxyOptions#getDescription()
- */
- public TargetHttpProxyOptions description(String description) {
- this.description = description;
- return this;
- }
+ public static class Builder {
+ private String name;
+ private String description;
+ private URI urlMap;
- /**
- * URL to the UrlMap resource that defines the mapping from URL to the BackendService.
- */
- public URI getUrlMap() {
- return urlMap;
- }
+ public Builder(String name, URI urlMap) {
+ this.name = name;
+ this.urlMap = urlMap;
+ }
+
+ /**
+ * @see TargetHttpProxyOptions#getDescription()
+ */
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
- /**
- * @see TargetHttpProxyOptions#getUrlMap()
- */
- public TargetHttpProxyOptions urlMap(URI urlMap) {
- this.urlMap = urlMap;
- return this;
+ public TargetHttpProxyOptions build() {
+ checkNotNull(name, "TargetHttpProxyOptions name cannot be null");
+ checkNotNull(urlMap, "TargetHttpProxyOptions name cannot be null");
+ return create(name, description, urlMap);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java
index 4864148..31ba738 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java
@@ -16,17 +16,24 @@
*/
package org.jclouds.googlecomputeengine.options;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.net.URI;
import java.util.List;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
/**
* Options for creating a Target Pool
- *
*/
-public class TargetPoolCreationOptions{
+@AutoValue
+public abstract class TargetPoolCreationOptions{
/**
- * Session affinity determines the hash method that
+ * Session affinity determines the hash method that
* Google Compute Engine uses to distribute traffic.
* @see <a href="https://cloud.google.com/compute/docs/reference/latest/targetPools#resource"/>
*/
@@ -36,116 +43,100 @@ public class TargetPoolCreationOptions{
NONE
}
- private List<URI> healthChecks;
- private List<URI> instances;
- private SessionAffinityValue sessionAffinity;
- private Float failoverRatio;
- private URI backupPool;
- private String description;
+ public abstract String name();
+ @Nullable public abstract List<URI> healthChecks();
+ @Nullable public abstract List<URI> instances();
+ @Nullable public abstract SessionAffinityValue sessionAffinity();
+ @Nullable public abstract Float failoverRatio();
+ @Nullable public abstract URI backupPool();
+ @Nullable public abstract String description();
- /**
- * The set of HealthChecks
- *
- * @return a set of HealthCheck URIs
- */
- public List<URI> getHealthChecks(){
- return healthChecks;
+ @SerializedNames({ "name", "healthChecks", "instances", "sessionAffinity", "failoverRatio",
+ "backupPool", "description"})
+ public static TargetPoolCreationOptions create(String name, List<URI> healthChecks, List<URI> instances,
+ SessionAffinityValue sessionAffinity, Float failoverRatio, URI backupPool, String description) {
+ return new AutoValue_TargetPoolCreationOptions(name, healthChecks, instances, sessionAffinity, failoverRatio,
+ backupPool, description);
}
- /**
- * A List of resource URIs to the member VMs serving this pool.
- * They must live in zones contained in the same region as this pool.
- *
- * @return set of instance URIs
- */
- public List<URI> getInstances(){
- return instances;
+ TargetPoolCreationOptions() {
}
- /**
- * Defines the session affinity option.
- * Session affinity determines the hash method that Google Compute Engine uses to distribute traffic.
- * @return
- */
- public SessionAffinityValue getSessionAffinity(){
- return sessionAffinity;
- }
+ public static class Builder {
- /**
- * This field is applicable only when the target pool is serving a forwarding rule as the primary pool
- * (e.g. not as a backup pool to some other target pool).
- * The value of the a float between [0, 1].
- * If set, backupPool must also be set.
- * @return failoverRatio, a float between [0, 1]
- */
- public Float getFailoverRatio(){
- return failoverRatio;
- }
+ private String name;
+ private List<URI> healthChecks;
+ private List<URI> instances;
+ private SessionAffinityValue sessionAffinity;
+ private Float failoverRatio;
+ private URI backupPool;
+ private String description;
- /**
- * This field is applicable only when the target pool is serving a forwarding rule as the primary pool
- * (e.g. not as a backup pool to some other target pool). Must be a fully-qualified URL to a target pool that is in the same region as the primary target pool.
- * If set, failoverRatio must also be set
- * @return backupPool, Fully-qualified URI to a target pool in the same region as primary target pool
- */
- public URI getBackupPool(){
- return backupPool;
- }
-
- /**
- * An optional textual description of the TargetPool.
- * @return description, provided by the client.
- */
- public String getDescription(){
- return description;
- }
+ public Builder(String name){
+ checkNotNull(name, "TargetPoolCreationOptions name cannot be null");
+ this.name = name;
+ }
- /**
- * @see TargetPoolCreationOptions#getHealthChecks()
- */
- public TargetPoolCreationOptions healthChecks(List<URI> healthChecks){
- this.healthChecks = healthChecks;
- return this;
- }
+ /** The set of HealthChecks */
+ public Builder healthChecks(List<URI> healthChecks){
+ this.healthChecks = healthChecks;
+ return this;
+ }
- /**
- * @see TargetPoolCreationOptions#getInstances()
- */
- public TargetPoolCreationOptions instances(List<URI> instances){
- this.instances = instances;
- return this;
- }
+ /**
+ * A List of resource URIs to the member VMs serving this pool.
+ * They must live in zones contained in the same region as this pool.
+ */
+ public Builder instances(List<URI> instances){
+ this.instances = instances;
+ return this;
+ }
- /**
- * @see TargetPoolCreationOptions#getSessionAffinity()
- */
- public TargetPoolCreationOptions sessionAffinity(SessionAffinityValue sessionAffinity){
- this.sessionAffinity = sessionAffinity;
- return this;
- }
+ /**
+ * Defines the session affinity option.
+ * Session affinity determines the hash method that Google Compute Engine uses to distribute traffic.
+ */
+ public Builder sessionAffinity(SessionAffinityValue sessionAffinity){
+ this.sessionAffinity = sessionAffinity;
+ return this;
+ }
- /**
- * @see TargetPoolCreationOptions#getFailoverRatio()
- */
- public TargetPoolCreationOptions failoverRatio(float failoverRatio){
- this.failoverRatio = failoverRatio;
- return this;
- }
+ /**
+ * This field is applicable only when the target pool is serving a forwarding rule as the primary pool
+ * (e.g. not as a backup pool to some other target pool).
+ * The value of the a float between [0, 1].
+ * If set, backupPool must also be set.
+ * @return failoverRatio, a float between [0, 1]
+ */
+ public Builder failoverRatio(float failoverRatio){
+ this.failoverRatio = failoverRatio;
+ return this;
+ }
- /**
- * @see TargetPoolCreationOptions#getBackupPool()
- */
- public TargetPoolCreationOptions backupPool(URI backupPool){
- this.backupPool = backupPool;
- return this;
- }
-
- /**
- * @see TargetPoolCreationOptions#getDescription()
- */
- public TargetPoolCreationOptions description(String description){
- this.description = description;
- return this;
- }
+ /**
+ * This field is applicable only when the target pool is serving a forwarding rule as the primary pool
+ * (e.g. not as a backup pool to some other target pool). Must be a fully-qualified URL to a target pool
+ * that is in the same region as the primary target pool.
+ * If set, failoverRatio must also be set
+ * @return backupPool, Fully-qualified URI to a target pool in the same region as primary target pool
+ */
+ public Builder backupPool(URI backupPool){
+ this.backupPool = backupPool;
+ return this;
+ }
+ /**
+ * An optional textual description of the TargetPool.
+ * @return description, provided by the client.
+ */
+ public Builder description(String description){
+ this.description = description;
+ return this;
+ }
+
+ public TargetPoolCreationOptions build() {
+ return create(name, healthChecks, instances, sessionAffinity, failoverRatio,
+ backupPool, description);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java
index b47aaf9..e569e79 100644
--- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java
+++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.googlecomputeengine.options;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.net.URI;
import java.util.List;
@@ -23,151 +25,121 @@ import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule;
import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher;
import org.jclouds.googlecomputeengine.domain.UrlMap.UrlMapTest;
import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.collect.ImmutableList;
-
-public class UrlMapOptions {
-
- private String name;
- @Nullable private String description;
- private List<HostRule> hostRules;
- private List<PathMatcher> pathMatchers;
- private List<UrlMapTest> tests;
- private URI defaultService;
- private String fingerprint;
-
- /**
- * Name of the UrlMap resource.
- * @return name, provided by the client.
- */
- public String getName(){
- return name;
- }
-
- /**
- * @see UrlMapOptions#getName()
- */
- public UrlMapOptions name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * An optional textual description of the UrlMap.
- * @return description, provided by the client.
- */
- public String getDescription(){
- return description;
- }
-
- /**
- * @see UrlMapOptions#getDescription()
- */
- public UrlMapOptions description(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * Rules for matching and directing incoming hosts.
- */
- public List<HostRule> getHostRules() {
- return hostRules;
- }
-
- /**
- * @see UrlMapOptions#getHostRules()
- */
- public UrlMapOptions hostRules(List<HostRule> hostRules) {
- this.hostRules = hostRules;
- return this;
- }
-
- /**
- * @see UrlMapOptions#getHostRules()
- */
- public UrlMapOptions hostRule(HostRule hostRule){
- this.hostRules = ImmutableList.of(hostRule);
- return this;
- }
-
- /**
- * The list of named PathMatchers to use against the URL.
- */
- public List<PathMatcher> getPathMatchers() {
- return pathMatchers;
- }
-
- /**
- * @see UrlMapOptions#getPathMatchers()
- */
- public UrlMapOptions pathMatcher(PathMatcher pathMatcher) {
- this.pathMatchers = ImmutableList.of(pathMatcher);
- return this;
- }
-
- /**
- * @see UrlMapOptions#getPathMatchers()
- */
- public UrlMapOptions pathMatchers(List<PathMatcher> pathMatchers) {
- this.pathMatchers = pathMatchers;
- return this;
- }
-
- /**
- * The list of expected URL mappings. Request to update this
- * UrlMap will succeed only all of the test cases pass.
- */
- public List<UrlMapTest> getTests() {
- return tests;
- }
-
- /**
- * @see UrlMapOptions#getTests()
- */
- public UrlMapOptions test(UrlMapTest urlMapTest) {
- this.tests = ImmutableList.of(urlMapTest);
- return this;
- }
-
- /**
- * @see UrlMapOptions#getTests()
- */
- public UrlMapOptions urlMapTests(List<UrlMapTest> urlMapTests) {
- this.tests = urlMapTests;
- return this;
- }
-
- /**
- * The URL of the BackendService resource if none of the hostRules match.
- */
- public URI getDefaultService() {
- return defaultService;
- }
-
- /**
- * @see UrlMapOptions#getDefaultService()
- */
- public UrlMapOptions defaultService(URI defaultService) {
- this.defaultService = defaultService;
- return this;
- }
-
- /**
- * Fingerprint of this resource. A hash of the contents stored in this object.
- * This field is used in optimistic locking. This field will be ignored when
- * inserting a UrlMap. An up-to-date fingerprint must be provided in order to
- * update the UrlMap.
- */
- public String getFingerprint() {
- return fingerprint;
- }
-
- /**
- * @see UrlMapOptions#getFingerprint()
- */
- public UrlMapOptions fingerprint(String fingerprint) {
- this.fingerprint = fingerprint;
- return this;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class UrlMapOptions {
+
+ @Nullable public abstract String name();
+ @Nullable public abstract String description();
+ @Nullable public abstract List<HostRule> hostRules();
+ @Nullable public abstract List<PathMatcher> pathMatchers();
+ @Nullable public abstract List<UrlMapTest> tests();
+ @Nullable public abstract URI defaultService();
+ @Nullable public abstract String fingerprint();
+
+ @SerializedNames({ "name", "description", "hostRules", "pathMatchers", "tests",
+ "defaultService", "fingerprint"})
+ static UrlMapOptions create(String name, String description, List<HostRule> hostRules,
+ List<PathMatcher> pathMatchers, List<UrlMapTest> tests, URI defaultService, String fingerprint) {
+ return new AutoValue_UrlMapOptions(name, description, hostRules,
+ pathMatchers, tests, defaultService, fingerprint);
+ }
+
+ UrlMapOptions(){
+ }
+
+ public static class Builder {
+
+ private String name;
+ private String description;
+ private List<HostRule> hostRules;
+ private List<PathMatcher> pathMatchers;
+ private List<UrlMapTest> tests;
+ private URI defaultService;
+ private String fingerprint;
+
+ /**
+ * Name of the UrlMap resource.
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * An optional textual description of the UrlMap.
+ */
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * Rules for matching and directing incoming hosts.
+ */
+ public Builder hostRules(List<HostRule> hostRules) {
+ this.hostRules = hostRules;
+ return this;
+ }
+
+ /**
+ * The list of named PathMatchers to use against the URL.
+ */
+ public Builder pathMatchers(List<PathMatcher> pathMatchers) {
+ this.pathMatchers = pathMatchers;
+ return this;
+ }
+
+ /**
+ * The list of expected URL mappings. Request to update this
+ * UrlMap will succeed only all of the test cases pass.
+ */
+ public Builder tests(List<UrlMapTest> tests) {
+ this.tests = tests;
+ return this;
+ }
+
+ /**
+ * The URL of the BackendService resource if none of the hostRules match.
+ */
+ public Builder defaultService(URI defaultService) {
+ this.defaultService = defaultService;
+ return this;
+ }
+
+ /**
+ * Fingerprint of this resource. A hash of the contents stored in this object.
+ * This field is used in optimistic locking. This field will be ignored when
+ * inserting a UrlMap. An up-to-date fingerprint must be provided in order to
+ * update the UrlMap.
+ */
+ public Builder fingerprint(String fingerprint) {
+ this.fingerprint = fingerprint;
+ return this;
+ }
+
+ /**
+ * Builds the UrlMapOptions.
+ * Note: This enforces that "name" and "defaultService" are not null as the GCE API expects.
+ * If you are patching an existing UrlMap you may wish to use {@link #buildForPatch()} instead.
+ */
+ public UrlMapOptions build() {
+ checkNotNull(name, "In UrlMapOptions: A UrlMap name cannot be null, if patching an existing UrlMap use buildForPatch() instead of build()");
+ checkNotNull(defaultService, "In UrlMapOptions: A UrlMap defaultService cannot be null, if patching an existing UrlMap use buildForPatch() instead of build()");
+ return create(name, description, hostRules, pathMatchers, tests,
+ defaultService, fingerprint);
+ }
+
+ /**
+ * This build option is specifically for when patching an existing UrlMap.
+ * If not patching an existing urlMap it is recommended that you use {@link #build()}.
+ */
+ public UrlMapOptions buildForPatch() {
+ return create(name, description, hostRules, pathMatchers, tests,
+ defaultService, fingerprint);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
deleted file mode 100644
index f55e938..0000000
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
+++ /dev/null
@@ -1,72 +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.jclouds.googlecomputeengine.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
-import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions.SessionAffinityValue;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.json.internal.GsonWrapper;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.Gson;
-
-@Test(groups = "unit", testName = "TargetPoolCreationBinderTest")
-public class TargetPoolCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
-
- private static final List<URI> FAKE_HEALTH_CHECKS = ImmutableList.of(
- URI.create("https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20141017"));
- private static SessionAffinityValue SESSION_AFFINITY = SessionAffinityValue.CLIENT_IP_PROTO;
- private static float FAILOVER_RATIO = (float) 0.4;
- private static String DESCRIPTION = "This is a test!";
-
- Json json = new GsonWrapper(new Gson());
-
- @Test
- public void testMap() throws SecurityException, NoSuchMethodException {
- TargetPoolCreationBinder binder = new TargetPoolCreationBinder(json);
- TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
- .healthChecks(FAKE_HEALTH_CHECKS)
- .sessionAffinity(SESSION_AFFINITY)
- .failoverRatio(FAILOVER_RATIO)
- .description(DESCRIPTION);
-
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
- Map<String, Object> postParams = ImmutableMap.of("name", "testTargetPoolName", "options", targetPoolCreationOptions);
-
- binder.bindToRequest(request, postParams);
-
- assertEquals(request.getPayload().getRawContent(),
- "{\""
- + "name\":\"testTargetPoolName\","
- + "\"healthChecks\":[\"" + FAKE_HEALTH_CHECKS.toArray()[0] + "\"],"
- + "\"sessionAffinity\":\"CLIENT_IP_PROTO\","
- + "\"failoverRatio\":0.4,"
- + "\"description\":\"This is a test!\""
- + "}");
- assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
index 257c4bc..2f03623 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
@@ -61,11 +61,12 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
@BeforeClass
public void init() {
- TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
- assertOperationDoneSuccessfully(targetPoolApi().create(TARGETPOOL_NAME, targetPoolCreationOptions));
+ TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME).build();
+ assertOperationDoneSuccessfully(targetPoolApi().create(targetPoolCreationOptions));
targetPool = targetPoolApi().get(TARGETPOOL_NAME);
- assertOperationDoneSuccessfully(targetPoolApi().create(TARGETPOOL_NAME_NEW, targetPoolCreationOptions));
+ targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME_NEW).build();
+ assertOperationDoneSuccessfully(targetPoolApi().create(targetPoolCreationOptions));
newTargetPool = targetPoolApi().get(TARGETPOOL_NAME_NEW);
assertOperationDoneSuccessfully(addressApi().create(ADDRESS_NAME));
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
index 31df698..a3656a0 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiLiveTest.java
@@ -66,9 +66,9 @@ public class GlobalForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiL
assertOperationDoneSuccessfully(api.backendServices()
.create(b));
- UrlMapOptions map = new UrlMapOptions().name(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)
+ UrlMapOptions map = new UrlMapOptions.Builder().name(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)
.description("simple url map")
- .defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME));
+ .defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME)).build();
assertOperationDoneSuccessfully(api.urlMaps()
.create(map));
assertOperationDoneSuccessfully(api.targetHttpProxies()
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
index ec2cad8..49e9cc5 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
@@ -78,7 +78,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
.port(options.port() + OFFSET)
.checkIntervalSec(options.checkIntervalSec() + OFFSET)
.timeoutSec(options.timeoutSec() + OFFSET)
- .buildNoDefaults();
+ .buildForPatch();
assertOperationDoneSuccessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions));
// Check changes happened and others unchanged.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
index ebc86fe..9efa8d9 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
@@ -91,7 +91,7 @@ public class HttpHealthCheckApiMockTest extends BaseGoogleComputeEngineApiMockTe
server.enqueue(jsonResponse("/global_operation.json"));
HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
- .timeoutSec(0).unhealthyThreshold(0).buildNoDefaults();
+ .timeoutSec(0).unhealthyThreshold(0).buildForPatch();
assertEquals(httpHealthCheckApi().patch("http-health-check", options),
new ParseGlobalOperationTest().expected(url("/projects")));
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java
index 2a4e517..ef3abae 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java
@@ -57,12 +57,14 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
assertOperationDoneSuccessfully(api.backendServices().create(b));
- UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
- .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
+ UrlMapOptions map = new UrlMapOptions.Builder().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
+ .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME)).build();
assertOperationDoneSuccessfully(api.urlMaps().create(map));
- UrlMapOptions map2 = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2").description("a second simple url map")
- .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
+ UrlMapOptions map2 = new UrlMapOptions.Builder().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")
+ .description("a second simple url map")
+ .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME))
+ .build();
assertOperationDoneSuccessfully(api.urlMaps().create(map2));
@@ -78,13 +80,8 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
@Test(groups = "live", dependsOnMethods = "testGetTargetHttpProxy")
public void testSetUrlMapTargetHttpProxy() {
- UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
- .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
- assertOperationDoneSuccessfully(api.urlMaps()
- .create(map));
-
assertOperationDoneSuccessfully(api().setUrlMap(TARGET_HTTP_PROXY_NAME,
- getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")));
+ getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")));
}
@Test(groups = "live", dependsOnMethods = "testSetUrlMapTargetHttpProxy")
@@ -97,7 +94,7 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2"));
}
- @Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy")
+ @Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy", alwaysRun = true)
public void testDeleteTargetHttpProxy() {
assertOperationDoneSuccessfully(api().delete(TARGET_HTTP_PROXY_NAME));
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
index 08d3e85..cd9a825 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
@@ -23,6 +23,7 @@ import static org.testng.AssertJUnit.assertNull;
import java.net.URI;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.options.TargetHttpProxyOptions;
import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest;
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest;
@@ -55,6 +56,20 @@ public class TargetHttpProxyApiMockTest extends BaseGoogleComputeEngineApiMockTe
stringFromResource("/target_http_proxy_insert.json"));
}
+ public void insert_options() throws Exception {
+ server.enqueue(jsonResponse("/operation.json"));
+
+ URI urlMap = URI.create(url("/projects/myproject/global/urlMaps/jclouds-test"));
+ TargetHttpProxyOptions options = new TargetHttpProxyOptions.Builder("jclouds-test", urlMap).description("test").build();
+ assertEquals(targetHttpProxyApi().create(options), new ParseOperationTest().expected(url("/projects")));
+ assertSent(server, "POST", "/projects/party/global/targetHttpProxies",
+ "{" +
+ " \"name\": \"jclouds-test\"," +
+ " \"urlMap\": \"" + url("/projects/myproject/global/urlMaps/jclouds-test") + "\"," +
+ " \"description\": \"test\"" +
+ "}");
+ }
+
public void delete() throws Exception {
server.enqueue(jsonResponse("/operation.json"));
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
index d94a616..c2423bc 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
@@ -126,10 +126,11 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertTargetPool() {
- TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
+ TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(BACKUP_TARGETPOOL_NAME)
.description(DESCRIPTION_BACKUP)
- .sessionAffinity(SessionAffinityValue.CLIENT_IP);
- assertOperationDoneSuccessfully(api().create(BACKUP_TARGETPOOL_NAME, targetPoolCreationOptions));
+ .sessionAffinity(SessionAffinityValue.CLIENT_IP)
+ .build();
+ assertOperationDoneSuccessfully(api().create(targetPoolCreationOptions));
}
@Test(groups = "live", dependsOnMethods = "testInsertTargetPool")
@@ -137,12 +138,13 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
assertNotNull(targetPool);
// Make a Target Pool with a backup and failoverRatio specified.
- TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
+ TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME)
.description(DESCRIPTION)
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
.backupPool(targetPool.selfLink())
- .failoverRatio((float) 0.5);
- assertOperationDoneSuccessfully(api().create(TARGETPOOL_NAME, targetPoolCreationOptions));
+ .failoverRatio((float) 0.5)
+ .build();
+ assertOperationDoneSuccessfully(api().create(targetPoolCreationOptions));
TargetPool targetPool2 = api().get(TARGETPOOL_NAME);
assertNotNull(targetPool2);
assertEquals(targetPool2.name(), TARGETPOOL_NAME);
@@ -222,8 +224,9 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2"})
public void testListBackupTargetPool() {
- TargetPoolCreationOptions options = new TargetPoolCreationOptions().description("A targetPool for testing setBackup.");
- assertOperationDoneSuccessfully(api().create(THIRD_TARGETPOOL_NAME, options));
+ TargetPoolCreationOptions options = new TargetPoolCreationOptions.Builder(THIRD_TARGETPOOL_NAME)
+ .description("A targetPool for testing setBackup.").build();
+ assertOperationDoneSuccessfully(api().create(options));
TargetPool targetPool = api().get(THIRD_TARGETPOOL_NAME);
assertNotNull(targetPool);
assertEquals(targetPool.name(), THIRD_TARGETPOOL_NAME);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
index f45a384..5f579ec 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiMockTest.java
@@ -54,8 +54,8 @@ public class TargetPoolApiMockTest extends BaseGoogleComputeEngineApiMockTest {
public void insert() throws Exception {
server.enqueue(jsonResponse("/region_operation.json"));
- TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
- assertEquals(targetPoolApi().create("test", targetPoolCreationOptions),
+ TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder("test").build();
+ assertEquals(targetPoolApi().create(targetPoolCreationOptions),
new ParseRegionOperationTest().expected(url("/projects")));
assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools",
stringFromResource("/targetpool_insert.json"));
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java
index f47d96e..f48e44a 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java
@@ -58,8 +58,8 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
.healthChecks(healthChecks);
assertOperationDoneSuccessfully(api.backendServices().create(b));
- UrlMapOptions map = new UrlMapOptions().name(URL_MAP_NAME).description("simple url map")
- .defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME));
+ UrlMapOptions map = new UrlMapOptions.Builder().name(URL_MAP_NAME).description("simple url map")
+ .defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME)).build();
assertOperationDoneSuccessfully(api().create(map));
@@ -100,11 +100,11 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher"));
- UrlMapOptions options = new UrlMapOptions().name(URL_MAP_NAME)
+ UrlMapOptions options = new UrlMapOptions.Builder().name(URL_MAP_NAME)
.pathMatchers(matchers)
.hostRules(hostRules)
.defaultService(service)
- .fingerprint(fingerprint);
+ .fingerprint(fingerprint).build();
assertOperationDoneSuccessfully(api().update(URL_MAP_NAME, options));
@@ -119,8 +119,8 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service);
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
- UrlMapOptions options = new UrlMapOptions().urlMapTests(urlMapTests)
- .fingerprint(fingerprint);
+ UrlMapOptions options = new UrlMapOptions.Builder().tests(urlMapTests)
+ .fingerprint(fingerprint).buildForPatch();
assertOperationDoneSuccessfully(api().patch(URL_MAP_NAME, options));
// Update options with settings it should have for later assertions.
@@ -132,11 +132,15 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher"));
- options.name(URL_MAP_NAME)
+
+ options = new UrlMapOptions.Builder().name(URL_MAP_NAME)
.description("simple url map")
.pathMatchers(matchers)
.hostRules(hostRules)
- .defaultService(service);
+ .defaultService(service)
+ .tests(urlMapTests)
+ .fingerprint(fingerprint)
+ .build();
assertUrlMapEquals(api().get(URL_MAP_NAME), options);
}
@@ -163,14 +167,14 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service);
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
- UrlMapOptions options = new UrlMapOptions();
-
- options.pathMatchers(matchers)
+ UrlMapOptions options = new UrlMapOptions.Builder()
+ .pathMatchers(matchers)
.name(URL_MAP_NAME)
.hostRules(hostRules)
- .urlMapTests(urlMapTests)
+ .tests(urlMapTests)
.defaultService(service)
- .description("simple url map");
+ .description("simple url map")
+ .build();
UrlMapValidateResult results = api().validate(URL_MAP_NAME, options);
UrlMapValidateResult expected = UrlMapValidateResult.allPass();
@@ -196,9 +200,9 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
}
private void assertUrlMapEquals(UrlMap result, UrlMapOptions expected) {
- assertEquals(result.name(), expected.getName());
- assertEquals(result.defaultService(), expected.getDefaultService());
- assertEquals(result.pathMatchers(), expected.getPathMatchers());
- assertEquals(result.hostRules(), expected.getHostRules());
+ assertEquals(result.name(), expected.name());
+ assertEquals(result.defaultService(), expected.defaultService());
+ assertEquals(result.pathMatchers(), expected.pathMatchers());
+ assertEquals(result.hostRules(), expected.hostRules());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
index 1107557..7c6d639 100644
--- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
+++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
@@ -119,17 +119,18 @@ public class UrlMapApiMockTest extends BaseGoogleComputeEngineApiMockTest {
private UrlMapOptions createBasicMap() {
URI service = URI.create(url("/projects/myproject/global/backendServices/jclouds-test"));
- return new UrlMapOptions().name("jclouds-test")
+ return new UrlMapOptions.Builder().name("jclouds-test")
.description("Sample url map")
- .hostRule(HostRule.create(null, ImmutableList.of("jclouds-test"), "path"))
- .pathMatcher(PathMatcher.create("path",
+ .hostRules(ImmutableList.of(HostRule.create(null, ImmutableList.of("jclouds-test"), "path")))
+ .pathMatchers(ImmutableList.of(PathMatcher.create("path",
null,
service,
ImmutableList.of(
PathRule.create(ImmutableList.of("/"),
- service))))
- .test(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service))
- .defaultService(service);
+ service)))))
+ .tests(ImmutableList.of(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service)))
+ .defaultService(service)
+ .build();
}
UrlMapApi urlMapApi() {
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0f67b625/providers/google-compute-engine/src/test/resources/target_http_proxy_insert.json
----------------------------------------------------------------------
diff --git a/providers/google-compute-engine/src/test/resources/target_http_proxy_insert.json b/providers/google-compute-engine/src/test/resources/target_http_proxy_insert.json
index b296e71..991055a 100644
--- a/providers/google-compute-engine/src/test/resources/target_http_proxy_insert.json
+++ b/providers/google-compute-engine/src/test/resources/target_http_proxy_insert.json
@@ -1 +1,4 @@
-{"name":"jclouds-test","urlMap":"https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"}
\ No newline at end of file
+{
+ "name": "jclouds-test",
+ "urlMap": "https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"
+}
\ No newline at end of file