com.google.cloud.compute.deprecated.ZoneOperationId类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中com.google.cloud.compute.deprecated.ZoneOperationId类的一些代码示例,展示了ZoneOperationId类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOperationId类的具体详情如下:
包路径:com.google.cloud.compute.deprecated.ZoneOperationId
类名称:ZoneOperationId

ZoneOperationId介绍

[英]Identity for a Google Compute Engine zone operation.
[中]谷歌计算引擎区域操作的标识。

代码示例

代码示例来源:origin: googleapis/google-cloud-java

@Override
ZoneOperationId setProjectId(String projectId) {
 if (getProject() != null) {
  return this;
 }
 return ZoneOperationId.of(projectId, zone, getOperation());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testToAndFromUrlZone() {
 ZoneOperationId zoneOperationId = ZoneOperationId.of(PROJECT, ZONE, NAME);
 compareZoneOperationId(zoneOperationId, ZoneOperationId.fromUrl(zoneOperationId.getSelfLink()));
 thrown.expect(IllegalArgumentException.class);
 thrown.expectMessage("notMatchingUrl is not a valid zone operation URL");
 ZoneOperationId.fromUrl("notMatchingUrl");
}

代码示例来源:origin: googleapis/google-cloud-java

private void compareZoneOperationId(ZoneOperationId expected, ZoneOperationId value) {
 assertEquals(expected, value);
 assertEquals(expected.getProject(), expected.getProject());
 assertEquals(expected.getZone(), expected.getZone());
 assertEquals(expected.getOperation(), expected.getOperation());
 assertEquals(expected.getSelfLink(), expected.getSelfLink());
 assertEquals(expected.hashCode(), expected.hashCode());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testAttachDisk() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 AttachedDisk.PersistentDiskConfiguration configuration =
   AttachedDisk.PersistentDiskConfiguration.of(DISK_ID);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.attachDisk(INSTANCE_ID, configuration)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.attachDisk(configuration));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSetMetadata() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 Metadata metadata = Metadata.newBuilder().add("k", "v").setFingerprint("fingerprint").build();
 expect(compute.setMetadata(INSTANCE_ID, metadata)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.setMetadata(metadata));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSetTagsFromList() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 List<String> tagList = ImmutableList.of("v1", "v2");
 Tags tags = Tags.newBuilder().setValues(tagList).setFingerprint("fingerprint").build();
 expect(compute.setTags(INSTANCE_ID, tags)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.setTags(tagList));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testCreateSnapshot() {
 initializeExpectedDisk(4);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "zone", "op"))
     .build();
 SnapshotId snapshotId = SnapshotId.of(SNAPSHOT.getSnapshot());
 SnapshotInfo snapshot = SnapshotInfo.newBuilder(snapshotId, DISK_ID).build();
 expect(compute.create(snapshot)).andReturn(operation);
 replay(compute);
 initializeDisk();
 assertSame(operation, disk.createSnapshot(SNAPSHOT.getSnapshot()));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testListEmptyZoneOperations() {
 ImmutableList<com.google.api.services.compute.model.Operation> operations = ImmutableList.of();
 Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
   Tuple.<String, Iterable<com.google.api.services.compute.model.Operation>>of(
     null, operations);
 EasyMock.expect(
     computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), EMPTY_RPC_OPTIONS))
   .andReturn(result);
 EasyMock.replay(computeRpcMock);
 compute = options.getService();
 Page<Operation> page = compute.listZoneOperations(ZONE_OPERATION_ID.getZone());
 assertNull(page.getNextPageToken());
 assertArrayEquals(operations.toArray(), Iterables.toArray(page.getValues(), Operation.class));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testDetachDisk() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.detachDisk(INSTANCE_ID, "dev0")).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.detachDisk("dev0"));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSetDiskAutodelete() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.setDiskAutoDelete(INSTANCE_ID, "dev0", true)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.setDiskAutoDelete("dev0", true));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testDeleteAccessConfig() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.deleteAccessConfig(INSTANCE_ID, "nic0", "NAT")).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.deleteAccessConfig("nic0", "NAT"));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSetMachineType() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.setMachineType(INSTANCE_ID, MACHINE_TYPE)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.setMachineType(MACHINE_TYPE));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testAddAccessConfig() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 NetworkInterface.AccessConfig accessConfig = NetworkInterface.AccessConfig.of("192.168.1.1");
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.addAccessConfig(INSTANCE_ID, "nic0", accessConfig)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.addAccessConfig("nic0", accessConfig));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSetSchedulingOptions() throws Exception {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 SchedulingOptions schedulingOptions =
   SchedulingOptions.standard(true, SchedulingOptions.Maintenance.MIGRATE);
 expect(compute.setSchedulingOptions(INSTANCE_ID, schedulingOptions)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.setSchedulingOptions(schedulingOptions));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testDeleteZoneOperation_True() {
 EasyMock.expect(
     computeRpcMock.deleteZoneOperation(
       ZONE_OPERATION_ID.getZone(), ZONE_OPERATION_ID.getOperation()))
   .andReturn(true);
 EasyMock.replay(computeRpcMock);
 compute = options.getService();
 assertTrue(compute.deleteOperation(ZONE_OPERATION_ID));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetZoneOperation_Null() {
 EasyMock.expect(
     computeRpcMock.getZoneOperation(
       ZONE_OPERATION_ID.getZone(), ZONE_OPERATION_ID.getOperation(), EMPTY_RPC_OPTIONS))
   .andReturn(null);
 EasyMock.replay(computeRpcMock);
 compute = options.getService();
 assertNull(compute.getOperation(ZONE_OPERATION_ID));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetZoneOperationWithSelectedFields() {
 Capture<Map<ComputeRpc.Option, Object>> capturedOptions = Capture.newInstance();
 EasyMock.expect(
     computeRpcMock.getZoneOperation(
       eq(ZONE_OPERATION_ID.getZone()),
       eq(ZONE_OPERATION_ID.getOperation()),
       capture(capturedOptions)))
   .andReturn(zoneOperation.toPb());
 EasyMock.replay(computeRpcMock);
 compute = options.getService();
 Operation operation = compute.getOperation(ZONE_OPERATION_ID, OPERATION_OPTION_FIELDS);
 String selector =
   (String) capturedOptions.getValue().get(OPERATION_OPTION_FIELDS.getRpcOption());
 assertTrue(selector.contains("selfLink"));
 assertTrue(selector.contains("id"));
 assertTrue(selector.contains("description"));
 assertEquals(23, selector.length());
 assertEquals(zoneOperation, operation);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testDeleteOperation() {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.deleteInstance(INSTANCE_ID)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.delete());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testStartOperation() {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.start(INSTANCE_ID)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.start());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testResetOperation() {
 initializeExpectedInstance(2);
 expect(compute.getOptions()).andReturn(mockOptions);
 Operation operation =
   new Operation.Builder(serviceMockReturnsOptions)
     .setOperationId(ZoneOperationId.of("project", "op"))
     .build();
 expect(compute.reset(INSTANCE_ID)).andReturn(operation);
 replay(compute);
 initializeInstance();
 assertSame(operation, instance.reset());
}

相关文章