.toBuilder() .setDiskType(DiskTypeId.of("zone", "diskType")) .setSourceImage(ImageId.of("image")) .build(); compareAttachedDisk(
@Test public void testConfigurationSetProjectId() { PersistentDiskConfiguration persistentConfiguration = PersistentDiskConfiguration.of(DiskId.of("zone", "disk")); comparePersistentDiskConfiguration( PersistentDiskConfiguration.of(DiskId.of("project", "zone", "disk")), persistentConfiguration.setProjectId("project")); ScratchDiskConfiguration scratchDiskConfiguration = ScratchDiskConfiguration.of(DiskTypeId.of("zone", "diskType")); compareScratchDiskConfiguration( ScratchDiskConfiguration.of(DiskTypeId.of("project", "zone", "diskType")), scratchDiskConfiguration.setProjectId("project")); CreateDiskConfiguration createDiskConfiguration = CREATE_DISK_CONFIGURATION .toBuilder() .setDiskType(DiskTypeId.of("zone", "diskType")) .setSourceImage(ImageId.of("image")) .build(); compareCreateDiskConfiguration( CREATE_DISK_CONFIGURATION, createDiskConfiguration.setProjectId("project")); }
@Override CreateDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder(); if (builder.diskType != null) { builder.setDiskType(diskType.setProjectId(projectId)); } if (builder.sourceImage != null) { builder.setSourceImage(sourceImage.setProjectId(projectId)); } return builder.build(); }