From 87ff2665756fe62b040a2d6fcbe4942981a6060e Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 17 Dec 2015 09:11:14 -0800 Subject: [PATCH] Minor docs and tests fixes --- gcloud-java-resourcemanager/README.md | 4 +- .../gcloud/resourcemanager/ProjectInfo.java | 41 +++++++++---------- .../resourcemanager/ProjectInfoTest.java | 1 + 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index ce56efe009fd..4e6ebecbbe5c 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -88,7 +88,7 @@ All you need to create a project is a globally unique project ID. You can also import com.google.gcloud.resourcemanager.ProjectInfo; ``` -Then add the following code to create a project (be sure to change `myProjectId` to be something unique). +Then add the following code to create a project (be sure to change `myProjectId` to your own unique project ID). ```java String myProjectId = "my-globally-unique-project-id"; // Change to a unique project ID. @@ -135,7 +135,7 @@ while (projectIterator.hasNext()) { #### Complete source code -Here we put together all the code shown above into one program. This program assumes that you are running from your own desktop. +Here we put together all the code shown above into one program. This program assumes that you are running from your own desktop and used the Google Cloud SDK to authenticate yourself. ```java import com.google.gcloud.resourcemanager.ProjectInfo; 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 48275d0194e1..2cb8a2d93ad2 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 @@ -50,12 +50,12 @@ public class ProjectInfo implements Serializable { */ public enum State { /** - * Only used/useful for distinguishing unset values + * Only used/useful for distinguishing unset values. */ LIFECYCLE_STATE_UNSPECIFIED, /** - * The normal and active state + * The normal and active state. */ ACTIVE, @@ -66,7 +66,7 @@ public enum State { DELETE_REQUESTED, /** - * the process of deleting the project has begun. Reversing the deletion is no longer possible. + * The process of deleting the project has begun. Reversing the deletion is no longer possible. */ DELETE_IN_PROGRESS } @@ -105,7 +105,7 @@ com.google.api.services.cloudresourcemanager.model.ResourceId toPb() { com.google.api.services.cloudresourcemanager.model.ResourceId resourceIdPb = new com.google.api.services.cloudresourcemanager.model.ResourceId(); resourceIdPb.setId(id); - resourceIdPb.setType(type.toString().toLowerCase()); + resourceIdPb.setType(type.toLowerCase()); return resourceIdPb; } @@ -141,9 +141,9 @@ private Builder() { /** * Set the user-assigned name of the project. * - * This field is optional and can remain unset. Allowed characters are: lowercase and uppercase - * letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. This - * field can be changed after project creation. + *

This field is optional and can remain unset. Allowed characters are: lowercase and + * uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. + * This field can be changed after project creation. */ public Builder name(String name) { this.name = firstNonNull(name, Data.nullOf(String.class)); @@ -153,7 +153,7 @@ public Builder name(String name) { /** * Set the unique, user-assigned ID of the project. * - * The ID must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. + *

The ID must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. * Trailing hyphens are prohibited. This field cannot be changed after the server creates the * project. */ @@ -165,7 +165,7 @@ public Builder projectId(String projectId) { /** * Add a label associated with this project. * - * See {@link #labels} for label restrictions. + *

See {@link #labels} for label restrictions. */ public Builder addLabel(String key, String value) { this.labels.put(key, value); @@ -191,11 +191,11 @@ public Builder clearLabels() { /** * Set the labels associated with this project. * - * Label keys must be between 1 and 63 characters long and must conform to the following regular - * expression: [a-z]([-a-z0-9]*[a-z0-9])?. Label values must be between 0 and 63 characters long - * and must conform to the regular expression ([a-z]([-a-z0-9]*[a-z0-9])?)?. No more than 256 - * labels can be associated with a given resource. This field can be changed after project - * creation. + *

Label keys must be between 1 and 63 characters long and must conform to the following + * regular expression: [a-z]([-a-z0-9]*[a-z0-9])?. Label values must be between 0 and 63 + * characters long and must conform to the regular expression ([a-z]([-a-z0-9]*[a-z0-9])?)?. No + * more than 256 labels can be associated with a given resource. This field can be changed after + * project creation. */ public Builder labels(Map labels) { this.labels = Maps.newHashMap(checkNotNull(labels)); @@ -240,7 +240,7 @@ public ProjectInfo build() { /** * Get the unique, user-assigned ID of the project. * - * This field cannot be changed after the server creates the project. + *

This field cannot be changed after the server creates the project. */ public String projectId() { return projectId; @@ -249,7 +249,7 @@ public String projectId() { /** * Get the user-assigned name of the project. * - * This field is optional, can remain unset, and can be changed after project creation. + *

This field is optional, can remain unset, and can be changed after project creation. */ public String name() { return Data.isNull(name) ? null : name; @@ -258,7 +258,7 @@ public String name() { /** * Get number uniquely identifying the project. * - * This field is set by the server and is read-only. + *

This field is set by the server and is read-only. */ public Long projectNumber() { return projectNumber; @@ -274,7 +274,7 @@ public Map labels() { /** * Get the project's lifecycle state. * - * This is a read-only field. To change the lifecycle state of your project, use the + *

This is a read-only field. To change the lifecycle state of your project, use the * {@code delete} or {@code undelete} method. */ public State state() { @@ -288,7 +288,7 @@ ResourceId parent() { /** * Get the project's creation time (in milliseconds). * - * This field is set by the server and is read-only. + *

This field is set by the server and is read-only. */ public Long createTimeMillis() { return createTimeMillis; @@ -332,8 +332,7 @@ com.google.api.services.cloudresourcemanager.model.Project toPb() { } static ProjectInfo fromPb(com.google.api.services.cloudresourcemanager.model.Project projectPb) { - ProjectInfo.Builder builder = - ProjectInfo.builder(projectPb.getProjectId()).projectNumber(projectPb.getProjectNumber()); + Builder builder = builder(projectPb.getProjectId()).projectNumber(projectPb.getProjectNumber()); if (projectPb.getName() != null && !projectPb.getName().equals("Unnamed")) { builder.name(projectPb.getName()); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectInfoTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectInfoTest.java index 0a7df4e66b48..3aaef8047322 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectInfoTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectInfoTest.java @@ -73,6 +73,7 @@ public void testToBuilder() { @Test public void testToAndFromPb() { + assertTrue(FULL_PROJECT_INFO.toPb().getCreateTime().endsWith("Z")); compareProjects(FULL_PROJECT_INFO, ProjectInfo.fromPb(FULL_PROJECT_INFO.toPb())); compareProjects(PARTIAL_PROJECT_INFO, ProjectInfo.fromPb(PARTIAL_PROJECT_INFO.toPb())); compareProjects(PARTIAL_PROJECT_INFO, ProjectInfo.fromPb(UNNAMED_PROJECT_FROM_LIST.toPb()));