Skip to content

Commit

Permalink
Fix DiskInfo and configurations javadoc and test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Apr 5, 2016
1 parent d238c52 commit bf5d90b
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import java.util.Objects;

/**
* Base class for Google Compute Engine disk configuration. A disk can be used as primary storage
* Base class for Google Compute Engine disk configurations. A disk can be used as primary storage
* for your virtual machine instances. Use {@link StandardDiskConfiguration} to create a standard
* disk given disk type and size. Use {@link ImageDiskConfiguration} to create a disk from a Compute
* disk given a disk type and size. Use {@link ImageDiskConfiguration} to create a disk from a Compute
* Engine disk image. Use {@link SnapshotDiskConfiguration} to create a disk from a Compute Engine
* disk snapshot.
*
Expand Down Expand Up @@ -109,7 +109,7 @@ public B sizeGb(Long sizeGb) {
}

/**
* Sets the identity of the disk diskType.
* Sets the identity of the disk type.
*/
public B diskType(DiskTypeId diskType) {
this.diskType = diskType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public List<LicenseId> licenses() {
}

/**
* Returns all instances' identities this disk is attached to.
* Returns all the identities of the instances this disk is attached to.
*/
public List<InstanceId> attachedInstances() {
return attachedInstances;
Expand Down Expand Up @@ -380,7 +380,7 @@ public boolean equals(Object obj) {
* Returns a builder for a {@code DiskInfo} object given its identity and configuration. Use
* {@link StandardDiskConfiguration} to create a simple disk given its type and size. Use
* {@link SnapshotDiskConfiguration} to create a disk from a snapshot. Use
* {@link ImageDiskConfiguration} to create a disk form a disk image.
* {@link ImageDiskConfiguration} to create a disk from a disk image.
*/
public static Builder builder(DiskId diskId, DiskConfiguration configuration) {
return new BuilderImpl().diskId(diskId).configuration(configuration);
Expand All @@ -390,7 +390,7 @@ public static Builder builder(DiskId diskId, DiskConfiguration configuration) {
* Returns a {@code DiskInfo} object given its identity and configuration. Use
* {@link StandardDiskConfiguration} to create a simple disk given its type and size. Use
* {@link SnapshotDiskConfiguration} to create a disk from a snapshot. Use
* {@link ImageDiskConfiguration} to create a disk form a disk image.
* {@link ImageDiskConfiguration} to create a disk from a disk image.
*/
public static DiskInfo of(DiskId diskId, DiskConfiguration configuration) {
return builder(diskId, configuration).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ private Builder() {
super(Type.IMAGE);
}

private Builder(ImageDiskConfiguration imageDiskConfiguration) {
super(Type.IMAGE, imageDiskConfiguration);
this.sourceImage = imageDiskConfiguration.sourceImage;
this.sourceImageId = imageDiskConfiguration.sourceImageId;
private Builder(ImageDiskConfiguration configuration) {
super(Type.IMAGE, configuration);
this.sourceImage = configuration.sourceImage;
this.sourceImageId = configuration.sourceImageId;
}

private Builder(Disk diskPb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
* A Google Compute Engine disk configuration to create a disk from a Google Compute Engine
* snaoshot.
* snapshot.
*
* @see <a href="https://cloud.google.com/compute/docs/disks/">Block Storage</a>
*/
Expand All @@ -49,10 +49,10 @@ private Builder() {
super(Type.SNAPSHOT);
}

private Builder(SnapshotDiskConfiguration snapshotDiskInfo) {
super(Type.SNAPSHOT, snapshotDiskInfo);
this.sourceSnapshot = snapshotDiskInfo.sourceSnapshot;
this.sourceSnapshotId = snapshotDiskInfo.sourceSnapshotId;
private Builder(SnapshotDiskConfiguration configuration) {
super(Type.SNAPSHOT, configuration);
this.sourceSnapshot = configuration.sourceSnapshot;
this.sourceSnapshotId = configuration.sourceSnapshotId;
}

private Builder(Disk diskPb) {
Expand Down Expand Up @@ -147,7 +147,7 @@ Disk toPb() {
/**
* Returns a builder for a {@code SnapshotDiskConfiguration} object given the snapshot identity.
*/
static Builder builder(SnapshotId sourceSnapshot) {
public static Builder builder(SnapshotId sourceSnapshot) {
return new Builder().sourceSnapshot(sourceSnapshot);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.Objects;

/**
* A Google Compute Engine standard persistent disk configuration. Allows to create a disk given its
* type and size.
* A Google Compute Engine standard persistent disk configuration. This class allows users to create
* a disk given its type and size.
*
* @see <a href="https://cloud.google.com/compute/docs/disks/">Block Storage</a>
*/
Expand All @@ -40,8 +40,8 @@ private Builder() {
super(Type.STANDARD);
}

private Builder(StandardDiskConfiguration diskInfo) {
super(Type.STANDARD, diskInfo);
private Builder(StandardDiskConfiguration configuration) {
super(Type.STANDARD, configuration);
}

private Builder(Disk diskPb) {
Expand All @@ -57,7 +57,7 @@ public StandardDiskConfiguration build() {
}
}

private StandardDiskConfiguration(StandardDiskConfiguration.Builder builder) {
private StandardDiskConfiguration(Builder builder) {
super(builder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class DiskInfoTest {
.description(DESCRIPTION)
.licenses(LICENSES)
.attachedInstances(ATTACHED_INSTANCES)
.lastAttachTimestamp(LAST_ATTACH_TIMESTAMP)
.lastDetachTimestamp(LAST_DETACH_TIMESTAMP)
.build();
private static final DiskInfo SNAPSHOT_DISK_INFO =
DiskInfo.builder(DISK_ID, SNAPSHOT_DISK_CONFIGURATION)
Expand Down Expand Up @@ -119,26 +121,35 @@ public void testToBuilderIncomplete() {
@Test
public void testBuilder() {
assertEquals(ID, DISK_INFO.id());
assertEquals(DISK_ID, DISK_INFO.diskId());
assertEquals(DISK_CONFIGURATION, DISK_INFO.configuration());
assertEquals(CREATION_TIMESTAMP, DISK_INFO.creationTimestamp());
assertEquals(CREATION_STATUS, DISK_INFO.creationStatus());
assertEquals(DESCRIPTION, DISK_INFO.description());
assertEquals(LICENSES, DISK_INFO.licenses());
assertEquals(ATTACHED_INSTANCES, DISK_INFO.attachedInstances());
assertEquals(LAST_ATTACH_TIMESTAMP, DISK_INFO.lastAttachTimestamp());
assertEquals(LAST_DETACH_TIMESTAMP, DISK_INFO.lastDetachTimestamp());
assertEquals(ID, IMAGE_DISK_INFO.id());
assertEquals(DISK_ID, IMAGE_DISK_INFO.diskId());
assertEquals(IMAGE_DISK_CONFIGURATION, IMAGE_DISK_INFO.configuration());
assertEquals(CREATION_TIMESTAMP, IMAGE_DISK_INFO.creationTimestamp());
assertEquals(CREATION_STATUS, IMAGE_DISK_INFO.creationStatus());
assertEquals(DESCRIPTION, IMAGE_DISK_INFO.description());
assertEquals(LICENSES, IMAGE_DISK_INFO.licenses());
assertEquals(ATTACHED_INSTANCES, IMAGE_DISK_INFO.attachedInstances());
assertEquals(LAST_ATTACH_TIMESTAMP, IMAGE_DISK_INFO.lastAttachTimestamp());
assertEquals(LAST_DETACH_TIMESTAMP, IMAGE_DISK_INFO.lastDetachTimestamp());
assertEquals(ID, SNAPSHOT_DISK_INFO.id());
assertEquals(DISK_ID, SNAPSHOT_DISK_INFO.diskId());
assertEquals(SNAPSHOT_DISK_CONFIGURATION, SNAPSHOT_DISK_INFO.configuration());
assertEquals(CREATION_TIMESTAMP, SNAPSHOT_DISK_INFO.creationTimestamp());
assertEquals(CREATION_STATUS, SNAPSHOT_DISK_INFO.creationStatus());
assertEquals(DESCRIPTION, SNAPSHOT_DISK_INFO.description());
assertEquals(LICENSES, SNAPSHOT_DISK_INFO.licenses());
assertEquals(ATTACHED_INSTANCES, SNAPSHOT_DISK_INFO.attachedInstances());
assertEquals(LAST_ATTACH_TIMESTAMP, SNAPSHOT_DISK_INFO.lastAttachTimestamp());
assertEquals(LAST_DETACH_TIMESTAMP, SNAPSHOT_DISK_INFO.lastDetachTimestamp());
}

@Test
Expand All @@ -152,6 +163,8 @@ public void testOf() {
assertNull(diskInfo.description());
assertNull(diskInfo.licenses());
assertNull(diskInfo.attachedInstances());
assertNull(diskInfo.lastAttachTimestamp());
assertNull(diskInfo.lastDetachTimestamp());
diskInfo = DiskInfo.of(DISK_ID, IMAGE_DISK_CONFIGURATION);
assertNull(diskInfo.id());
assertEquals(DISK_ID, diskInfo.diskId());
Expand All @@ -161,6 +174,8 @@ public void testOf() {
assertNull(diskInfo.description());
assertNull(diskInfo.licenses());
assertNull(diskInfo.attachedInstances());
assertNull(diskInfo.lastAttachTimestamp());
assertNull(diskInfo.lastDetachTimestamp());
diskInfo = DiskInfo.of(DISK_ID, SNAPSHOT_DISK_CONFIGURATION);
assertNull(diskInfo.id());
assertEquals(DISK_ID, diskInfo.diskId());
Expand All @@ -170,6 +185,8 @@ public void testOf() {
assertNull(diskInfo.description());
assertNull(diskInfo.licenses());
assertNull(diskInfo.attachedInstances());
assertNull(diskInfo.lastAttachTimestamp());
assertNull(diskInfo.lastDetachTimestamp());
}

@Test
Expand Down Expand Up @@ -238,11 +255,14 @@ public void compareDiskInfo(DiskInfo expected, DiskInfo value) {
assertEquals(expected, value);
assertEquals(expected.configuration(), value.configuration());
assertEquals(expected.id(), value.id());
assertEquals(expected.diskId(), value.diskId());
assertEquals(expected.creationTimestamp(), value.creationTimestamp());
assertEquals(expected.creationStatus(), value.creationStatus());
assertEquals(expected.description(), value.description());
assertEquals(expected.licenses(), value.licenses());
assertEquals(expected.attachedInstances(), value.attachedInstances());
assertEquals(expected.lastAttachTimestamp(), value.lastAttachTimestamp());
assertEquals(expected.lastDetachTimestamp(), value.lastDetachTimestamp());
assertEquals(expected.hashCode(), value.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ImageDiskConfigurationTest {
@Test
public void testToBuilder() {
compareImageDiskConfiguration(DISK_CONFIGURATION, DISK_CONFIGURATION.toBuilder().build());
ImageId newImageId = ImageId.of("newProjet", "newImage");
ImageId newImageId = ImageId.of("newProject", "newImage");
ImageDiskConfiguration diskConfiguration = DISK_CONFIGURATION.toBuilder()
.sizeGb(24L)
.sourceImage(newImageId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class SnapshotDiskConfigurationTest {
@Test
public void testToBuilder() {
compareSnapshotDiskConfiguration(DISK_CONFIGURATION, DISK_CONFIGURATION.toBuilder().build());
SnapshotId newSnapshot = SnapshotId.of("newProjet", "newSnapshot");
SnapshotId newSnapshot = SnapshotId.of("newProject", "newSnapshot");
SnapshotDiskConfiguration diskConfiguration = DISK_CONFIGURATION.toBuilder()
.sizeGb(24L)
.sourceSnapshot(newSnapshot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ public class StandardDiskConfigurationTest {

@Test
public void testToBuilder() {
compareDefaultDiskConfiguration(DISK_CONFIGURATION, DISK_CONFIGURATION.toBuilder().build());
compareStandardDiskConfiguration(DISK_CONFIGURATION, DISK_CONFIGURATION.toBuilder().build());
StandardDiskConfiguration diskConfiguration = DISK_CONFIGURATION.toBuilder()
.sizeGb(24L)
.build();
assertEquals(24L, diskConfiguration.sizeGb().longValue());
diskConfiguration = diskConfiguration.toBuilder()
.sizeGb(SIZE)
.build();
compareDefaultDiskConfiguration(DISK_CONFIGURATION, diskConfiguration);
compareStandardDiskConfiguration(DISK_CONFIGURATION, diskConfiguration);
}

@Test
public void testToBuilderIncomplete() {
StandardDiskConfiguration diskConfiguration = StandardDiskConfiguration.of(DISK_TYPE);
compareDefaultDiskConfiguration(diskConfiguration, diskConfiguration.toBuilder().build());
compareStandardDiskConfiguration(diskConfiguration, diskConfiguration.toBuilder().build());
}

@Test
Expand All @@ -64,7 +64,7 @@ public void testBuilder() {
public void testToAndFromPb() {
assertTrue(DiskConfiguration.fromPb(DISK_CONFIGURATION.toPb())
instanceof StandardDiskConfiguration);
compareDefaultDiskConfiguration(DISK_CONFIGURATION,
compareStandardDiskConfiguration(DISK_CONFIGURATION,
DiskConfiguration.<StandardDiskConfiguration>fromPb(DISK_CONFIGURATION.toPb()));
}

Expand All @@ -89,10 +89,10 @@ public void testSetProjectId() {
StandardDiskConfiguration configuration = DISK_CONFIGURATION.toBuilder()
.diskType(DiskTypeId.of(DISK_TYPE.zone(), DISK_TYPE.diskType()))
.build();
compareDefaultDiskConfiguration(DISK_CONFIGURATION, configuration.setProjectId("project"));
compareStandardDiskConfiguration(DISK_CONFIGURATION, configuration.setProjectId("project"));
}

private void compareDefaultDiskConfiguration(StandardDiskConfiguration expected,
private void compareStandardDiskConfiguration(StandardDiskConfiguration expected,
StandardDiskConfiguration value) {
assertEquals(expected, value);
assertEquals(expected.diskType(), value.diskType());
Expand Down

0 comments on commit bf5d90b

Please sign in to comment.