Skip to content

Commit f968d38

Browse files
committed
Add SnapshotInfo and related classes to SerializationTest, minor fixes
1 parent 741b804 commit f968d38

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

gcloud-java-compute/src/main/java/com/google/gcloud/compute/DiskId.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ DiskId setProjectId(String projectId) {
106106
}
107107

108108
/**
109-
* Returns a disk identity given the zone identity and the disk name. The address name must be
110-
* 1-63 characters long and comply with RFC1035. Specifically, the name must match the regular
109+
* Returns a disk identity given the zone identity and the disk name. The disk name must be 1-63
110+
* characters long and comply with RFC1035. Specifically, the name must match the regular
111111
* expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a
112112
* lowercase letter, and all following characters must be a dash, lowercase letter, or digit,
113113
* except the last character, which cannot be a dash.
@@ -119,7 +119,7 @@ public static DiskId of(ZoneId zoneId, String disk) {
119119
}
120120

121121
/**
122-
* Returns a disk identity given the zone and disk names. The address name must be 1-63 characters
122+
* Returns a disk identity given the zone and disk names. The disk name must be 1-63 characters
123123
* long and comply with RFC1035. Specifically, the name must match the regular expression
124124
* {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a lowercase letter,
125125
* 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) {
132132
}
133133

134134
/**
135-
* Returns a disk identity given project, zone and disks names. The address name must be 1-63
135+
* Returns a disk identity given project, zone and disks names. The disk name must be 1-63
136136
* characters long and comply with RFC1035. Specifically, the name must match the regular
137137
* expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a
138138
* lowercase letter, and all following characters must be a dash, lowercase letter, or digit,

gcloud-java-compute/src/main/java/com/google/gcloud/compute/SnapshotInfo.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ public Snapshot apply(SnapshotInfo snapshot) {
7474
private final StorageBytesStatus storageBytesStatus;
7575

7676
/**
77-
* The status of a Google Compute Engine snapshot. A snapshot can be used to create other
78-
* resources, such as disks, only after the snapshot has been successfully created and the status
79-
* is set to {@code READY}.
77+
* The status of a Google Compute Engine snapshot. A snapshot can be used to create a disk only
78+
* after the snapshot has been successfully created and the status is set to {@code READY}.
8079
*/
8180
public enum Status {
8281
/**
@@ -106,7 +105,7 @@ public enum Status {
106105
}
107106

108107
/**
109-
* An indicator whether {@link SnapshotInfo#storageBytes()} is in a stable state or it is being
108+
* An indicator of whether {@link SnapshotInfo#storageBytes()} is in a stable state or it is being
110109
* adjusted as a result of shared storage reallocation.
111110
*/
112111
public enum StorageBytesStatus {

gcloud-java-compute/src/test/java/com/google/gcloud/compute/SerializationTest.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public class SerializationTest {
147147
.usage(INSTANCE_USAGE)
148148
.build();
149149
private static final Address ADDRESS = new Address.Builder(COMPUTE, REGION_ADDRESS_ID).build();
150+
private static final DiskId DISK_ID = DiskId.of("project", "zone", "disk");
151+
private static final SnapshotId SNAPSHOT_ID = SnapshotId.of("project", "snapshot");
152+
private static final SnapshotInfo SNAPSHOT_INFO = SnapshotInfo.of(SNAPSHOT_ID, DISK_ID);
150153
private static final Compute.DiskTypeOption DISK_TYPE_OPTION =
151154
Compute.DiskTypeOption.fields();
152155
private static final Compute.DiskTypeFilter DISK_TYPE_FILTER =
@@ -212,11 +215,12 @@ public void testModelAndRequests() throws Exception {
212215
REGION_OPERATION_ID, ZONE_OPERATION_ID, GLOBAL_OPERATION, REGION_OPERATION, ZONE_OPERATION,
213216
INSTANCE_ID, REGION_FORWARDING_RULE_ID, GLOBAL_FORWARDING_RULE_ID, GLOBAL_ADDRESS_ID,
214217
REGION_ADDRESS_ID, INSTANCE_USAGE, GLOBAL_FORWARDING_USAGE, REGION_FORWARDING_USAGE,
215-
ADDRESS_INFO, ADDRESS, DISK_TYPE_OPTION, DISK_TYPE_FILTER, DISK_TYPE_LIST_OPTION,
216-
DISK_TYPE_AGGREGATED_LIST_OPTION, MACHINE_TYPE_OPTION, MACHINE_TYPE_FILTER,
217-
MACHINE_TYPE_LIST_OPTION, MACHINE_TYPE_AGGREGATED_LIST_OPTION, REGION_OPTION, REGION_FILTER,
218-
REGION_LIST_OPTION, ZONE_OPTION, ZONE_FILTER, ZONE_LIST_OPTION, LICENSE_OPTION,
219-
OPERATION_OPTION, OPERATION_FILTER, OPERATION_LIST_OPTION, ADDRESS_OPTION, ADDRESS_FILTER,
218+
ADDRESS_INFO, ADDRESS, DISK_ID, SNAPSHOT_ID, SNAPSHOT_INFO, DISK_TYPE_OPTION,
219+
DISK_TYPE_FILTER, DISK_TYPE_LIST_OPTION, DISK_TYPE_AGGREGATED_LIST_OPTION,
220+
MACHINE_TYPE_OPTION, MACHINE_TYPE_FILTER, MACHINE_TYPE_LIST_OPTION,
221+
MACHINE_TYPE_AGGREGATED_LIST_OPTION, REGION_OPTION, REGION_FILTER, REGION_LIST_OPTION,
222+
ZONE_OPTION, ZONE_FILTER, ZONE_LIST_OPTION, LICENSE_OPTION, OPERATION_OPTION,
223+
OPERATION_FILTER, OPERATION_LIST_OPTION, ADDRESS_OPTION, ADDRESS_FILTER,
220224
ADDRESS_LIST_OPTION, ADDRESS_AGGREGATED_LIST_OPTION};
221225
for (Serializable obj : objects) {
222226
Object copy = serializeAndDeserialize(obj);

gcloud-java-compute/src/test/java/com/google/gcloud/compute/SnapshotIdTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public void testSetProjectId() {
6565

6666
@Test
6767
public void testMatchesUrl() {
68-
assertTrue(GlobalOperationId.matchesUrl(GlobalOperationId.of(PROJECT, NAME).selfLink()));
69-
assertFalse(GlobalOperationId.matchesUrl("notMatchingUrl"));
68+
assertTrue(SnapshotId.matchesUrl(SnapshotId.of(PROJECT, NAME).selfLink()));
69+
assertFalse(SnapshotId.matchesUrl("notMatchingUrl"));
7070
}
7171

7272
private void compareSnapshotId(SnapshotId expected, SnapshotId value) {

0 commit comments

Comments
 (0)