|
19 | 19 |
|
20 | 20 | import com.google.api.gax.rpc.InvalidArgumentException;
|
21 | 21 | import com.google.api.gax.rpc.NotFoundException;
|
| 22 | +import com.google.cloud.compute.v1.Allowed; |
22 | 23 | import com.google.cloud.compute.v1.AttachedDisk;
|
23 | 24 | import com.google.cloud.compute.v1.AttachedDiskInitializeParams;
|
| 25 | +import com.google.cloud.compute.v1.Firewall; |
| 26 | +import com.google.cloud.compute.v1.FirewallsClient; |
24 | 27 | import com.google.cloud.compute.v1.GetInstanceRequest;
|
| 28 | +import com.google.cloud.compute.v1.Image; |
| 29 | +import com.google.cloud.compute.v1.ImagesClient; |
25 | 30 | import com.google.cloud.compute.v1.Instance;
|
26 | 31 | import com.google.cloud.compute.v1.InstanceGroupManager;
|
27 | 32 | import com.google.cloud.compute.v1.InstanceGroupManagersClient;
|
|
37 | 42 | import com.google.cloud.compute.v1.ZoneOperationsSettings;
|
38 | 43 | import java.io.IOException;
|
39 | 44 | import java.util.ArrayList;
|
| 45 | +import java.util.Collections; |
40 | 46 | import java.util.List;
|
41 | 47 | import java.util.Map;
|
42 | 48 | import org.junit.AfterClass;
|
@@ -237,6 +243,53 @@ public void testApiError() {
|
237 | 243 | }
|
238 | 244 | }
|
239 | 245 |
|
| 246 | + @Test |
| 247 | + public void testInt64() throws IOException { |
| 248 | + // we want to test a field with format:int64 |
| 249 | + String name = generateRandomName("image"); |
| 250 | + List<Long> licenseCodes = Collections.singletonList(5543610867827062957L); |
| 251 | + String sourceImage = "projects/debian-cloud/global/images/debian-10-buster-v20210721"; |
| 252 | + ImagesClient imagesClient = ImagesClient.create(); |
| 253 | + Image image = |
| 254 | + Image.newBuilder() |
| 255 | + .setName(name) |
| 256 | + .addAllLicenseCodes(licenseCodes) |
| 257 | + .setSourceImage(sourceImage) |
| 258 | + .build(); |
| 259 | + try { |
| 260 | + Operation op = imagesClient.insert(DEFAULT_PROJECT, image); |
| 261 | + waitGlobalOperation(op); |
| 262 | + |
| 263 | + Image fetched = imagesClient.get(DEFAULT_PROJECT, name); |
| 264 | + Assert.assertEquals(licenseCodes, fetched.getLicenseCodesList()); |
| 265 | + } finally { |
| 266 | + imagesClient.delete(DEFAULT_PROJECT, name); |
| 267 | + } |
| 268 | + } |
| 269 | + |
| 270 | + @Test |
| 271 | + public void testCapitalLetterField() throws IOException { |
| 272 | + // we want to test a field like "IPProtocol" |
| 273 | + String name = generateRandomName("fw-rule"); |
| 274 | + FirewallsClient firewallsClient = FirewallsClient.create(); |
| 275 | + Firewall firewall = |
| 276 | + Firewall.newBuilder() |
| 277 | + .setName(name) |
| 278 | + .addAllowed(Allowed.newBuilder().setIPProtocol("tcp").addPorts("80").build()) |
| 279 | + .addSourceRanges("0.0.0.0/0") |
| 280 | + .build(); |
| 281 | + try { |
| 282 | + Operation op = firewallsClient.insert(DEFAULT_PROJECT, firewall); |
| 283 | + waitGlobalOperation(op); |
| 284 | + |
| 285 | + Firewall fetched = firewallsClient.get(DEFAULT_PROJECT, name); |
| 286 | + Assert.assertEquals(name, fetched.getName()); |
| 287 | + Assert.assertEquals("tcp", fetched.getAllowed(0).getIPProtocol()); |
| 288 | + } finally { |
| 289 | + firewallsClient.delete(DEFAULT_PROJECT, name); |
| 290 | + } |
| 291 | + } |
| 292 | + |
240 | 293 | @Ignore("Patch is not supported")
|
241 | 294 | @Test
|
242 | 295 | public void testPatch() {
|
|
0 commit comments