Skip to content

Commit 785c3fe

Browse files
committed
Add test for missing fields, fix NPE, minor docs and lint fixes
1 parent d34490f commit 785c3fe

9 files changed

Lines changed: 15 additions & 8 deletions

File tree

gcloud-java-compute/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Java idiomatic client for [Google Cloud Compute] (https://cloud.google.com/compu
1010
[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969)
1111

1212
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
13-
<!-- TODO(mziccard): add link to API documentatin -->
13+
14+
<!-- TODO(mziccard): add link to API documentation -->
1415

1516
> Note: This client is a work-in-progress, and may occasionally
1617
> make backwards-incompatible changes.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ public static DiskTypeId of(ZoneId zoneId, String diskType) {
9999
}
100100

101101
/**
102-
* Returns a disk type identity given the zone disk and disk type.
102+
* Returns a disk type identity given the zone and disk type names.
103103
*/
104104
public static DiskTypeId of(String zone, String diskType) {
105105
return of(ZoneId.of(null, zone), diskType);
106106
}
107107

108108
/**
109-
* Returns a disk type identity given project disk, zone disk and disk type.
109+
* Returns a disk type identity given project disk, zone and disk type names.
110110
*/
111111
public static DiskTypeId of(String project, String zone, String diskType) {
112112
return of(ZoneId.of(project, zone), diskType);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public MachineTypeId machineTypeId() {
164164
}
165165

166166
/**
167-
* Returns an unique identifier for the machin type; defined by the service.
167+
* Returns an unique identifier for the machine type; defined by the service.
168168
*/
169169
public BigInteger id() {
170170
return id;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ com.google.api.services.compute.model.Region toPb() {
327327
regionPb.setName(regionId.region());
328328
regionPb.setDescription(description);
329329
regionPb.setSelfLink(selfLink);
330-
regionPb.setStatus(status.name());
330+
if (status != null) {
331+
regionPb.setStatus(status.name());
332+
}
331333
if (zones != null) {
332334
regionPb.setZones(Lists.transform(zones, ZoneId.TO_URL_FUNCTION));
333335
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ com.google.api.services.compute.model.Zone toPb() {
356356
zonePb.setName(zoneId.zone());
357357
zonePb.setDescription(description);
358358
zonePb.setSelfLink(selfLink);
359-
zonePb.setStatus(status.name());
359+
if (status != null) {
360+
zonePb.setStatus(status.name());
361+
}
360362
if (maintenanceWindows != null) {
361363
zonePb.setMaintenanceWindows(
362364
Lists.transform(maintenanceWindows, MaintenanceWindow.TO_PB_FUNCTION));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public void testBuilder() {
6363
public void testToPbAndFromPb() {
6464
compareDiskTypes(DISK_TYPE, DiskType.fromPb(DISK_TYPE.toPb()));
6565
DiskType diskType = DiskType.builder()
66-
.id(ID)
6766
.diskTypeId(DISK_TYPE_ID)
6867
.selfLink(DISK_TYPE_ID.toUrl())
6968
.build();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public void testBuilder() {
7575
public void testToPbAndFromPb() {
7676
compareMachineTypes(MACHINE_TYPE, MachineType.fromPb(MACHINE_TYPE.toPb()));
7777
MachineType machineType = MachineType.builder()
78-
.id(ID)
7978
.machineTypeId(MACHINE_TYPE_ID)
8079
.selfLink(MACHINE_TYPE_ID.toUrl())
8180
.build();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public void testToAndFromPb() {
7676
compareRegions(REGION, region);
7777
assertEquals(REGION_ID.project(), region.regionId().project());
7878
assertEquals(REGION_ID.region(), region.regionId().region());
79+
region = Region.builder().regionId(REGION_ID).selfLink(REGION_ID.toUrl()).build();
80+
compareRegions(region, Region.fromPb(region.toPb()));
7981
}
8082

8183
private void compareRegions(Region expected, Region value) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public void testToAndFromPb() {
7777
compareZones(ZONE, zone);
7878
assertEquals(ZONE_ID.project(), zone.zoneId().project());
7979
assertEquals(ZONE_ID.zone(), zone.zoneId().zone());
80+
zone = Zone.builder().zoneId(ZONE_ID).selfLink(ZONE_ID.toUrl()).build();
81+
compareZones(zone, Zone.fromPb(zone.toPb()));
8082
}
8183

8284
private void compareZones(Zone expected, Zone value) {

0 commit comments

Comments
 (0)