diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java index 7b48e595ae0d..5d490e662df0 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java @@ -132,7 +132,7 @@ private Builder() { Builder(ProjectInfo info) { this.name = info.name; this.projectId = info.projectId; - this.labels = Maps.newHashMap(checkNotNull(info.labels)); + this.labels.putAll(info.labels); this.projectNumber = info.projectNumber; this.state = info.state; this.createTimeMillis = info.createTimeMillis; @@ -159,7 +159,7 @@ public Builder name(String name) { * project. */ public Builder projectId(String projectId) { - this.projectId = projectId; + this.projectId = checkNotNull(projectId); return this; } @@ -230,7 +230,7 @@ public ProjectInfo build() { ProjectInfo(Builder builder) { this.name = builder.name; - this.projectId = checkNotNull(builder.projectId); + this.projectId = builder.projectId; this.labels = ImmutableMap.copyOf(builder.labels); this.projectNumber = builder.projectNumber; this.state = builder.state; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index b8631a9ae881..9aabd640b018 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -36,7 +36,7 @@ public interface ResourceManager extends Service { /** * The fields of a project. * - * These values can be used to specify the fields to include of in a partial response when calling + * These values can be used to specify the fields to include in a partial response when calling * {@link ResourceManager#get} or {@link ResourceManager#list}. Project ID is always returned, * even if not specified. */ diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java index 45f8f9de75e9..d73c6ae4015c 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java @@ -17,6 +17,7 @@ public class DefaultResourceManagerRpc implements ResourceManagerRpc { + // see https://cloud.google.com/resource-manager/v1/errors/core_errors private static final Set RETRYABLE_CODES = ImmutableSet.of(503, 500, 429, 417); private final ResourceManagerOptions options; @@ -45,9 +46,7 @@ private static ResourceManagerException translate(IOException exception) { } private static ResourceManagerException translate(GoogleJsonError exception) { - boolean retryable = - RETRYABLE_CODES.contains(exception.getCode()) - || "InternalError".equals(exception.getMessage()); + boolean retryable = RETRYABLE_CODES.contains(exception.getCode()); return new ResourceManagerException(exception.getCode(), exception.getMessage(), retryable); } @@ -63,7 +62,7 @@ public void delete(String projectId) throws ResourceManagerException { } @Override - public Project get(String projectId) throws ResourceManagerException { + public Project get(String projectId, Map options) throws ResourceManagerException { // TODO(ajaykannan): fix me! return null; } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java index f7e330639399..ec96e26e0be5 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java @@ -77,7 +77,7 @@ public Y y() { void delete(String projectId) throws ResourceManagerException; - Project get(String projectId) throws ResourceManagerException; + Project get(String projectId, Map options) throws ResourceManagerException; Tuple> list(Map options) throws ResourceManagerException; diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java index 223dd5b14289..65bb37dbccf9 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java @@ -18,7 +18,6 @@ import static org.easymock.EasyMock.createStrictMock; import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; @@ -94,7 +93,6 @@ public void testResourceManager() { @Test public void testDelete() { resourceManager.delete(PROJECT_INFO.projectId()); - expectLastCall(); replay(resourceManager); project.delete(); } @@ -102,7 +100,6 @@ public void testDelete() { @Test public void testUndelete() { resourceManager.undelete(PROJECT_INFO.projectId()); - expectLastCall(); replay(resourceManager); project.undelete(); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index dd8fb8014bf0..8b61519fc106 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -46,6 +46,10 @@ public class SerializationTest { .build(); private static final PageImpl PAGE_RESULT = new PageImpl<>(null, "c", Collections.singletonList(PARTIAL_PROJECT_INFO)); + private static final ResourceManager.ProjectGetOption PROJECT_GET_OPTION = + ResourceManager.ProjectGetOption.fields(ResourceManager.ProjectField.NAME); + private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = + ResourceManager.ProjectListOption.filter("name:*"); @Test public void testServiceOptions() throws Exception { @@ -63,7 +67,8 @@ public void testServiceOptions() throws Exception { @Test public void testModelAndRequests() throws Exception { - Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PAGE_RESULT}; + Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PAGE_RESULT, + PROJECT_GET_OPTION, PROJECT_LIST_OPTION}; for (Serializable obj : objects) { Object copy = serializeAndDeserialize(obj); assertEquals(obj, obj);