http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViewMembers.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViewMembers.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViewMembers.java new file mode 100644 index 0000000..c14ac44 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViewMembers.java @@ -0,0 +1,69 @@ +/* + * 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.functions.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; + +@Singleton +public class ParseRegionResourceViewMembers extends ParseJson<ListPage<URI>> { + + @Inject + public ParseRegionResourceViewMembers(Json json) { + super(json, new TypeLiteral<ListPage<URI>>() { + }); + } + + public static class ToPagedIterable extends BaseWithRegionAndNameToPagedIterable<URI, ToPagedIterable> { + + private final GoogleComputeEngineApi api; + + @Inject + protected ToPagedIterable(GoogleComputeEngineApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<URI>> fetchNextPage(final String projectName, + final String regionName, + final String name, + final ListOptions options) { + return new Function<Object, IterableWithMarker<URI>>() { + + @Override + public IterableWithMarker<URI> apply(Object input) { + return api.getResourceViewApiForProject(projectName) + .listResourcesAtMarkerInRegion(regionName, name, input.toString(), options); + } + }; + } + } +}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViews.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViews.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViews.java new file mode 100644 index 0000000..778b5c3 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionResourceViews.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.jclouds.googlecomputeengine.functions.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.domain.ResourceView; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; + +@Singleton +public class ParseRegionResourceViews extends ParseJson<ListPage<ResourceView>> { + + @Inject + public ParseRegionResourceViews(Json json) { + super(json, new TypeLiteral<ListPage<ResourceView>>() { + }); + } + + public static class ToPagedIterable extends BaseWithRegionToPagedIterable<ResourceView, ToPagedIterable> { + + private final GoogleComputeEngineApi api; + + @Inject + protected ToPagedIterable(GoogleComputeEngineApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<ResourceView>> fetchNextPage(final String projectName, + final String regionName, + final ListOptions options) { + return new Function<Object, IterableWithMarker<ResourceView>>() { + + @Override + public IterableWithMarker<ResourceView> apply(Object input) { + return api.getResourceViewApiForProject(projectName) + .listAtMarkerInRegion(regionName, input.toString(), options); + } + }; + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetHttpProxies.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetHttpProxies.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetHttpProxies.java new file mode 100644 index 0000000..62537e9 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetHttpProxies.java @@ -0,0 +1,63 @@ +/* + * 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.functions.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.TargetHttpProxy; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; + +public class ParseTargetHttpProxies extends ParseJson<ListPage<TargetHttpProxy>> { + + @Inject + public ParseTargetHttpProxies(Json json) { + super(json, new TypeLiteral<ListPage<TargetHttpProxy>>() { + }); + } + + public static class ToPagedIterable extends BaseToPagedIterable<TargetHttpProxy, ToPagedIterable> { + + private final GoogleComputeEngineApi api; + + @Inject + protected ToPagedIterable(GoogleComputeEngineApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<TargetHttpProxy>> fetchNextPage(final String projectName, + final ListOptions options) { + return new Function<Object, IterableWithMarker<TargetHttpProxy>>() { + + @Override + public IterableWithMarker<TargetHttpProxy> apply(Object input) { + return api.getTargetHttpProxyApiForProject(projectName).list(input.toString(), options); + } + }; + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseUrlMaps.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseUrlMaps.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseUrlMaps.java new file mode 100644 index 0000000..dc9e5ca --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseUrlMaps.java @@ -0,0 +1,63 @@ +/* + * 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.functions.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.domain.UrlMap; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; + +public class ParseUrlMaps extends ParseJson<ListPage<UrlMap>> { + + @Inject + public ParseUrlMaps(Json json) { + super(json, new TypeLiteral<ListPage<UrlMap>>() { + }); + } + + public static class ToPagedIterable extends BaseToPagedIterable<UrlMap, ToPagedIterable> { + + private final GoogleComputeEngineApi api; + + @Inject + protected ToPagedIterable(GoogleComputeEngineApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<UrlMap>> fetchNextPage(final String projectName, + final ListOptions options) { + return new Function<Object, IterableWithMarker<UrlMap>>() { + + @Override + public IterableWithMarker<UrlMap> apply(Object input) { + return api.getUrlMapApiForProject(projectName).listAtMarker(input.toString(), options); + } + }; + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViewMembers.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViewMembers.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViewMembers.java new file mode 100644 index 0000000..230bfe8 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViewMembers.java @@ -0,0 +1,70 @@ +/* + * 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.functions.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; + +@Singleton +public class ParseZoneResourceViewMembers extends ParseJson<ListPage<URI>> { + + @Inject + public ParseZoneResourceViewMembers(Json json) { + super(json, new TypeLiteral<ListPage<URI>>() { + }); + } + + public static class ToPagedIterable extends BaseWithZoneAndNameToPagedIterable<URI, ToPagedIterable> { + + private final GoogleComputeEngineApi api; + + @Inject + protected ToPagedIterable(GoogleComputeEngineApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<URI>> fetchNextPage(final String projectName, + final String zoneName, + final String name, + final ListOptions options) { + return new Function<Object, IterableWithMarker<URI>>() { + + @Override + public IterableWithMarker<URI> apply(Object input) { + return api.getResourceViewApiForProject(projectName) + .listResourcesAtMarkerInZone(zoneName, name, + input.toString(), options); + } + }; + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViews.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViews.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViews.java new file mode 100644 index 0000000..8fb3433 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneResourceViews.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.jclouds.googlecomputeengine.functions.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.domain.ResourceView; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; + +@Singleton +public class ParseZoneResourceViews extends ParseJson<ListPage<ResourceView>> { + + @Inject + public ParseZoneResourceViews(Json json) { + super(json, new TypeLiteral<ListPage<ResourceView>>() { + }); + } + + public static class ToPagedIterable extends BaseWithZoneToPagedIterable<ResourceView, ToPagedIterable> { + + private final GoogleComputeEngineApi api; + + @Inject + protected ToPagedIterable(GoogleComputeEngineApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<ResourceView>> fetchNextPage(final String projectName, + final String zoneName, + final ListOptions options) { + return new Function<Object, IterableWithMarker<ResourceView>>() { + + @Override + public IterableWithMarker<ResourceView> apply(Object input) { + return api.getResourceViewApiForProject(projectName) + .listAtMarkerInZone(zoneName, input.toString(), options); + } + }; + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/handlers/PayloadBinder.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/handlers/PayloadBinder.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/handlers/PayloadBinder.java new file mode 100644 index 0000000..46b8476 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/handlers/PayloadBinder.java @@ -0,0 +1,56 @@ +/* + * 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.handlers; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.googlecomputeengine.options.ResourceOptions; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToJsonPayload; + +public class PayloadBinder implements MapBinder { + + @Inject + private BindToJsonPayload jsonBinder; + + /** + * {@inheritDoc} + */ + @Override + public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { + ResourceOptions options = (ResourceOptions) checkNotNull(postParams.get("options"), "options"); + String name = (String) checkNotNull(postParams.get("name"), "name"); + // Set the name field in the options object to the one that was passed in as part of the url. + // This ensures that a resource at url .../<resource type>/<some name> does not have its name + // field set to something different than what is in the url. + options.name(name); + return bindToRequest(request, options); + } + + /** + * {@inheritDoc} + */ + @Override + public <R extends HttpRequest> R bindToRequest(R request, Object input) { + return jsonBinder.bindToRequest(request, input); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/BackendServiceOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/BackendServiceOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/BackendServiceOptions.java new file mode 100644 index 0000000..0ed2d02 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/BackendServiceOptions.java @@ -0,0 +1,216 @@ +/* + * 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.options; + +import static com.google.common.base.Objects.equal; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.googlecomputeengine.domain.BackendService.Backend; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Options to create a backend service resource. + * + * @see org.jclouds.googlecomputeengine.domain.BackendService + */ +public class BackendServiceOptions extends ResourceOptions { + + private ImmutableSet.Builder<URI> healthChecks = ImmutableSet.builder(); + private ImmutableSet.Builder<Backend> backends = ImmutableSet.builder(); + private Integer timeoutSec; + private Integer port; + private String protocol; + private String fingerprint; + + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getBackends() + */ + public Set<Backend> getBackends() { + return backends.build(); + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getBackends() + */ + public BackendServiceOptions addBackend(Backend backend) { + this.backends.add(backend); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getBackends() + */ + public BackendServiceOptions backends(Set<Backend> backends) { + this.backends = ImmutableSet.builder(); + this.backends.addAll(backends); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.Resource#getName() + */ + @Override + public BackendServiceOptions name(String name) { + this.name = name; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.Resource#getDescription() + */ + @Override + public BackendServiceOptions description(String description) { + this.description = description; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getHealthChecks() + */ + public Set<URI> getHealthChecks() { + return healthChecks.build(); + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getHealthChecks() + */ + public BackendServiceOptions addHealthCheck(URI healthCheck) { + this.healthChecks.add(healthCheck); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getHealthChecks() + */ + public BackendServiceOptions healthChecks(Set<URI> healthChecks) { + this.healthChecks = ImmutableSet.builder(); + this.healthChecks.addAll(healthChecks); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getTimeoutSec() + */ + public Integer getTimeoutSec() { + return timeoutSec; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getTimeoutSec() + */ + public BackendServiceOptions timeoutSec(Integer timeoutSec) { + this.timeoutSec = timeoutSec; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getPort() + */ + public Integer getPort() { + return port; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getPort() + */ + public BackendServiceOptions port(Integer port) { + this.port = port; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getProtocol() + */ + public String getProtocol() { + return protocol; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getProtocol() + */ + public BackendServiceOptions protocol(String protocol) { + this.protocol = protocol; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getFingerprint() + */ + public String getFingerprint() { + return fingerprint; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.BackendService#getFingerprint() + */ + public BackendServiceOptions fingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(name, backends, healthChecks, timeoutSec, + port, protocol); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + BackendServiceOptions that = BackendServiceOptions.class.cast(obj); + return equal(this.name, that.name) + && equal(this.backends, that.backends) + && equal(this.healthChecks, that.healthChecks) + && equal(this.timeoutSec, that.timeoutSec) + && equal(this.port, that.port) + && equal(this.protocol, that.protocol); + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return super.string() + .omitNullValues() + .add("backends", backends) + .add("healthChecks", healthChecks) + .add("timeoutSec", timeoutSec) + .add("port", port) + .add("protocol", protocol) + .add("fingerprint", fingerprint); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleOptions.java new file mode 100644 index 0000000..b68a000 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleOptions.java @@ -0,0 +1,176 @@ +/* + * 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.options; + +import static com.google.common.base.Objects.equal; + +import java.net.URI; + +import com.google.common.base.Objects; + +/** + * Options to create a forwarding rule resource. + * + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule + */ +public class ForwardingRuleOptions extends ResourceOptions { + + private String region; + private String ipAddress; + private String ipProtocol; + private String portRange; + private URI target; + + /** + * {@inheritDoc} + */ + @Override + public ForwardingRuleOptions name(String name) { + this.name = name; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ForwardingRuleOptions description(String description) { + this.description = description; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getRegion() + */ + public String getRegion() { + return region; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getRegion() + */ + public ForwardingRuleOptions region(String region) { + this.region = region; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getIpAddress() + */ + public String getIpAddress() { + return ipAddress; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getIpAddress() + */ + public ForwardingRuleOptions ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getIpProtocol() + */ + public String getIpProtocol() { + return ipProtocol; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getIpProtocol() + */ + public ForwardingRuleOptions ipProtocol(String ipProtocol) { + this.ipProtocol = ipProtocol; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getPortRange() + */ + public String getPortRange() { + return portRange; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getPortRange() + */ + public ForwardingRuleOptions portRange(String portRange) { + this.portRange = portRange; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getTarget() + */ + public URI getTarget() { + return target; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getTarget() + */ + public ForwardingRuleOptions target(URI target) { + this.target = target; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(name, region, ipAddress, ipProtocol, portRange, + target); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + ForwardingRuleOptions that = ForwardingRuleOptions.class.cast(obj); + return equal(this.name, that.name) + && equal(this.region, that.region) + && equal(this.ipAddress, that.ipAddress) + && equal(this.ipProtocol, that.ipProtocol) + && equal(this.portRange, that.portRange) + && equal(this.target, that.target); + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return super.string() + .omitNullValues() + .add("region", region) + .add("ipAddress", ipAddress) + .add("ipProtocol", ipProtocol) + .add("portRange", portRange) + .add("target", target); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceOptions.java new file mode 100644 index 0000000..29cae0c --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceOptions.java @@ -0,0 +1,69 @@ +/* + * 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.options; + +import static com.google.common.base.Objects.toStringHelper; + +import com.google.common.base.Objects; + +public abstract class ResourceOptions { + + protected String name; + protected String description; + + /** + * @see org.jclouds.googlecomputeengine.domain.Resource#getName() + */ + public abstract ResourceOptions name(String name); + + /** + * @see org.jclouds.googlecomputeengine.domain.Resource#getName() + */ + public String getName() { + return name; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.Resource#getDescription() + */ + public abstract ResourceOptions description(String description); + + /** + * @see org.jclouds.googlecomputeengine.domain.Resource#getDescription() + */ + public String getDescription() { + return description; + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return toStringHelper(this) + .omitNullValues() + .add("name", name) + .add("description", description); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceViewOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceViewOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceViewOptions.java new file mode 100644 index 0000000..43fc5d7 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ResourceViewOptions.java @@ -0,0 +1,149 @@ +/* + * 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.options; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Options to create a resource view. + * + * @see org.jclouds.googlecomputeengine.domain.ResourceView + */ +public class ResourceViewOptions extends ResourceOptions { + + private ImmutableSet.Builder<URI> members = ImmutableSet.<URI>builder(); + private String region; + private String zone; + + /** + * {@inheritDoc} + */ + @Override + public ResourceViewOptions name(String name) { + this.name = name; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceViewOptions description(String description) { + this.description = description; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getMembers() + */ + public Set<URI> getMembers() { + return members.build(); + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getMembers() + */ + public ResourceViewOptions addMember(URI member) { + this.members.add(checkNotNull(member)); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getMembers() + */ + public ResourceViewOptions members(Set<URI> members) { + this.members = ImmutableSet.builder(); + this.members.addAll(members); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getRegion() + */ + public ResourceViewOptions region(String region) { + this.region = region; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getRegion() + */ + public String getRegion() { + return region; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getZone() + */ + public ResourceViewOptions zone(String zone) { + this.zone = zone; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.ResourceView#getZone() + */ + public String getZone() { + return zone; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(name, members, zone, region); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + ResourceViewOptions that = ResourceViewOptions.class.cast(obj); + return equal(this.name, that.name) + && equal(this.members, that.members) + && equal(this.zone, that.zone) + && equal(this.region, that.region); + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return super.string() + .omitNullValues() + .add("memebers", members); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java new file mode 100644 index 0000000..280acca --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetHttpProxyOptions.java @@ -0,0 +1,103 @@ +/* + * 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.options; + +import static com.google.common.base.Objects.equal; + +import java.net.URI; + +import com.google.common.base.Objects; + +/** + * Options to create a target http proxy. + * + * @see org.jclouds.googlecomputeengine.domain.TargetHttpProxy + */ +public final class TargetHttpProxyOptions extends ResourceOptions { + + private URI urlMap; + + /** + * {@inheritDoc} + */ + @Override + public TargetHttpProxyOptions name(String name) { + this.name = name; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TargetHttpProxyOptions description(String description) { + this.description = description; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.TargetHttpProxy#getUrlMap() + */ + public URI getUrlMap() { + return urlMap; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.TargetHttpProxy#getUrlMap() + */ + public TargetHttpProxyOptions urlMap(URI urlMap) { + this.urlMap = urlMap; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(name, urlMap); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + TargetHttpProxyOptions that = TargetHttpProxyOptions.class.cast(obj); + return equal(this.name, that.name) + && equal(this.urlMap, that.urlMap); + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return super.string() + .omitNullValues() + .add("urlMap", urlMap); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java new file mode 100644 index 0000000..3175ac7 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/UrlMapOptions.java @@ -0,0 +1,214 @@ +/* + * 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.options; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.googlecomputeengine.domain.UrlMap; +import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule; +import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher; +import org.jclouds.googlecomputeengine.domain.UrlMap.UrlMapTest; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * Options to create an urlMap. + * + * @see UrlMap + */ +public class UrlMapOptions extends ResourceOptions { + + private ImmutableSet.Builder<HostRule> hostRules = ImmutableSet.builder(); + private ImmutableSet.Builder<PathMatcher> pathMatchers = ImmutableSet.builder(); + private ImmutableSet.Builder<UrlMapTest> urlMapTests = ImmutableSet.builder(); + private URI defaultService; + private String fingerprint; + + /** + ** + * {@inheritDoc} + */ + @Override + public UrlMapOptions name(String name) { + this.name = name; + return this; + } + + /** + ** + * {@inheritDoc} + */ + @Override + public UrlMapOptions description(String description) { + this.description = description; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getHostRules() + */ + public UrlMapOptions addHostRule(HostRule hostRule) { + this.hostRules.add(checkNotNull(hostRule)); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getHostRules() + */ + public UrlMapOptions hostRules(Set<HostRule> hostRules) { + this.hostRules = ImmutableSet.builder(); + this.hostRules.addAll(hostRules); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getHostRules() + */ + public Set<HostRule> getHostRules() { + return hostRules.build(); + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getPathMatchers() + */ + public UrlMapOptions addPathMatcher(PathMatcher pathMatcher) { + this.pathMatchers.add(checkNotNull(pathMatcher)); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getPathMatchers() + */ + public UrlMapOptions pathMatchers(Set<PathMatcher> pathMatchers) { + this.pathMatchers = ImmutableSet.builder(); + this.pathMatchers.addAll(pathMatchers); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getPathMatchers() + */ + public Set<PathMatcher> getPathMatchers() { + return pathMatchers.build(); + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getTests() + */ + public UrlMapOptions addTest(UrlMapTest urlMapTest) { + this.urlMapTests.add(checkNotNull(urlMapTest)); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getTests() + */ + public UrlMapOptions urlMapTests(Set<UrlMapTest> urlMapTests) { + this.urlMapTests = ImmutableSet.builder(); + this.urlMapTests.addAll(urlMapTests); + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getTests() + */ + public Set<UrlMapTest> getTests() { + return urlMapTests.build(); + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getDefaultService() + */ + public UrlMapOptions defaultService(URI defaultService) { + this.defaultService = defaultService; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getDefaultService() + */ + public URI getDefaultService() { + return defaultService; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getFingerprint() + */ + public UrlMapOptions fingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.UrlMap#getFingerprint() + */ + public String getFingerprint() { + return fingerprint; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(name, hostRules, pathMatchers, urlMapTests, + defaultService); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + UrlMapOptions that = UrlMapOptions.class.cast(obj); + return equal(this.name, that.name) + && equal(this.hostRules, that.hostRules) + && equal(this.pathMatchers, that.pathMatchers) + && equal(this.urlMapTests, that.urlMapTests) + && equal(this.defaultService, that.defaultService); + } + + /** + ** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return toStringHelper(this) + .omitNullValues() + .add("hostRules", hostRules.build()) + .add("pathMatchers", pathMatchers.build()) + .add("tests", urlMapTests.build()) + .add("defaultService", defaultService) + .add("fingerprint", fingerprint); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java new file mode 100644 index 0000000..80b8d13 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java @@ -0,0 +1,215 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertNull; + +import java.io.IOException; +import java.net.URI; + +import javax.ws.rs.core.MediaType; + +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; +import org.jclouds.googlecomputeengine.options.BackendServiceOptions; +import org.jclouds.googlecomputeengine.parse.ParseBackendServiceGetHealthTest; +import org.jclouds.googlecomputeengine.parse.ParseBackendServiceListTest; +import org.jclouds.googlecomputeengine.parse.ParseBackendServiceTest; +import org.jclouds.googlecomputeengine.parse.ParseOperationTest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +@Test(groups = "unit") +public class BackendServiceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { + + private static final String ENDPOINT_BASE = "https://www.googleapis.com/" + + "compute/v1/projects/myproject/global/backendServices"; + + private org.jclouds.http.HttpRequest.Builder<? extends HttpRequest.Builder<?>> getBasicRequest() { + return HttpRequest.builder().addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN); + } + + private HttpResponse createResponse(String payloadFile) { + return HttpResponse.builder().statusCode(200) + .payload(payloadFromResource(payloadFile)) + .build(); + } + + public void testGetBackendServiceResponseIs2xx() throws Exception { + HttpRequest request = getBasicRequest().method("GET") + .endpoint(ENDPOINT_BASE + "/jclouds-test") + .build(); + HttpResponse response = createResponse("/backend_service_get.json"); + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, request, response) + .getBackendServiceApiForProject("myproject"); + + assertEquals(api.get("jclouds-test"), new ParseBackendServiceTest().expected()); + } + + public void testGetBackendServiceResponseIs4xx() throws Exception { + HttpRequest request = getBasicRequest().method("GET") + .endpoint(ENDPOINT_BASE + "/jclouds-test") + .build(); + + HttpResponse response = HttpResponse.builder().statusCode(404).build(); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, request, response) + .getBackendServiceApiForProject("myproject"); + + assertNull(api.get("jclouds-test")); + } + + public void testInsertBackendServiceResponseIs2xx() throws IOException { + HttpRequest request = getBasicRequest().method("POST") + .endpoint(ENDPOINT_BASE) + .payload(payloadFromResourceWithContentType("/backend_service_insert.json", + MediaType.APPLICATION_JSON)) + .build(); + HttpResponse response = createResponse("/operation.json"); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + URI hc = URI.create("https://www.googleapis.com/compute/v1/projects/" + + "myproject/global/httpHealthChecks/jclouds-test"); + assertEquals(api.create("jclouds-test", new BackendServiceOptions().name("jclouds-test") + .protocol("HTTP") + .port(80) + .timeoutSec(30) + .addHealthCheck(hc)), + new ParseOperationTest().expected()); + + } + + public void testUpdateBackendServiceResponseIs2xx() throws IOException { + HttpRequest request = getBasicRequest().method("PUT") + .endpoint(ENDPOINT_BASE + "/jclouds-test") + .payload(payloadFromResourceWithContentType("/backend_service_insert.json", + MediaType.APPLICATION_JSON)) + .build(); + HttpResponse response = createResponse("/operation.json"); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + URI hc = URI.create("https://www.googleapis.com/compute/v1/projects/" + + "myproject/global/httpHealthChecks/jclouds-test"); + assertEquals(api.update("jclouds-test", new BackendServiceOptions().name("jclouds-test") + .protocol("HTTP") + .port(80) + .timeoutSec(30) + .addHealthCheck(hc)), + new ParseOperationTest().expected()); + } + + public void testPatchBackendServiceResponseIs2xx() throws IOException { + HttpRequest request = getBasicRequest().method("PATCH") + .endpoint(ENDPOINT_BASE + "/jclouds-test") + .payload(payloadFromResourceWithContentType("/backend_service_insert.json", + MediaType.APPLICATION_JSON)) + .build(); + HttpResponse response = createResponse("/operation.json"); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + URI hc = URI.create("https://www.googleapis.com/compute/v1/projects/" + + "myproject/global/httpHealthChecks/jclouds-test"); + assertEquals(api.patch("jclouds-test", new BackendServiceOptions().name("jclouds-test") + .protocol("HTTP") + .port(80) + .timeoutSec(30) + .addHealthCheck(hc)), + new ParseOperationTest().expected()); + } + + public void testDeleteBackendServiceResponseIs2xx() { + HttpRequest request = getBasicRequest().method("DELETE") + .endpoint(ENDPOINT_BASE + "/jclouds-test") + .build(); + HttpResponse response = createResponse("/operation.json"); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + assertEquals(api.delete("jclouds-test"), new ParseOperationTest().expected()); + } + + public void testDeleteBackendServiceResponseIs4xx() { + HttpRequest request = getBasicRequest().method("DELETE") + .endpoint(ENDPOINT_BASE + "/jclouds-test") + .build(); + + HttpResponse response = HttpResponse.builder().statusCode(404).build(); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + assertNull(api.delete("jclouds-test")); + } + + public void testListBackendServiceResponseIs2xx() { + HttpRequest request = getBasicRequest().method("GET") + .endpoint(ENDPOINT_BASE) + .build(); + HttpResponse response = createResponse("/backend_service_list.json"); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + assertEquals(api.listFirstPage().toString(), + new ParseBackendServiceListTest().expected().toString()); + } + + public void testListBackendServiceResponseIs4xx() { + HttpRequest request = getBasicRequest().method("GET") + .endpoint(ENDPOINT_BASE) + .build(); + + HttpResponse response = HttpResponse.builder().statusCode(404).build(); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + assertTrue(api.list().concat().isEmpty()); + } + + public void testGetHealthResponseIs2xx() throws IOException { + HttpRequest request = getBasicRequest().method("POST") + .endpoint(ENDPOINT_BASE + + "/jclouds-test/getHealth") + .payload(payloadFromResource("/backend_service_get_health_request.json")) + .build(); + HttpResponse response = createResponse("/backend_service_get_health.json"); + + BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, request, response).getBackendServiceApiForProject("myproject"); + + URI group = URI.create("https://www.googleapis.com/resourceviews/v1beta1/" + + "projects/myproject/zones/us-central1-a/" + + "resourceViews/jclouds-test"); + assertEquals(api.getHealth("jclouds-test", group), new ParseBackendServiceGetHealthTest().expected()); + + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiLiveTest.java new file mode 100644 index 0000000..e4f99c0 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiLiveTest.java @@ -0,0 +1,152 @@ +/* + * 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.features; + +import static com.google.common.collect.Iterables.getOnlyElement; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.net.URI; +import java.util.HashSet; +import java.util.List; + +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.BackendService; +import org.jclouds.googlecomputeengine.domain.BackendService.Backend; +import org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; +import org.jclouds.googlecomputeengine.options.BackendServiceOptions; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; + +public class BackendServiceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { + + private static final String BACKEND_SERVICE_NAME = "backend-service-api-live-test-backend-service"; + private static final String BACKEND_SERVICE_HEALTH_CHECK_NAME = "backend-service-api-live-test-health-check"; + private static final String BACKEND_SERVICE_RESOURCE_VIEW_NAME = "backend-service-api-live-test-resource-view"; + private static final int TIME_WAIT = 30; + + private BackendServiceApi api() { + return api.getBackendServiceApiForProject(userProject.get()); + } + + @Test(groups = "live") + public void testInsertBackendService() { + // TODO: (ashmrtnz) create health check here once it is merged into this project + HashSet<URI> healthChecks = new HashSet<URI>(); + healthChecks.add(getHealthCheckUrl(userProject.get(), BACKEND_SERVICE_HEALTH_CHECK_NAME)); + BackendServiceOptions b = new BackendServiceOptions().name(BACKEND_SERVICE_NAME).healthChecks(healthChecks); + assertGlobalOperationDoneSucessfully(api().create(BACKEND_SERVICE_NAME, b), TIME_WAIT); + } + + @Test(groups = "live", dependsOnMethods = "testInsertBackendService") + public void testGetBackendService() { + BackendService service = api().get(BACKEND_SERVICE_NAME); + assertNotNull(service); + assertBackendServiceEquals(service); + } + + @Test(groups = "live", dependsOnMethods = "testGetBackendService") + public void testPatchBackendService() { + String fingerprint = api().get(BACKEND_SERVICE_NAME).getFingerprint().get(); + BackendServiceOptions backendService = new BackendServiceOptions() + .name(BACKEND_SERVICE_NAME) + .healthChecks(ImmutableSet.of(getHealthCheckUrl(userProject.get(), BACKEND_SERVICE_HEALTH_CHECK_NAME))) + .timeoutSec(10) + .fingerprint(fingerprint); + + assertGlobalOperationDoneSucessfully(api().update(BACKEND_SERVICE_NAME, backendService), TIME_WAIT); + assertBackendServiceEquals(api().get(BACKEND_SERVICE_NAME), backendService); + } + + @Test(groups = "live", dependsOnMethods = "testPatchBackendService") + public void testUpdateBackendService() { + api.getResourceViewApiForProject(userProject.get()).createInZone(DEFAULT_ZONE_NAME, + BACKEND_SERVICE_RESOURCE_VIEW_NAME); + String fingerprint = api().get(BACKEND_SERVICE_NAME).getFingerprint().get(); + Backend backend = Backend.builder() + .group(getResourceViewInZoneUrl(userProject.get(), + BACKEND_SERVICE_RESOURCE_VIEW_NAME)) + .build(); + BackendServiceOptions backendService = new BackendServiceOptions() + .name(BACKEND_SERVICE_NAME) + .healthChecks(ImmutableSet.of(getHealthCheckUrl(userProject.get(), + BACKEND_SERVICE_HEALTH_CHECK_NAME))) + .timeoutSec(45) + .port(8080) + .addBackend(backend) + .fingerprint(fingerprint); + + assertGlobalOperationDoneSucessfully(api().update(BACKEND_SERVICE_NAME, + backendService), + TIME_WAIT); + assertBackendServiceEquals(api().get(BACKEND_SERVICE_NAME), + backendService); + } + + @Test(groups = "live", dependsOnMethods = "testUpdateBackendService") + public void testListBackendService() { + PagedIterable<BackendService> backendServices = api().list(new ListOptions.Builder() + .filter("name eq " + BACKEND_SERVICE_NAME)); + + List<BackendService> backendServicesAsList = Lists.newArrayList(backendServices.concat()); + + assertEquals(backendServicesAsList.size(), 1); + + } + + @Test(groups = "live", dependsOnMethods = "testListBackendService") + public void testGetHealthBackendService() { + // Check to see that the health check returned is empty because it can + // take several minutes to create all the resources needed and wait for + // the health check to return a health status. + assertGroupHealthEquals(api().getHealth(BACKEND_SERVICE_NAME, + getResourceViewInZoneUrl(userProject.get(), + BACKEND_SERVICE_RESOURCE_VIEW_NAME))); + } + + @Test(groups = "live", dependsOnMethods = "testGetHealthBackendService") + public void testDeleteBackendService() { + assertGlobalOperationDoneSucessfully(api().delete(BACKEND_SERVICE_NAME), TIME_WAIT); + api.getResourceViewApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, + BACKEND_SERVICE_RESOURCE_VIEW_NAME); + } + + private void assertBackendServiceEquals(BackendService result) { + assertEquals(result.getName(), BACKEND_SERVICE_NAME); + assertEquals(getOnlyElement(result.getHealthChecks()), + getHealthCheckUrl(userProject.get(), BACKEND_SERVICE_HEALTH_CHECK_NAME)); + } + + private void assertBackendServiceEquals(BackendService result, BackendServiceOptions expected) { + assertEquals(result.getName(), expected.getName()); + assertEquals(result.getHealthChecks(), expected.getHealthChecks()); + if (expected.getTimeoutSec() != null) { + assertEquals(result.getTimeoutSec().get(), expected.getTimeoutSec()); + } + if (expected.getPort() != null) { + assertEquals(result.getPort().get(), expected.getPort()); + } + } + + private void assertGroupHealthEquals(BackendServiceGroupHealth result) { + assert result.getHealthStatuses().size() == 0; + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/29f4013d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java index 1beb95c..a9c7660 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java @@ -19,6 +19,7 @@ package org.jclouds.googlecomputeengine.features; import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Address; @@ -27,10 +28,23 @@ import org.jclouds.googlecomputeengine.domain.TargetPool; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions; import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions; +import org.jclouds.googlecomputeengine.options.BackendServiceOptions; +import org.jclouds.googlecomputeengine.options.ForwardingRuleOptions; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.googlecomputeengine.options.UrlMapOptions; + import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.net.URI; +import java.util.HashSet; +import java.util.List; + +import org.jclouds.collect.PagedIterable; + +import com.google.common.collect.Lists; + public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final String FORWARDING_RULE_NAME = "forwarding-rule-api-live-test"; @@ -118,4 +132,120 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes public void testDeleteForwardingRule() { assertOperationDoneSuccessfully(api().delete(FORWARDING_RULE_NAME)); } + + + private static final String GLOBAL_FORWARDING_RULE_NAME = "global-forwarding-rule-api-live-test-forwarding-rule"; + private static final String GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME = "global-" + + "forwarding-rule-api-live-test-target-http-proxy"; + private static final String GLOBAL_FORWARDING_RULE_URL_MAP_NAME = "global-" + + "forwarding-rule-api-live-test-url-map"; + private static final String GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME = "global-" + + "forwarding-rule-api-live-test-backend-service"; + private static final String GLOBAL_FORWARDING_RULE_HEALTH_CHECK_NAME = "global-" + + "forwarding-rule-api-live-test-health-check"; + private static final String PORT_RANGE = "80"; + + private ForwardingRuleApi api() { + return api.getForwardingRuleApiForProject(userProject.get()); + } + + @Test(groups = "live") + public void testInsertGlobalForwardingRule() { + String project = userProject.get(); + + // TODO: (ashmrtnz) create httpHealthCheck here once it is merged into project + HashSet<URI> healthChecks = new HashSet<URI>(); + healthChecks.add(getHealthCheckUrl(project, GLOBAL_FORWARDING_RULE_HEALTH_CHECK_NAME)); + BackendServiceOptions b = new BackendServiceOptions().name(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME) + .healthChecks(healthChecks); + assertGlobalOperationDoneSucessfully(api.getBackendServiceApiForProject(project) + .create(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME, b), TIME_WAIT); + + UrlMapOptions map = new UrlMapOptions().name(GLOBAL_FORWARDING_RULE_URL_MAP_NAME) + .description("simple url map") + .defaultService(getBackendServiceUrl(project, + GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME)); + assertGlobalOperationDoneSucessfully(api.getUrlMapApiForProject(project) + .create(GLOBAL_FORWARDING_RULE_URL_MAP_NAME, + map), + TIME_WAIT); + assertGlobalOperationDoneSucessfully(api.getTargetHttpProxyApiForProject(project) + .create(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME, + getUrlMapUrl(project, GLOBAL_FORWARDING_RULE_URL_MAP_NAME)), + TIME_WAIT); + assertGlobalOperationDoneSucessfully( + api().create(GLOBAL_FORWARDING_RULE_NAME, + new ForwardingRuleOptions().target(getTargetHttpProxyUrl(userProject.get(), + GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME)) + .portRange(PORT_RANGE)), + TIME_WAIT); + } + + @Test(groups = "live", dependsOnMethods = "testInsertGlobalForwardingRule") + public void testGetGlobalForwardingRule() { + ForwardingRule forwardingRule = api().get(GLOBAL_FORWARDING_RULE_NAME); + assertNotNull(forwardingRule); + ForwardingRuleOptions expected = new ForwardingRuleOptions() + .target(getTargetHttpProxyUrl(userProject.get(), + GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME)) + .portRange("80-80") + .ipProtocol("TCP") + .name(GLOBAL_FORWARDING_RULE_NAME); + assertGlobalForwardingRuleEquals(forwardingRule, expected); + } + + @Test(groups = "live", dependsOnMethods = "testGetGlobalForwardingRule") + public void testSetGlobalForwardingRuleTarget() { + assertGlobalOperationDoneSucessfully(api.getTargetHttpProxyApiForProject(userProject.get()) + .create(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME + "-2", + getUrlMapUrl(userProject.get(), + GLOBAL_FORWARDING_RULE_URL_MAP_NAME)), + TIME_WAIT); + assertGlobalOperationDoneSucessfully(api().setTarget(GLOBAL_FORWARDING_RULE_NAME, + getTargetHttpProxyUrl(userProject.get(), + GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME + "-2")), + TIME_WAIT); + } + + @Test(groups = "live", dependsOnMethods = "testSetGlobalForwardingRuleTarget") + public void testListGlobalForwardingRule() { + + PagedIterable<ForwardingRule> forwardingRules = api().list(new ListOptions.Builder() + .filter("name eq " + GLOBAL_FORWARDING_RULE_NAME)); + + List<ForwardingRule> forwardingRulesAsList = Lists.newArrayList(forwardingRules.concat()); + + assertEquals(forwardingRulesAsList.size(), 1); + + } + + @Test(groups = "live", dependsOnMethods = "testListGlobalForwardingRule") + public void testDeleteGlobalForwardingRule() { + assertGlobalOperationDoneSucessfully(api().delete(GLOBAL_FORWARDING_RULE_NAME), TIME_WAIT); + + // Teardown other created resources + String project = userProject.get(); + assertGlobalOperationDoneSucessfully(api.getTargetHttpProxyApiForProject(project) + .delete(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME), + TIME_WAIT); + assertGlobalOperationDoneSucessfully(api.getTargetHttpProxyApiForProject(project) + .delete(GLOBAL_FORWARDING_RULE_TARGET_HTTP_PROXY_NAME + "-2"), + TIME_WAIT); + assertGlobalOperationDoneSucessfully(api.getUrlMapApiForProject(project) + .delete(GLOBAL_FORWARDING_RULE_URL_MAP_NAME), + TIME_WAIT); + assertGlobalOperationDoneSucessfully(api.getBackendServiceApiForProject(project) + .delete(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME), + TIME_WAIT); + // TODO: (ashmrtnz) delete health check once it is merged into project + } + + private void assertGlobalForwardingRuleEquals(ForwardingRule result, ForwardingRuleOptions expected) { + assertEquals(result.getName(), expected.getName()); + assertEquals(result.getTarget(), expected.getTarget()); + assertEquals(result.getIpProtocol().orNull(), expected.getIpProtocol()); + assertEquals(result.getDescription().orNull(), expected.getDescription()); + assertEquals(result.getPortRange(), expected.getPortRange()); + assertTrue(result.getIpAddress().isPresent()); + } }
