本文整理了Java中com.google.cloud.compute.deprecated.ZoneOperationId.getZone()
方法的一些代码示例,展示了ZoneOperationId.getZone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOperationId.getZone()
方法的具体详情如下:
包路径:com.google.cloud.compute.deprecated.ZoneOperationId
类名称:ZoneOperationId
方法名:getZone
[英]Returns the name of the zone this operation belongs to.
[中]返回此操作所属区域的名称。
代码示例来源: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 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
@Override
public Boolean call() {
switch (operation.getType()) {
case REGION:
RegionOperationId regionOperationId = (RegionOperationId) operation;
return computeRpc.deleteRegionOperation(
regionOperationId.getRegion(), regionOperationId.getOperation());
case ZONE:
ZoneOperationId zoneOperationId = (ZoneOperationId) operation;
return computeRpc.deleteZoneOperation(
zoneOperationId.getZone(), zoneOperationId.getOperation());
case GLOBAL:
return computeRpc.deleteGlobalOperation(operation.getOperation());
default:
throw new IllegalArgumentException("Unexpected operation identity type");
}
}
},
代码示例来源: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 testDeleteZoneOperation_False() {
EasyMock.expect(
computeRpcMock.deleteZoneOperation(
ZONE_OPERATION_ID.getZone(), ZONE_OPERATION_ID.getOperation()))
.andReturn(false);
EasyMock.replay(computeRpcMock);
compute = options.getService();
assertFalse(compute.deleteOperation(ZONE_OPERATION_ID));
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public com.google.api.services.compute.model.Operation call() {
switch (operationId.getType()) {
case REGION:
RegionOperationId regionOperationId = (RegionOperationId) operationId;
return computeRpc.getRegionOperation(
regionOperationId.getRegion(),
regionOperationId.getOperation(),
optionsMap);
case ZONE:
ZoneOperationId zoneOperationId = (ZoneOperationId) operationId;
return computeRpc.getZoneOperation(
zoneOperationId.getZone(), zoneOperationId.getOperation(), optionsMap);
case GLOBAL:
return computeRpc.getGlobalOperation(operationId.getOperation(), optionsMap);
default:
throw new IllegalArgumentException("Unexpected operation identity type");
}
}
},
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZoneOperations() {
String cursor = "cursor";
compute = options.getService();
ImmutableList<Operation> operationList = ImmutableList.of(zoneOperation, zoneOperation);
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
EasyMock.expect(
computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), EMPTY_RPC_OPTIONS))
.andReturn(result);
EasyMock.replay(computeRpcMock);
Page<Operation> page = compute.listZoneOperations(ZONE_OPERATION_ID.getZone());
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(
operationList.toArray(), Iterables.toArray(page.getValues(), Operation.class));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZoneOperation() {
EasyMock.expect(
computeRpcMock.getZoneOperation(
ZONE_OPERATION_ID.getZone(), ZONE_OPERATION_ID.getOperation(), EMPTY_RPC_OPTIONS))
.andReturn(zoneOperation.toPb());
EasyMock.replay(computeRpcMock);
compute = options.getService();
Operation operation = compute.getOperation(ZONE_OPERATION_ID);
assertEquals(zoneOperation, operation);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZoneOperationsWithOptions() {
String cursor = "cursor";
compute = options.getService();
ImmutableList<Operation> operationList = ImmutableList.of(zoneOperation, zoneOperation);
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
EasyMock.expect(
computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), OPERATION_LIST_OPTIONS))
.andReturn(result);
EasyMock.replay(computeRpcMock);
Page<Operation> page =
compute.listZoneOperations(
ZONE_OPERATION_ID.getZone(),
OPERATION_LIST_PAGE_SIZE,
OPERATION_LIST_PAGE_TOKEN,
OPERATION_LIST_FILTER);
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(
operationList.toArray(), Iterables.toArray(page.getValues(), Operation.class));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZoneOperationsNextPage() {
String cursor = "cursor";
String nextCursor = "nextCursor";
compute = options.getService();
ImmutableList<Operation> operationList = ImmutableList.of(zoneOperation, zoneOperation);
ImmutableList<Operation> nextOperationList = ImmutableList.of(zoneOperation);
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> nextResult =
Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION));
Map<ComputeRpc.Option, ?> nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor);
EasyMock.expect(
computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), EMPTY_RPC_OPTIONS))
.andReturn(result);
EasyMock.expect(computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), nextOptions))
.andReturn(nextResult);
EasyMock.replay(computeRpcMock);
Page<Operation> page = compute.listZoneOperations(ZONE_OPERATION_ID.getZone());
assertEquals(cursor, page.getNextPageToken());
assertArrayEquals(
operationList.toArray(), Iterables.toArray(page.getValues(), Operation.class));
page = page.getNextPage();
assertEquals(nextCursor, page.getNextPageToken());
assertArrayEquals(
nextOperationList.toArray(), Iterables.toArray(page.getValues(), Operation.class));
}
代码示例来源: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
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 testListZoneOperations() {
Page<Operation> operationPage = compute.listZoneOperations(ZONE);
Iterator<Operation> operationIterator = operationPage.iterateAll().iterator();
while (operationIterator.hasNext()) {
Operation operation = operationIterator.next();
assertNotNull(operation.getGeneratedId());
assertNotNull(operation.getOperationId());
assertEquals(ZONE, operation.<ZoneOperationId>getOperationId().getZone());
// todo(mziccard): uncomment or remove once #727 is closed
// assertNotNull(operation.getCreationTimestamp());
assertNotNull(operation.getOperationType());
assertNotNull(operation.getStatus());
assertNotNull(operation.getUser());
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZoneOperationsWithFilter() {
Page<Operation> operationPage =
compute.listZoneOperations(
ZONE,
Compute.OperationListOption.filter(
Compute.OperationFilter.equals(Compute.OperationField.STATUS, "DONE")));
Iterator<Operation> operationIterator = operationPage.iterateAll().iterator();
while (operationIterator.hasNext()) {
Operation operation = operationIterator.next();
assertNotNull(operation.getGeneratedId());
assertNotNull(operation.getOperationId());
assertEquals(ZONE, operation.<ZoneOperationId>getOperationId().getZone());
// todo(mziccard): uncomment or remove once #727 is closed
// assertNotNull(operation.getCreationTimestamp());
assertNotNull(operation.getOperationType());
assertEquals(Operation.Status.DONE, operation.getStatus());
assertNotNull(operation.getUser());
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZoneOperationsWithSelectedFields() {
Page<Operation> operationPage =
compute.listZoneOperations(
ZONE, Compute.OperationListOption.fields(Compute.OperationField.ID));
Iterator<Operation> operationIterator = operationPage.iterateAll().iterator();
while (operationIterator.hasNext()) {
Operation operation = operationIterator.next();
assertNotNull(operation.getGeneratedId());
assertNotNull(operation.getOperationId());
assertEquals(ZONE, operation.<ZoneOperationId>getOperationId().getZone());
assertNull(operation.getOperationType());
assertNull(operation.getTargetLink());
assertNull(operation.getTargetId());
assertNull(operation.getOperationType());
assertNull(operation.getStatus());
assertNull(operation.getStatusMessage());
assertNull(operation.getUser());
assertNull(operation.getProgress());
assertNull(operation.getDescription());
assertNull(operation.getInsertTime());
assertNull(operation.getStartTime());
assertNull(operation.getEndTime());
assertNull(operation.getWarnings());
assertNull(operation.getHttpErrorMessage());
}
}
代码示例来源:origin: googleapis/google-cloud-java
assertEquals(OperationId.Type.ZONE, zoneOperationId.getType());
assertEquals(PROJECT, zoneOperationId.getProject());
assertEquals(ZONE, zoneOperationId.getZone());
assertEquals(NAME, zoneOperationId.getOperation());
assertEquals(ZONE_URL, zoneOperationId.getSelfLink());
assertEquals(OperationId.Type.ZONE, zoneOperationId.getType());
assertNull(zoneOperationId.getProject());
assertEquals(ZONE, zoneOperationId.getZone());
assertEquals(NAME, zoneOperationId.getOperation());
zoneOperationId = ZoneOperationId.of(ZoneId.of(PROJECT, ZONE), NAME);
assertEquals(OperationId.Type.ZONE, zoneOperationId.getType());
assertEquals(PROJECT, zoneOperationId.getProject());
assertEquals(ZONE, zoneOperationId.getZone());
assertEquals(NAME, zoneOperationId.getOperation());
RegionOperationId regionOperationId = RegionOperationId.of(PROJECT, REGION, NAME);
内容来源于网络,如有侵权,请联系作者删除!