|
29 | 29 | import com.google.cloud.compute.v1.DiskTypesScopedList; |
30 | 30 | import com.google.cloud.compute.v1.ListDiskTypesHttpRequest; |
31 | 31 | import com.google.cloud.compute.v1.ProjectName; |
| 32 | +import com.google.cloud.compute.v1.ProjectRegionDiskTypeName; |
32 | 33 | import com.google.cloud.compute.v1.ProjectZoneDiskTypeName; |
33 | 34 | import com.google.cloud.compute.v1.ProjectZoneName; |
34 | 35 | import com.google.common.collect.Lists; |
@@ -57,7 +58,8 @@ public class ITComputeTest { |
57 | 58 |
|
58 | 59 | @BeforeClass |
59 | 60 | public static void beforeClass() throws IOException{ |
60 | | - Credentials credentials = GoogleCredentials.getApplicationDefault(); |
| 61 | + Credentials credentials = GoogleCredentials.getApplicationDefault().createScoped( |
| 62 | + DiskTypeSettings.getDefaultServiceScopes()); |
61 | 63 |
|
62 | 64 | diskTypeSettings = |
63 | 65 | DiskTypeSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build(); |
@@ -131,10 +133,18 @@ public void testAggregatedListDiskTypes() { |
131 | 133 | } |
132 | 134 | assertThat(diskTypeIterator.size()).isGreaterThan(0); |
133 | 135 | for (DiskType diskType : diskTypeIterator) { |
134 | | - assertThat(diskType.getZone()).isNotNull(); |
135 | | - ProjectZoneDiskTypeName zoneName = ProjectZoneDiskTypeName.parse(trimUrl(diskType.getSelfLink())); |
136 | | - assertThat(zoneName.getDiskType()).isNotNull(); |
137 | | - assertThat(zoneName.getZone()).isNotNull(); |
| 136 | + assertThat(diskType.getRegion() != null || diskType.getZone() != null).isTrue(); |
| 137 | + if (diskType.getRegion() != null) { |
| 138 | + ProjectRegionDiskTypeName zoneName = ProjectRegionDiskTypeName |
| 139 | + .parse(trimUrl(diskType.getSelfLink())); |
| 140 | + assertThat(zoneName.getDiskType()).isNotNull(); |
| 141 | + assertThat(zoneName.getRegion()).isNotNull(); |
| 142 | + } else { |
| 143 | + ProjectZoneDiskTypeName zoneName = ProjectZoneDiskTypeName |
| 144 | + .parse(trimUrl(diskType.getSelfLink())); |
| 145 | + assertThat(zoneName.getDiskType()).isNotNull(); |
| 146 | + assertThat(zoneName.getZone()).isNotNull(); |
| 147 | + } |
138 | 148 | assertThat(diskType.getCreationTimestamp()).isNotNull(); |
139 | 149 | assertThat(diskType.getDescription()).isNotNull(); |
140 | 150 | assertThat(diskType.getValidDiskSize()).isNotNull(); |
|
0 commit comments