@Test public void testToBuilder() { compareStandardDiskConfiguration(DISK_CONFIGURATION, DISK_CONFIGURATION.toBuilder().build()); StandardDiskConfiguration diskConfiguration = DISK_CONFIGURATION.toBuilder().setSizeGb(24L).build(); assertEquals(24L, diskConfiguration.getSizeGb().longValue()); diskConfiguration = diskConfiguration.toBuilder().setSizeGb(SIZE).build(); compareStandardDiskConfiguration(DISK_CONFIGURATION, diskConfiguration); }
.toBuilder() .setDiskType(DiskTypeId.of(TYPE.getZone(), TYPE.getType())) .build(); DiskInfo diskInfo = DISK_INFO
/** Returns a {@code StandardDiskConfiguration} object given the disk size in GB. */ public static StandardDiskConfiguration of(long sizeGb) { return newBuilder().setSizeGb(sizeGb).build(); }
/** Returns a {@code StandardDiskConfiguration} object given the disk type. */ public static StandardDiskConfiguration of(DiskTypeId diskType) { return newBuilder().setDiskType(diskType).build(); }
/** Returns a {@code StandardDiskConfiguration} object given the disk type and size in GB. */ public static StandardDiskConfiguration of(DiskTypeId diskType, long sizeGb) { return newBuilder().setDiskType(diskType).setSizeGb(sizeGb).build(); }
@Override StandardDiskConfiguration setProjectId(String projectId) { if (getDiskType() == null || getDiskType().getProject() != null) { return this; } return toBuilder().setDiskType(getDiskType().setProjectId(projectId)).build(); }
@Test public void testSetProjectId() { StandardDiskConfiguration configuration = DISK_CONFIGURATION .toBuilder() .setDiskType(DiskTypeId.of(DISK_TYPE.getZone(), DISK_TYPE.getType())) .build(); compareStandardDiskConfiguration(DISK_CONFIGURATION, configuration.setProjectId("project")); }
@SuppressWarnings("unchecked") static StandardDiskConfiguration fromPb(Disk diskPb) { return new Builder(diskPb).build(); } }
@Test public void testToBuilderIncomplete() { StandardDiskConfiguration diskConfiguration = StandardDiskConfiguration.of(DISK_TYPE); compareStandardDiskConfiguration(diskConfiguration, diskConfiguration.toBuilder().build()); }