From f968d386eb8e8da983ca2414e3a994fe76616220 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 23 Mar 2016 17:10:21 +0100 Subject: [PATCH] Add SnapshotInfo and related classes to SerializationTest, minor fixes --- .../java/com/google/gcloud/compute/DiskId.java | 8 ++++---- .../com/google/gcloud/compute/SnapshotInfo.java | 7 +++---- .../google/gcloud/compute/SerializationTest.java | 14 +++++++++----- .../com/google/gcloud/compute/SnapshotIdTest.java | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/DiskId.java b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/DiskId.java index b2a0f3e45db7..7338e04ef5d8 100644 --- a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/DiskId.java +++ b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/DiskId.java @@ -106,8 +106,8 @@ DiskId setProjectId(String projectId) { } /** - * Returns a disk identity given the zone identity and the disk name. The address name must be - * 1-63 characters long and comply with RFC1035. Specifically, the name must match the regular + * Returns a disk identity given the zone identity and the disk name. The disk name must be 1-63 + * characters long and comply with RFC1035. Specifically, the name must match the regular * expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a * lowercase letter, and all following characters must be a dash, lowercase letter, or digit, * except the last character, which cannot be a dash. @@ -119,7 +119,7 @@ public static DiskId of(ZoneId zoneId, String disk) { } /** - * Returns a disk identity given the zone and disk names. The address name must be 1-63 characters + * Returns a disk identity given the zone and disk names. The disk name must be 1-63 characters * long and comply with RFC1035. Specifically, the name must match the regular expression * {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a lowercase letter, * and all following characters must be a dash, lowercase letter, or digit, except the last @@ -132,7 +132,7 @@ public static DiskId of(String zone, String disk) { } /** - * Returns a disk identity given project, zone and disks names. The address name must be 1-63 + * Returns a disk identity given project, zone and disks names. The disk name must be 1-63 * characters long and comply with RFC1035. Specifically, the name must match the regular * expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a * lowercase letter, and all following characters must be a dash, lowercase letter, or digit, diff --git a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/SnapshotInfo.java b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/SnapshotInfo.java index 283ca665d173..fe567988d82c 100644 --- a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/SnapshotInfo.java +++ b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/SnapshotInfo.java @@ -74,9 +74,8 @@ public Snapshot apply(SnapshotInfo snapshot) { private final StorageBytesStatus storageBytesStatus; /** - * The status of a Google Compute Engine snapshot. A snapshot can be used to create other - * resources, such as disks, only after the snapshot has been successfully created and the status - * is set to {@code READY}. + * The status of a Google Compute Engine snapshot. A snapshot can be used to create a disk only + * after the snapshot has been successfully created and the status is set to {@code READY}. */ public enum Status { /** @@ -106,7 +105,7 @@ public enum Status { } /** - * An indicator whether {@link SnapshotInfo#storageBytes()} is in a stable state or it is being + * An indicator of whether {@link SnapshotInfo#storageBytes()} is in a stable state or it is being * adjusted as a result of shared storage reallocation. */ public enum StorageBytesStatus { diff --git a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SerializationTest.java b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SerializationTest.java index 81afee4acf50..8b5956cef100 100644 --- a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SerializationTest.java +++ b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SerializationTest.java @@ -147,6 +147,9 @@ public class SerializationTest { .usage(INSTANCE_USAGE) .build(); private static final Address ADDRESS = new Address.Builder(COMPUTE, REGION_ADDRESS_ID).build(); + private static final DiskId DISK_ID = DiskId.of("project", "zone", "disk"); + private static final SnapshotId SNAPSHOT_ID = SnapshotId.of("project", "snapshot"); + private static final SnapshotInfo SNAPSHOT_INFO = SnapshotInfo.of(SNAPSHOT_ID, DISK_ID); private static final Compute.DiskTypeOption DISK_TYPE_OPTION = Compute.DiskTypeOption.fields(); private static final Compute.DiskTypeFilter DISK_TYPE_FILTER = @@ -212,11 +215,12 @@ public void testModelAndRequests() throws Exception { REGION_OPERATION_ID, ZONE_OPERATION_ID, GLOBAL_OPERATION, REGION_OPERATION, ZONE_OPERATION, INSTANCE_ID, REGION_FORWARDING_RULE_ID, GLOBAL_FORWARDING_RULE_ID, GLOBAL_ADDRESS_ID, REGION_ADDRESS_ID, INSTANCE_USAGE, GLOBAL_FORWARDING_USAGE, REGION_FORWARDING_USAGE, - ADDRESS_INFO, ADDRESS, DISK_TYPE_OPTION, DISK_TYPE_FILTER, DISK_TYPE_LIST_OPTION, - DISK_TYPE_AGGREGATED_LIST_OPTION, MACHINE_TYPE_OPTION, MACHINE_TYPE_FILTER, - MACHINE_TYPE_LIST_OPTION, MACHINE_TYPE_AGGREGATED_LIST_OPTION, REGION_OPTION, REGION_FILTER, - REGION_LIST_OPTION, ZONE_OPTION, ZONE_FILTER, ZONE_LIST_OPTION, LICENSE_OPTION, - OPERATION_OPTION, OPERATION_FILTER, OPERATION_LIST_OPTION, ADDRESS_OPTION, ADDRESS_FILTER, + ADDRESS_INFO, ADDRESS, DISK_ID, SNAPSHOT_ID, SNAPSHOT_INFO, DISK_TYPE_OPTION, + DISK_TYPE_FILTER, DISK_TYPE_LIST_OPTION, DISK_TYPE_AGGREGATED_LIST_OPTION, + MACHINE_TYPE_OPTION, MACHINE_TYPE_FILTER, MACHINE_TYPE_LIST_OPTION, + MACHINE_TYPE_AGGREGATED_LIST_OPTION, REGION_OPTION, REGION_FILTER, REGION_LIST_OPTION, + ZONE_OPTION, ZONE_FILTER, ZONE_LIST_OPTION, LICENSE_OPTION, OPERATION_OPTION, + OPERATION_FILTER, OPERATION_LIST_OPTION, ADDRESS_OPTION, ADDRESS_FILTER, ADDRESS_LIST_OPTION, ADDRESS_AGGREGATED_LIST_OPTION}; for (Serializable obj : objects) { Object copy = serializeAndDeserialize(obj); diff --git a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SnapshotIdTest.java b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SnapshotIdTest.java index cbda6fd3ebd0..13dadee790b9 100644 --- a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SnapshotIdTest.java +++ b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/SnapshotIdTest.java @@ -65,8 +65,8 @@ public void testSetProjectId() { @Test public void testMatchesUrl() { - assertTrue(GlobalOperationId.matchesUrl(GlobalOperationId.of(PROJECT, NAME).selfLink())); - assertFalse(GlobalOperationId.matchesUrl("notMatchingUrl")); + assertTrue(SnapshotId.matchesUrl(SnapshotId.of(PROJECT, NAME).selfLink())); + assertFalse(SnapshotId.matchesUrl("notMatchingUrl")); } private void compareSnapshotId(SnapshotId expected, SnapshotId value) {