@Override ScratchDiskConfiguration setProjectId(String projectId) { if (diskType.getProject() != null) { return this; } return toBuilder().setDiskType(diskType.setProjectId(projectId)).build(); }
@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(); }
@Test public void testSetProjectId() { DiskTypeId diskTypeId = DiskTypeId.of(PROJECT, ZONE, DISK_TYPE); assertSame(diskTypeId, diskTypeId.setProjectId(PROJECT)); compareDiskTypeId(diskTypeId, DiskTypeId.of(ZONE, DISK_TYPE).setProjectId(PROJECT)); }
@Override ImageDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder().setSourceImage(sourceImage.setProjectId(projectId)); if (getDiskType() != null) { builder.setDiskType(getDiskType().setProjectId(projectId)); } return builder.build(); }
@Override StandardDiskConfiguration setProjectId(String projectId) { if (getDiskType() == null || getDiskType().getProject() != null) { return this; } return toBuilder().setDiskType(getDiskType().setProjectId(projectId)).build(); }
@Override SnapshotDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder().setSourceSnapshot(sourceSnapshot.setProjectId(projectId)); if (getDiskType() != null) { builder.setDiskType(getDiskType().setProjectId(projectId)); } return builder.build(); }
@Test public void testToAndFromUrl() { DiskTypeId diskTypeId = DiskTypeId.of(PROJECT, ZONE, DISK_TYPE); assertSame(diskTypeId, diskTypeId.setProjectId(PROJECT)); compareDiskTypeId(diskTypeId, DiskTypeId.fromUrl(diskTypeId.getSelfLink())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("notMatchingUrl is not a valid disk type URL"); DiskTypeId.fromUrl("notMatchingUrl"); }