本文整理了Java中com.google.cloud.compute.deprecated.Zone
类的一些代码示例,展示了Zone
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zone
类的具体详情如下:
包路径:com.google.cloud.compute.deprecated.Zone
类名称:Zone
[英]A Google Compute Engine zone.
[中]谷歌计算引擎专区。
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Zone apply(com.google.api.services.compute.model.Zone zone) {
return Zone.fromPb(zone);
}
});
代码示例来源:origin: googleapis/google-cloud-java
@Override
public com.google.api.services.compute.model.Zone apply(Zone region) {
return region.toPb();
}
};
代码示例来源:origin: googleapis/google-cloud-java
Zone build() {
return new Zone(this);
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZone() {
Zone zone = compute.getZone(ZONE);
assertEquals(ZONE, zone.getZoneId().getZone());
assertNotNull(zone.getGeneratedId());
assertNotNull(zone.getCreationTimestamp());
assertNotNull(zone.getDescription());
assertNotNull(zone.getStatus());
assertNotNull(zone.getRegion());
}
代码示例来源:origin: googleapis/google-cloud-java
private void compareZones(Zone expected, Zone value) {
assertEquals(expected, value);
assertEquals(expected.getZoneId(), value.getZoneId());
assertEquals(expected.getGeneratedId(), value.getGeneratedId());
assertEquals(expected.getCreationTimestamp(), value.getCreationTimestamp());
assertEquals(expected.getDescription(), value.getDescription());
assertEquals(expected.getStatus(), value.getStatus());
assertEquals(expected.getRegion(), value.getRegion());
assertEquals(expected.getDeprecationStatus(), value.getDeprecationStatus());
assertEquals(expected.hashCode(), value.hashCode());
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testToAndFromPb() {
com.google.api.services.compute.model.Zone zonePb = ZONE.toPb();
assertEquals(REGION_ID.getSelfLink(), zonePb.getRegion());
Zone zone = Zone.fromPb(zonePb);
compareZones(ZONE, zone);
assertEquals(ZONE_ID.getProject(), zone.getZoneId().getProject());
assertEquals(ZONE_ID.getZone(), zone.getZoneId().getZone());
zone = Zone.builder().setZoneId(ZONE_ID).build();
compareZones(zone, Zone.fromPb(zone.toPb()));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testBuilder() {
assertEquals(REGION_ID, ZONE.getRegion());
assertEquals(GENERATED_ID, ZONE.getGeneratedId());
assertEquals(CREATION_TIMESTAMP, ZONE.getCreationTimestamp());
assertEquals(DESCRIPTION, ZONE.getDescription());
assertEquals(STATUS, ZONE.getStatus());
assertEquals(REGION_ID, ZONE.getRegion());
assertEquals(DEPRECATION_STATUS, ZONE.getDeprecationStatus());
}
代码示例来源:origin: googleapis/google-cloud-java
static Zone fromPb(com.google.api.services.compute.model.Zone zonePb) {
Builder builder = builder();
builder.setZoneId(ZoneId.fromUrl(zonePb.getSelfLink()));
if (zonePb.getId() != null) {
builder.setGeneratedId(zonePb.getId().toString());
}
if (zonePb.getCreationTimestamp() != null) {
builder.setCreationTimestamp(TIMESTAMP_FORMATTER.parseMillis(zonePb.getCreationTimestamp()));
}
builder.setDescription(zonePb.getDescription());
if (zonePb.getStatus() != null) {
builder.setStatus(Status.valueOf(zonePb.getStatus()));
}
if (zonePb.getRegion() != null) {
builder.setRegion(RegionId.fromUrl(zonePb.getRegion()));
}
if (zonePb.getDeprecated() != null) {
builder.setDeprecationStatus(
DeprecationStatus.fromPb(zonePb.getDeprecated(), ZoneId.FROM_URL_FUNCTION));
}
return builder.build();
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZoneWithSelectedFields() {
Zone zone = compute.getZone(ZONE, Compute.ZoneOption.fields(Compute.ZoneField.ID));
assertEquals(ZONE, zone.getZoneId().getZone());
assertNotNull(zone.getGeneratedId());
assertNull(zone.getCreationTimestamp());
assertNull(zone.getDescription());
assertNull(zone.getStatus());
assertNull(zone.getRegion());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZones() {
Page<Zone> zonePage = compute.listZones();
Iterator<Zone> zoneIterator = zonePage.iterateAll().iterator();
while (zoneIterator.hasNext()) {
Zone zone = zoneIterator.next();
assertNotNull(zone.getZoneId());
assertNotNull(zone.getGeneratedId());
assertNotNull(zone.getCreationTimestamp());
assertNotNull(zone.getDescription());
assertNotNull(zone.getStatus());
assertNotNull(zone.getRegion());
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public final boolean equals(Object obj) {
return obj == this
|| obj != null
&& obj.getClass().equals(Zone.class)
&& Objects.equals(toPb(), ((Zone) obj).toPb());
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Zone apply(com.google.api.services.compute.model.Zone pb) {
return Zone.fromPb(pb);
}
};
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZonesWithSelectedFields() {
Page<Zone> zonePage =
compute.listZones(Compute.ZoneListOption.fields(Compute.ZoneField.CREATION_TIMESTAMP));
Iterator<Zone> zoneIterator = zonePage.iterateAll().iterator();
while (zoneIterator.hasNext()) {
Zone zone = zoneIterator.next();
assertNotNull(zone.getZoneId());
assertNull(zone.getGeneratedId());
assertNotNull(zone.getCreationTimestamp());
assertNull(zone.getDescription());
assertNull(zone.getStatus());
assertNull(zone.getRegion());
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZone() {
EasyMock.expect(computeRpcMock.getZone(ZONE_ID.getZone(), EMPTY_RPC_OPTIONS))
.andReturn(ZONE.toPb());
EasyMock.replay(computeRpcMock);
compute = options.getService();
Zone zone = compute.getZone(ZONE_ID.getZone());
assertEquals(ZONE, zone);
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Zone getZone(final String zone, ZoneOption... options) {
final Map<ComputeRpc.Option, ?> optionsMap = optionMap(options);
try {
com.google.api.services.compute.model.Zone answer =
runWithRetries(
new Callable<com.google.api.services.compute.model.Zone>() {
@Override
public com.google.api.services.compute.model.Zone call() {
return computeRpc.getZone(zone, optionsMap);
}
},
getOptions().getRetrySettings(),
EXCEPTION_HANDLER,
getOptions().getClock());
return answer == null ? null : Zone.fromPb(answer);
} catch (RetryHelper.RetryHelperException e) {
throw ComputeException.translateAndThrow(e);
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZoneWithSelectedFields() {
Capture<Map<ComputeRpc.Option, Object>> capturedOptions = Capture.newInstance();
EasyMock.expect(computeRpcMock.getZone(eq(ZONE_ID.getZone()), capture(capturedOptions)))
.andReturn(ZONE.toPb());
EasyMock.replay(computeRpcMock);
compute = options.getService();
Zone zone = compute.getZone(ZONE_ID.getZone(), ZONE_OPTION_FIELDS);
String selector = (String) capturedOptions.getValue().get(ZONE_OPTION_FIELDS.getRpcOption());
assertTrue(selector.contains("selfLink"));
assertTrue(selector.contains("id"));
assertTrue(selector.contains("description"));
assertEquals(23, selector.length());
assertEquals(ZONE, zone);
}
内容来源于网络,如有侵权,请联系作者删除!