本文整理了Java中com.google.cloud.compute.deprecated.ZoneOperationId.of()
方法的一些代码示例,展示了ZoneOperationId.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOperationId.of()
方法的具体详情如下:
包路径:com.google.cloud.compute.deprecated.ZoneOperationId
类名称:ZoneOperationId
方法名:of
[英]Returns a zone operation identity given the zone identity and the operation name.
[中]返回给定区域标识和操作名称的区域操作标识。
代码示例来源:origin: googleapis/google-cloud-java
@Override
ZoneOperationId parse(String... args) throws Exception {
String message;
if (args.length == 2) {
return ZoneOperationId.of(args[0], (args[1]));
} else if (args.length > 2) {
message = "Too many arguments.";
} else {
message = "Missing required zone and operation id.";
}
throw new IllegalArgumentException(message);
}
代码示例来源:origin: googleapis/google-cloud-java
static ZoneOperationId fromUrl(String url) {
Matcher matcher = PATTERN.matcher(url);
if (!matcher.matches()) {
throw new IllegalArgumentException(url + " is not a valid zone operation URL");
}
return ZoneOperationId.of(matcher.group(1), matcher.group(2), matcher.group(3));
}
}
代码示例来源: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 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 testDeleteOperation() {
initializeExpectedDisk(4);
expect(compute.getOptions()).andReturn(mockOptions);
Operation operation =
new Operation.Builder(serviceMockReturnsOptions)
.setOperationId(ZoneOperationId.of("project", "zone", "op"))
.build();
expect(compute.deleteDisk(DISK_ID)).andReturn(operation);
replay(compute);
initializeDisk();
assertSame(operation, disk.delete());
}
代码示例来源: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 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());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testStopOperation() {
initializeExpectedInstance(2);
expect(compute.getOptions()).andReturn(mockOptions);
Operation operation =
new Operation.Builder(serviceMockReturnsOptions)
.setOperationId(ZoneOperationId.of("project", "op"))
.build();
expect(compute.stop(INSTANCE_ID)).andReturn(operation);
replay(compute);
initializeInstance();
assertSame(operation, instance.stop());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testResizeOperation() {
initializeExpectedDisk(4);
expect(compute.getOptions()).andReturn(mockOptions);
Operation operation =
new Operation.Builder(serviceMockReturnsOptions)
.setOperationId(ZoneOperationId.of("project", "zone", "op"))
.build();
expect(compute.resize(DISK_ID, 42L)).andReturn(operation);
replay(compute);
initializeDisk();
assertSame(operation, disk.resize(42L));
}
代码示例来源: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 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 testDetachDiskWithOptions() 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", Compute.OperationOption.fields()))
.andReturn(operation);
replay(compute);
initializeInstance();
assertSame(operation, instance.detachDisk("dev0", Compute.OperationOption.fields()));
}
代码示例来源: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 testSetTagsWithOptions() throws Exception {
initializeExpectedInstance(2);
expect(compute.getOptions()).andReturn(mockOptions);
Operation operation =
new Operation.Builder(serviceMockReturnsOptions)
.setOperationId(ZoneOperationId.of("project", "op"))
.build();
Tags tags = Tags.newBuilder().setValues("v1", "v2").setFingerprint("fingerprint").build();
expect(compute.setTags(INSTANCE_ID, tags, Compute.OperationOption.fields()))
.andReturn(operation);
replay(compute);
initializeInstance();
assertSame(operation, instance.setTags(tags, Compute.OperationOption.fields()));
}
代码示例来源: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
@Test
public void testSetProjectId() {
GlobalOperationId operationId = GlobalOperationId.of(PROJECT, NAME);
assertSame(operationId, operationId.setProjectId(PROJECT));
compareOperationId(operationId, GlobalOperationId.of(NAME).setProjectId(PROJECT));
ZoneOperationId zoneOperationId = ZoneOperationId.of(PROJECT, ZONE, NAME);
assertSame(zoneOperationId, zoneOperationId.setProjectId(PROJECT));
compareZoneOperationId(zoneOperationId, ZoneOperationId.of(ZONE, NAME).setProjectId(PROJECT));
RegionOperationId regionOperationId = RegionOperationId.of(PROJECT, REGION, NAME);
assertSame(regionOperationId, regionOperationId.setProjectId(PROJECT));
compareRegionOperationId(
regionOperationId, RegionOperationId.of(REGION, NAME).setProjectId(PROJECT));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testMatchesUrl() {
assertTrue(GlobalOperationId.matchesUrl(GlobalOperationId.of(PROJECT, NAME).getSelfLink()));
assertFalse(GlobalOperationId.matchesUrl("notMatchingUrl"));
assertTrue(
RegionOperationId.matchesUrl(RegionOperationId.of(PROJECT, REGION, NAME).getSelfLink()));
assertFalse(RegionOperationId.matchesUrl("notMatchingUrl"));
assertTrue(ZoneOperationId.matchesUrl(ZoneOperationId.of(PROJECT, REGION, NAME).getSelfLink()));
assertFalse(ZoneOperationId.matchesUrl("notMatchingUrl"));
}
内容来源于网络,如有侵权,请联系作者删除!