@Override ImageDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder().setSourceImage(sourceImage.setProjectId(projectId)); if (getDiskType() != null) { builder.setDiskType(getDiskType().setProjectId(projectId)); } return builder.build(); }
@Test public void testToBuilderIncomplete() { ImageDiskConfiguration diskConfiguration = ImageDiskConfiguration.of(IMAGE); compareImageDiskConfiguration(diskConfiguration, diskConfiguration.toBuilder().build()); }
@Test public void testToBuilder() { compareImageDiskConfiguration(DISK_CONFIGURATION, DISK_CONFIGURATION.toBuilder().build()); ImageId newImageId = ImageId.of("newProject", "newImage"); ImageDiskConfiguration diskConfiguration = DISK_CONFIGURATION .toBuilder() .setSizeGb(24L) .setSourceImage(newImageId) .setSourceImageId("newImageId") .build(); assertEquals(24L, diskConfiguration.getSizeGb().longValue()); assertEquals(newImageId, diskConfiguration.getSourceImage()); assertEquals("newImageId", diskConfiguration.getSourceImageId()); diskConfiguration = diskConfiguration .toBuilder() .setSizeGb(SIZE) .setSourceImage(IMAGE) .setSourceImageId(IMAGE_ID) .build(); compareImageDiskConfiguration(DISK_CONFIGURATION, diskConfiguration); }
@Test public void testSetProjectId() { ImageDiskConfiguration diskConfiguration = DISK_CONFIGURATION .toBuilder() .setDiskType(DiskTypeId.of(DISK_TYPE.getZone(), DISK_TYPE.getType())) .setSourceImage(ImageId.of(IMAGE.getImage())) .build(); compareImageDiskConfiguration(DISK_CONFIGURATION, diskConfiguration.setProjectId("project")); }
ImageDiskConfiguration imageDiskConfiguration = IMAGE_DISK_CONFIGURATION .toBuilder() .setDiskType(DiskTypeId.of(TYPE.getZone(), TYPE.getType())) .setSourceImage(ImageId.of(IMAGE.getImage()))