Remove Kernel, tweak Disk definition
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/194b1897 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/194b1897 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/194b1897 Branch: refs/heads/jclouds-393 Commit: 194b189706a20bb34ac28b2c72f193f27f3b6482 Parents: 2d92701 Author: Andrew Bayer <[email protected]> Authored: Tue Dec 3 11:13:13 2013 -0800 Committer: Andrew Bayer <[email protected]> Committed: Tue Dec 3 11:13:13 2013 -0800 ---------------------------------------------------------------------- .../GoogleComputeEngineApi.java | 10 -- .../googlecomputeengine/domain/Disk.java | 32 ++++- .../googlecomputeengine/domain/Kernel.java | 91 ------------ .../googlecomputeengine/features/KernelApi.java | 140 ------------------- .../functions/internal/ParseKernels.java | 66 --------- .../features/KernelApiExpectTest.java | 109 --------------- .../features/KernelApiLiveTest.java | 77 ---------- .../parse/ParseKernelListTest.java | 73 ---------- .../parse/ParseKernelTest.java | 51 ------- .../src/test/resources/kernel.json | 8 -- .../src/test/resources/kernel_list.json | 27 ---- 11 files changed, 27 insertions(+), 657 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java index f6ff923..6918d27 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java @@ -27,7 +27,6 @@ import org.jclouds.googlecomputeengine.features.FirewallApi; import org.jclouds.googlecomputeengine.features.GlobalOperationApi; import org.jclouds.googlecomputeengine.features.ImageApi; import org.jclouds.googlecomputeengine.features.InstanceApi; -import org.jclouds.googlecomputeengine.features.KernelApi; import org.jclouds.googlecomputeengine.features.MachineTypeApi; import org.jclouds.googlecomputeengine.features.NetworkApi; import org.jclouds.googlecomputeengine.features.ProjectApi; @@ -107,15 +106,6 @@ public interface GoogleComputeEngineApi extends Closeable { InstanceApi getInstanceApiForProject(@PathParam("project") String projectName); /** - * Provides access to Kernel features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - KernelApi getKernelApiForProject(@PathParam("project") String projectName); - - /** * Provides access to MachineType features * * @param projectName the name of the project http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java index 15ecf69..3c7bad8 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java @@ -17,6 +17,7 @@ package org.jclouds.googlecomputeengine.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Optional.fromNullable; import static com.google.common.base.Preconditions.checkNotNull; import java.beans.ConstructorProperties; @@ -25,6 +26,7 @@ import java.util.Date; import com.google.common.annotations.Beta; import com.google.common.base.Objects; +import com.google.common.base.Optional; /** * A persistent disk resource @@ -36,15 +38,17 @@ import com.google.common.base.Objects; public final class Disk extends AbstractDisk { private final URI zone; + private final Optional<URI> sourceImage; @ConstructorProperties({ "id", "creationTimestamp", "selfLink", "name", "description", "sizeGb", "zone", - "status" + "status", "sourceImage" }) private Disk(String id, Date creationTimestamp, URI selfLink, String name, String description, - Integer sizeGb, URI zone, String status) { + Integer sizeGb, URI zone, String status, URI sourceImage) { super(Kind.DISK, id, creationTimestamp, selfLink, name, description, sizeGb, status); this.zone = checkNotNull(zone, "zone of %s", name); + this.sourceImage = fromNullable(sourceImage); } /** @@ -55,6 +59,13 @@ public final class Disk extends AbstractDisk { } /** + * @return the source image for the disk + */ + public Optional<URI> getSourceImage() { + return sourceImage; + } + + /** * {@inheritDoc} */ @Override @@ -73,7 +84,8 @@ public final class Disk extends AbstractDisk { protected Objects.ToStringHelper string() { return super.string() .omitNullValues() - .add("zone", zone); + .add("zone", zone) + .add("sourceImage", sourceImage.orNull()); } /** @@ -95,6 +107,7 @@ public final class Disk extends AbstractDisk { public static final class Builder extends AbstractDisk.Builder<Builder> { private URI zone; + private URI sourceImage; /** * @see Disk#getZone() @@ -104,6 +117,14 @@ public final class Disk extends AbstractDisk { return this; } + /** + * @see Disk#getSourceImage() + */ + public Builder sourceImage(URI sourceImage) { + this.sourceImage = sourceImage; + return this; + } + @Override protected Builder self() { return this; @@ -111,12 +132,13 @@ public final class Disk extends AbstractDisk { public Disk build() { return new Disk(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, super.sizeGb, zone, super.status); + super.description, super.sizeGb, zone, super.status, sourceImage); } public Builder fromDisk(Disk in) { return super.fromAbstractDisk(in) - .zone(in.getZone()); + .zone(in.getZone()) + .sourceImage(in.getSourceImage().orNull()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Kernel.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Kernel.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Kernel.java deleted file mode 100644 index 3c54865..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Kernel.java +++ /dev/null @@ -1,91 +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.domain; - -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import com.google.common.annotations.Beta; -import com.google.common.base.Optional; - -/** - * Represents a kernel. - * - * @author David Alves - * @see <a href="https://developers.google.com/compute/docs/reference/v1/kernels"/> - */ -@Beta -public final class Kernel extends Resource { - private final Optional<Deprecated> deprecated; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "deprecated" - }) - private Kernel(String id, Date creationTimestamp, URI selfLink, String name, String description, - Deprecated deprecated) { - super(Kind.KERNEL, id, creationTimestamp, selfLink, name, description); - this.deprecated = fromNullable(deprecated); - } - - /** - * @return the deprecation information for this kernel - */ - public Optional<Deprecated> getDeprecated() { - return deprecated; - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromKernel(this); - } - - public static final class Builder extends Resource.Builder<Builder> { - - private Deprecated deprecated; - - /** - * @see Kernel#getDeprecated() - */ - public Builder deprecated(Deprecated deprecated) { - this.deprecated = checkNotNull(deprecated, "deprecated"); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Kernel build() { - return new Kernel(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, deprecated); - } - - public Builder fromKernel(Kernel in) { - return super.fromResource(in) - .deprecated(in.getDeprecated().orNull()); - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/KernelApi.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/KernelApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/KernelApi.java deleted file mode 100644 index 1c9d3af..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/KernelApi.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.features; - -import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecomputeengine.domain.Kernel; -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.functions.internal.ParseKernels; -import org.jclouds.googlecomputeengine.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; - -/** - * Provides access to Kernels via their REST API. - * - * @author David Alves - * @see <a href="https://developers.google.com/compute/docs/reference/v1/kernels"/> - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -@Consumes(MediaType.APPLICATION_JSON) -public interface KernelApi { - - /** - * Returns the specified kernel resource - * - * @param kernelName name of the kernel resource to return. - * @return If successful, this method returns a Kernel resource - */ - @Named("Kernels:get") - @GET - @Path("/global/kernels/{kernel}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - Kernel get(@PathParam("kernel") String kernelName); - - /** - * @see KernelApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) - */ - @Named("Kernels:list") - @GET - @Path("/global/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListPage<Kernel> listFirstPage(); - - /** - * @see KernelApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) - */ - @Named("Kernels:list") - @GET - @Path("/global/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListPage<Kernel> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * Retrieves the list of kernel resources available to the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecomputeengine.domain.ListPage - */ - @Named("Kernels:list") - @GET - @Path("/global/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListPage<Kernel> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions listOptions); - - /** - * @see KernelApi#list(org.jclouds.googlecomputeengine.options.ListOptions) - */ - @Named("Kernels:list") - @GET - @Path("/global/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Transform(ParseKernels.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<Kernel> list(); - - /** - * A paged version of KernelApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see KernelApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) - */ - @Named("Kernels:list") - @GET - @Path("/global/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Transform(ParseKernels.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<Kernel> list(ListOptions listOptions); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseKernels.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseKernels.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseKernels.java deleted file mode 100644 index 121677f..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseKernels.java +++ /dev/null @@ -1,66 +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.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.Kernel; -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; - -/** - * @author David Alves - */ -public class ParseKernels extends ParseJson<ListPage<Kernel>> { - - @Inject - public ParseKernels(Json json) { - super(json, new TypeLiteral<ListPage<Kernel>>() { - }); - } - - public static class ToPagedIterable extends BaseToPagedIterable<Kernel, ToPagedIterable> { - - private final GoogleComputeEngineApi api; - - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function<Object, IterableWithMarker<Kernel>> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function<Object, IterableWithMarker<Kernel>>() { - - @Override - public IterableWithMarker<Kernel> apply(Object input) { - return api.getKernelApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiExpectTest.java deleted file mode 100644 index 7dcd1f6..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiExpectTest.java +++ /dev/null @@ -1,109 +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.features; - -import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; -import org.jclouds.googlecomputeengine.parse.ParseKernelListTest; -import org.jclouds.googlecomputeengine.parse.ParseKernelTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class KernelApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { - - public void testGetKernelResponseIs2xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/kernels/12941177846308850718") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/kernel.json")).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getKernelApiForProject("myproject"); - - assertEquals(kernelApi.get("12941177846308850718"), - new ParseKernelTest().expected()); - } - - public void testGetKernelResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/kernels/12941177846308850718") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getKernelApiForProject("myproject"); - - assertNull(kernelApi.get("12941177846308850718")); - } - - public void testListKernelNoOptionsResponseIs2xx() throws Exception { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/kernels") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/kernel_list.json")).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getKernelApiForProject("myproject"); - - assertEquals(kernelApi.listFirstPage().toString(), - new ParseKernelListTest().expected().toString()); - } - - public void testListKernelsResponseIs4xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/kernels") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getKernelApiForProject("myproject"); - - assertTrue(kernelApi.list().concat().isEmpty()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiLiveTest.java deleted file mode 100644 index 8e9f971..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/KernelApiLiveTest.java +++ /dev/null @@ -1,77 +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.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.util.Iterator; -import java.util.List; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecomputeengine.domain.Kernel; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; -import org.jclouds.googlecomputeengine.options.ListOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * @author David Alves - */ -public class KernelApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { - - private Kernel kernel; - - private KernelApi api() { - return api.getKernelApiForProject("google"); - } - - @Test(groups = "live") - public void testListKernel() { - - PagedIterable<Kernel> kernels = api().list(new ListOptions.Builder() - .maxResults(1)); - - Iterator<IterableWithMarker<Kernel>> pageIterator = kernels.iterator(); - assertTrue(pageIterator.hasNext()); - - IterableWithMarker<Kernel> singlePageIterator = pageIterator.next(); - List<Kernel> kernelAsList = Lists.newArrayList(singlePageIterator); - - assertSame(kernelAsList.size(), 1); - - this.kernel = Iterables.getOnlyElement(kernelAsList); - } - - - @Test(groups = "live", dependsOnMethods = "testListKernel") - public void testGetKernel() { - Kernel kernel = api().get(this.kernel.getName()); - assertNotNull(kernel); - assertKernelEquals(kernel, this.kernel); - } - - private void assertKernelEquals(Kernel result, Kernel expected) { - assertEquals(result.getName(), expected.getName()); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelListTest.java deleted file mode 100644 index b0c6b4b..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelListTest.java +++ /dev/null @@ -1,73 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.*; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseKernelListTest extends BaseGoogleComputeEngineParseTest<ListPage<Kernel>> { - - @Override - public String resource() { - return "/kernel_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage<Kernel> expected() { - return ListPage.<Kernel>builder() - .kind(Resource.Kind.KERNEL_LIST) - .id("projects/google/global/kernels") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/google/global/kernels")) - .items(ImmutableSet.of( - Kernel.builder() - .id("12941177846308850718") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse - ("2012-07-16T21:42:16.950")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/google/global/kernels/gce-20110524")) - .name("gce-20110524") - .description("DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000").build(), - Kernel.builder() - .id("12941177983348179280") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse - ("2012-07-16T21:42:31.166")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/google/global/kernels/gce-20110728")) - .name("gce-20110728") - .description("DEPRECATED. Created Thu, 28 Jul 2011 16:44:38 +0000") - .deprecated(org.jclouds.googlecomputeengine.domain.Deprecated.builder() - .state("OBSOLETE") - .replacement(URI.create("https://www.googleapis.com/compute/v1/projects/google/global/kernels/gce-v20130603")) - .build()) - .build() - )).build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelTest.java deleted file mode 100644 index 1d179d4..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseKernelTest.java +++ /dev/null @@ -1,51 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.Kernel; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseKernelTest extends BaseGoogleComputeEngineParseTest<Kernel> { - - @Override - public String resource() { - return "/kernel.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Kernel expected() { - return Kernel.builder() - .id("12941177846308850718") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T21:42:16.950")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/google/global/kernels/gce-20110524")) - .name("gce-20110524") - .description("DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000") - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/test/resources/kernel.json ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/resources/kernel.json b/google-compute-engine/src/test/resources/kernel.json deleted file mode 100644 index eb89a1c..0000000 --- a/google-compute-engine/src/test/resources/kernel.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "kind": "compute#kernel", - "id": "12941177846308850718", - "creationTimestamp": "2012-07-16T21:42:16.950", - "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/kernels/gce-20110524", - "name": "gce-20110524", - "description": "DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000" -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/194b1897/google-compute-engine/src/test/resources/kernel_list.json ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/resources/kernel_list.json b/google-compute-engine/src/test/resources/kernel_list.json deleted file mode 100644 index f9ebc13..0000000 --- a/google-compute-engine/src/test/resources/kernel_list.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "kind": "compute#kernelList", - "id": "projects/google/global/kernels", - "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/kernels", - "items": [ - { - "kind": "compute#kernel", - "id": "12941177846308850718", - "creationTimestamp": "2012-07-16T21:42:16.950", - "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/kernels/gce-20110524", - "name": "gce-20110524", - "description": "DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000" - }, - { - "kind": "compute#kernel", - "id": "12941177983348179280", - "creationTimestamp": "2012-07-16T21:42:31.166", - "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/kernels/gce-20110728", - "name": "gce-20110728", - "description": "DEPRECATED. Created Thu, 28 Jul 2011 16:44:38 +0000", - "deprecated": { - "state": "OBSOLETE", - "replacement": "https://www.googleapis.com/compute/v1/projects/google/global/kernels/gce-v20130603" - } - } - ] -} \ No newline at end of file
