From 8df138b0aba5dbfa0a5b8dc07a1dc6541b4d2bac Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 1 Apr 2016 19:29:28 +0200 Subject: [PATCH] Rename id to generatedId for Dns resources --- gcloud-java-dns/README.md | 6 +- .../com/google/gcloud/dns/ChangeRequest.java | 4 +- .../google/gcloud/dns/ChangeRequestInfo.java | 40 +++--- .../main/java/com/google/gcloud/dns/Zone.java | 4 +- .../java/com/google/gcloud/dns/ZoneInfo.java | 36 +++--- .../gcloud/dns/ChangeRequestInfoTest.java | 12 +- .../google/gcloud/dns/ChangeRequestTest.java | 6 +- .../com/google/gcloud/dns/DnsImplTest.java | 13 +- .../google/gcloud/dns/SerializationTest.java | 4 +- .../com/google/gcloud/dns/ZoneInfoTest.java | 18 +-- .../java/com/google/gcloud/dns/ZoneTest.java | 60 ++++----- .../com/google/gcloud/dns/it/ITDnsTest.java | 118 +++++++++--------- .../gcloud/examples/dns/DnsExample.java | 12 +- .../examples/dns/snippets/CreateZone.java | 2 +- .../examples/dns/snippets/DeleteZone.java | 2 +- .../ManipulateZonesAndRecordSets.java | 6 +- 16 files changed, 175 insertions(+), 168 deletions(-) diff --git a/gcloud-java-dns/README.md b/gcloud-java-dns/README.md index a01282f16c5d..703bcb190807 100644 --- a/gcloud-java-dns/README.md +++ b/gcloud-java-dns/README.md @@ -125,7 +125,7 @@ ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); // Create zone in Google Cloud DNS Zone zone = dns.create(zoneInfo); -System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); +System.out.printf("Zone was created and assigned ID %s.%n", zone.generatedId()); ``` You now have an empty zone hosted in Google Cloud DNS which is ready to be populated with @@ -226,7 +226,7 @@ while (ChangeRequestInfo.Status.PENDING.equals(changeRequest.status())) { } catch (InterruptedException e) { System.err.println("The thread was interrupted while waiting..."); } - changeRequest = dns.getChangeRequest(zone.name(), changeRequest.id()); + changeRequest = dns.getChangeRequest(zone.name(), changeRequest.generatedId()); } System.out.println("The change request has been applied."); ``` @@ -315,7 +315,7 @@ if (!changeRequest.deletions().isEmpty()) { } // Update the change, but fetch only change ID and status - changeRequest = dns.getChangeRequest(zoneName, changeRequest.id(), option); + changeRequest = dns.getChangeRequest(zoneName, changeRequest.generatedId(), option); } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index 4b6369976ca6..60b053faab6d 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -103,8 +103,8 @@ public Builder removeDeletion(RecordSet recordSet) { } @Override - Builder id(String id) { - infoBuilder.id(id); + Builder generatedId(String generatedId) { + infoBuilder.generatedId(generatedId); return this; } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java index b63b4f4a0788..4a92512996dd 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java @@ -47,10 +47,10 @@ public ChangeRequestInfo apply(Change pb) { return ChangeRequestInfo.fromPb(pb); } }; - private static final long serialVersionUID = -9027378042756366333L; + private static final long serialVersionUID = -6029143477639439169L; private final List additions; private final List deletions; - private final String id; + private final String generatedId; private final Long startTimeMillis; private final ChangeRequestInfo.Status status; @@ -119,9 +119,9 @@ public abstract static class Builder { public abstract Builder removeDeletion(RecordSet recordSet); /** - * Associates a server-assigned id to this {@code ChangeRequestInfo}. + * Associates a service-generated id to this {@code ChangeRequestInfo}. */ - abstract Builder id(String id); + abstract Builder generatedId(String generatedId); /** * Sets the time when this change request was started by a server. @@ -143,7 +143,7 @@ public abstract static class Builder { static class BuilderImpl extends Builder { private List additions; private List deletions; - private String id; + private String generatedId; private Long startTimeMillis; private ChangeRequestInfo.Status status; @@ -155,7 +155,7 @@ static class BuilderImpl extends Builder { BuilderImpl(ChangeRequestInfo info) { this.additions = Lists.newLinkedList(info.additions()); this.deletions = Lists.newLinkedList(info.deletions()); - this.id = info.id(); + this.generatedId = info.generatedId; this.startTimeMillis = info.startTimeMillis; this.status = info.status; } @@ -214,8 +214,8 @@ public ChangeRequestInfo build() { } @Override - Builder id(String id) { - this.id = checkNotNull(id); + Builder generatedId(String generatedId) { + this.generatedId = checkNotNull(generatedId); return this; } @@ -235,7 +235,7 @@ Builder status(ChangeRequestInfo.Status status) { ChangeRequestInfo(BuilderImpl builder) { this.additions = ImmutableList.copyOf(builder.additions); this.deletions = ImmutableList.copyOf(builder.deletions); - this.id = builder.id; + this.generatedId = builder.generatedId; this.startTimeMillis = builder.startTimeMillis; this.status = builder.status; } @@ -271,22 +271,22 @@ public List deletions() { } /** - * Returns the id assigned to this {@code ChangeRequest} by the server. + * Returns the service-generated id for this change request. */ - public String id() { - return id; + public String generatedId() { + return generatedId; } /** - * Returns the time when this {@code ChangeRequest} was started by the server. + * Returns the time when this change request was started by the server. */ public Long startTimeMillis() { return startTimeMillis; } /** - * Returns the status of this {@code ChangeRequest}. If the change request has not been applied - * yet, the status is {@code PENDING}. + * Returns the status of this change request. If the change request has not been applied yet, the + * status is {@code PENDING}. */ public ChangeRequestInfo.Status status() { return status; @@ -295,8 +295,8 @@ public ChangeRequestInfo.Status status() { Change toPb() { Change pb = new Change(); // set id - if (id() != null) { - pb.setId(id()); + if (generatedId() != null) { + pb.setId(generatedId()); } // set timestamp if (startTimeMillis() != null) { @@ -316,7 +316,7 @@ Change toPb() { static ChangeRequestInfo fromPb(Change pb) { Builder builder = builder(); if (pb.getId() != null) { - builder.id(pb.getId()); + builder.generatedId(pb.getId()); } if (pb.getStartTime() != null) { builder.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); @@ -342,7 +342,7 @@ public boolean equals(Object other) { @Override public int hashCode() { - return Objects.hash(additions, deletions, id, startTimeMillis, status); + return Objects.hash(additions, deletions, generatedId, startTimeMillis, status); } @Override @@ -350,7 +350,7 @@ public String toString() { return MoreObjects.toStringHelper(this) .add("additions", additions) .add("deletions", deletions) - .add("id", id) + .add("generatedId", generatedId) .add("startTimeMillis", startTimeMillis) .add("status", status) .toString(); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 9930bfdbad67..6e22bfc6785a 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -61,8 +61,8 @@ public Builder name(String name) { } @Override - Builder id(String id) { - infoBuilder.id(id); + Builder generatedId(String generatedId) { + infoBuilder.generatedId(generatedId); return this; } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index 38a88b67777e..a0ee24bc5948 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -38,9 +38,9 @@ */ public class ZoneInfo implements Serializable { - private static final long serialVersionUID = 201601191647L; + private static final long serialVersionUID = -5313169712036079818L; private final String name; - private final String id; + private final String generatedId; private final Long creationTimeMillis; private final String dnsName; private final String description; @@ -57,9 +57,9 @@ public abstract static class Builder { public abstract Builder name(String name); /** - * Sets an id for the zone which is assigned to the zone by the server. + * Sets service-generated id for the zone. */ - abstract Builder id(String id); + abstract Builder generatedId(String generatedId); /** * Sets the time when this zone was created. @@ -98,7 +98,7 @@ public abstract static class Builder { static class BuilderImpl extends Builder { private String name; - private String id; + private String generatedId; private Long creationTimeMillis; private String dnsName; private String description; @@ -114,7 +114,7 @@ private BuilderImpl(String name) { */ BuilderImpl(ZoneInfo info) { this.name = info.name; - this.id = info.id; + this.generatedId = info.generatedId; this.creationTimeMillis = info.creationTimeMillis; this.dnsName = info.dnsName; this.description = info.description; @@ -131,8 +131,8 @@ public Builder name(String name) { } @Override - Builder id(String id) { - this.id = id; + Builder generatedId(String generatedId) { + this.generatedId = generatedId; return this; } @@ -175,7 +175,7 @@ public ZoneInfo build() { ZoneInfo(BuilderImpl builder) { this.name = builder.name; - this.id = builder.id; + this.generatedId = builder.generatedId; this.creationTimeMillis = builder.creationTimeMillis; this.dnsName = builder.dnsName; this.description = builder.description; @@ -199,10 +199,10 @@ public String name() { } /** - * Returns the read-only zone id assigned by the server. + * Returns the service-generated id for this zone. */ - public String id() { - return id; + public String generatedId() { + return generatedId; } /** @@ -253,8 +253,8 @@ com.google.api.services.dns.model.ManagedZone toPb() { new com.google.api.services.dns.model.ManagedZone(); pb.setDescription(this.description()); pb.setDnsName(this.dnsName()); - if (this.id() != null) { - pb.setId(new BigInteger(this.id())); + if (this.generatedId() != null) { + pb.setId(new BigInteger(this.generatedId())); } pb.setName(this.name()); pb.setNameServers(this.nameServers); // do use real attribute value which may be null @@ -276,7 +276,7 @@ static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { builder.dnsName(pb.getDnsName()); } if (pb.getId() != null) { - builder.id(pb.getId().toString()); + builder.generatedId(pb.getId().toString()); } if (pb.getNameServers() != null) { builder.nameServers(pb.getNameServers()); @@ -298,15 +298,15 @@ public boolean equals(Object obj) { @Override public int hashCode() { - return Objects.hash(name, id, creationTimeMillis, dnsName, - description, nameServerSet, nameServers); + return Objects.hash(name, generatedId, creationTimeMillis, dnsName, description, nameServerSet, + nameServers); } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("name", name()) - .add("id", id()) + .add("generatedId", generatedId()) .add("description", description()) .add("dnsName", dnsName()) .add("nameServerSet", nameServerSet()) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java index 55f2af0824ec..f3ae7a586391 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java @@ -31,7 +31,7 @@ public class ChangeRequestInfoTest { - private static final String ID = "cr-id-1"; + private static final String GENERATED_ID = "cr-id-1"; private static final Long START_TIME_MILLIS = 12334567890L; private static final ChangeRequest.Status STATUS = ChangeRequest.Status.PENDING; private static final String NAME1 = "dns1"; @@ -51,7 +51,7 @@ public class ChangeRequestInfoTest { .delete(RECORD3) .startTimeMillis(START_TIME_MILLIS) .status(STATUS) - .id(ID) + .generatedId(GENERATED_ID) .build(); @Test @@ -65,7 +65,7 @@ public void testEmptyBuilder() { @Test public void testBuilder() { - assertEquals(ID, CHANGE.id()); + assertEquals(GENERATED_ID, CHANGE.generatedId()); assertEquals(STATUS, CHANGE.status()); assertEquals(START_TIME_MILLIS, CHANGE.startTimeMillis()); assertEquals(ADDITIONS, CHANGE.additions()); @@ -85,7 +85,7 @@ public void testEqualsAndNotEquals() { assertEquals(CHANGE, clone); clone = ChangeRequest.fromPb(CHANGE.toPb()); assertEquals(CHANGE, clone); - clone = CHANGE.toBuilder().id("some-other-id").build(); + clone = CHANGE.toBuilder().generatedId("some-other-id").build(); assertNotEquals(CHANGE, clone); clone = CHANGE.toBuilder().startTimeMillis(CHANGE.startTimeMillis() + 1).build(); assertNotEquals(CHANGE, clone); @@ -112,7 +112,7 @@ public void testToAndFromPb() { assertEquals(CHANGE, ChangeRequest.fromPb(CHANGE.toPb())); ChangeRequestInfo partial = ChangeRequest.builder().build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().id(ID).build(); + partial = ChangeRequest.builder().generatedId(GENERATED_ID).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); partial = ChangeRequest.builder().add(RECORD1).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); @@ -133,7 +133,7 @@ public void testToBuilder() { assertEquals(CHANGE, CHANGE.toBuilder().build()); ChangeRequestInfo partial = ChangeRequest.builder().build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().id(ID).build(); + partial = ChangeRequest.builder().generatedId(GENERATED_ID).build(); assertEquals(partial, partial.toBuilder().build()); partial = ChangeRequest.builder().add(RECORD1).build(); assertEquals(partial, partial.toBuilder().build()); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java index bfd1d0f512f4..4d4b2c01823c 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java @@ -53,7 +53,7 @@ public void setUp() throws Exception { changeRequest = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( CHANGE_REQUEST_INFO.toBuilder() .startTimeMillis(132L) - .id("12") + .generatedId("12") .status(ChangeRequest.Status.DONE) .build())); changeRequestPartial = new ChangeRequest(dns, ZONE_NAME, @@ -104,8 +104,8 @@ public void testBuilder() { // one for each build() call because it invokes a constructor expect(dns.options()).andReturn(OPTIONS).times(9); replay(dns); - String id = changeRequest.id() + "aaa"; - assertEquals(id, changeRequest.toBuilder().id(id).build().id()); + String id = changeRequest.generatedId() + "aaa"; + assertEquals(id, changeRequest.toBuilder().generatedId(id).build().generatedId()); ChangeRequest modified = changeRequest.toBuilder().status(ChangeRequest.Status.PENDING).build(); assertEquals(ChangeRequest.Status.PENDING, modified.status()); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index 94ed4a3da3f7..d9d657ee03e7 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -60,7 +60,7 @@ public class DnsImplTest { .add(DNS_RECORD1) .startTimeMillis(123L) .status(ChangeRequest.Status.PENDING) - .id(CHANGE_ID) + .generatedId(CHANGE_ID) .build(); // Result lists @@ -215,12 +215,13 @@ public void testProjectGetWithOptions() { @Test public void testGetChangeRequest() { - EasyMock.expect(dnsRpcMock.getChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_COMPLETE.id(), - EMPTY_RPC_OPTIONS)).andReturn(CHANGE_REQUEST_COMPLETE.toPb()); + EasyMock.expect(dnsRpcMock.getChangeRequest(ZONE_INFO.name(), + CHANGE_REQUEST_COMPLETE.generatedId(), EMPTY_RPC_OPTIONS)) + .andReturn(CHANGE_REQUEST_COMPLETE.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.name(), - CHANGE_REQUEST_COMPLETE.id()); + CHANGE_REQUEST_COMPLETE.generatedId()); assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); } @@ -229,12 +230,12 @@ public void testGetChangeRequest() { public void testGetChangeRequestWithOptions() { Capture> capturedOptions = Capture.newInstance(); EasyMock.expect(dnsRpcMock.getChangeRequest(EasyMock.eq(ZONE_INFO.name()), - EasyMock.eq(CHANGE_REQUEST_COMPLETE.id()), EasyMock.capture(capturedOptions))) + EasyMock.eq(CHANGE_REQUEST_COMPLETE.generatedId()), EasyMock.capture(capturedOptions))) .andReturn(CHANGE_REQUEST_COMPLETE.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.name(), - CHANGE_REQUEST_COMPLETE.id(), CHANGE_GET_FIELDS); + CHANGE_REQUEST_COMPLETE.generatedId(), CHANGE_GET_FIELDS); String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java index ad25b31068dd..7742d4c59a48 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -31,7 +31,7 @@ public class SerializationTest extends BaseSerializationTest { private static final ZoneInfo FULL_ZONE_INFO = Zone.of("some zone name", "www.example.com", "some descriptions").toBuilder() .creationTimeMillis(132L) - .id("123333") + .generatedId("123333") .nameServers(ImmutableList.of("server 1", "server 2")) .nameServerSet("specificationstring") .build(); @@ -78,7 +78,7 @@ public class SerializationTest extends BaseSerializationTest { .add(RECORD_SET_COMPLETE) .delete(RECORD_SET_PARTIAL) .status(ChangeRequest.Status.PENDING) - .id("some id") + .generatedId("some id") .startTimeMillis(132L) .build(); private static final ChangeRequest CHANGE_REQUEST_COMPLETE = new ChangeRequest(DNS, "name", diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java index 923672bb85a7..d0a64a61b816 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java @@ -32,7 +32,7 @@ public class ZoneInfoTest { private static final String NAME = "mz-example.com"; - private static final String ID = "123456"; + private static final String GENERATED_ID = "123456"; private static final Long CREATION_TIME_MILLIS = 1123468321321L; private static final String DNS_NAME = "example.com."; private static final String DESCRIPTION = "description for the zone"; @@ -43,7 +43,7 @@ public class ZoneInfoTest { private static final List NAME_SERVERS = ImmutableList.of(NS1, NS2, NS3); private static final ZoneInfo INFO = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() .creationTimeMillis(CREATION_TIME_MILLIS) - .id(ID) + .generatedId(GENERATED_ID) .nameServerSet(NAME_SERVER_SET) .nameServers(NAME_SERVERS) .build(); @@ -53,7 +53,7 @@ public void testOf() { ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertTrue(partial.nameServers().isEmpty()); assertEquals(NAME, partial.name()); - assertNull(partial.id()); + assertNull(partial.generatedId()); assertNull(partial.creationTimeMillis()); assertNull(partial.nameServerSet()); assertEquals(DESCRIPTION, partial.description()); @@ -67,7 +67,7 @@ public void testBuilder() { assertEquals(NS2, INFO.nameServers().get(1)); assertEquals(NS3, INFO.nameServers().get(2)); assertEquals(NAME, INFO.name()); - assertEquals(ID, INFO.id()); + assertEquals(GENERATED_ID, INFO.generatedId()); assertEquals(CREATION_TIME_MILLIS, INFO.creationTimeMillis()); assertEquals(NAME_SERVER_SET, INFO.nameServerSet()); assertEquals(DESCRIPTION, INFO.description()); @@ -91,7 +91,7 @@ public void testEqualsAndNotEquals() { assertNotEquals(INFO, clone); clone = INFO.toBuilder().dnsName(differentName).build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().id(INFO.id() + "1111").build(); + clone = INFO.toBuilder().generatedId(INFO.generatedId() + "1111").build(); assertNotEquals(INFO, clone); clone = INFO.toBuilder().nameServerSet(INFO.nameServerSet() + "salt").build(); assertNotEquals(INFO, clone); @@ -109,7 +109,9 @@ public void testToBuilder() { assertEquals(INFO, INFO.toBuilder().build()); ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().id(ID).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() + .generatedId(GENERATED_ID) + .build(); assertEquals(partial, partial.toBuilder().build()); partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() .creationTimeMillis(CREATION_TIME_MILLIS).build(); @@ -128,7 +130,9 @@ public void testToAndFromPb() { assertEquals(INFO, ZoneInfo.fromPb(INFO.toPb())); ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().id(ID).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() + .generatedId(GENERATED_ID) + .build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() .creationTimeMillis(CREATION_TIME_MILLIS).build(); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index ba4493abfca8..f14addfc44b6 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -45,7 +45,7 @@ public class ZoneTest { private static final String ZONE_ID = "123"; private static final ZoneInfo ZONE_INFO = Zone.of(ZONE_NAME, "example.com", "description") .toBuilder() - .id(ZONE_ID) + .generatedId(ZONE_ID) .creationTimeMillis(123478946464L) .build(); private static final ZoneInfo NO_ID_INFO = @@ -61,7 +61,7 @@ public class ZoneTest { private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTIONS = Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME); private static final ChangeRequestInfo CHANGE_REQUEST = - ChangeRequestInfo.builder().id("someid").build(); + ChangeRequestInfo.builder().generatedId("someid").build(); private static final ChangeRequestInfo CHANGE_REQUEST_NO_ID = ChangeRequestInfo.builder().build(); private static final DnsException EXCEPTION = createStrictMock(DnsException.class); @@ -287,51 +287,52 @@ public void applyNullChangeRequest() { @Test public void getChangeAndZoneFoundByName() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId())) .andReturn(changeRequestAfter).times(2); // again for options - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(changeRequestAfter).times(2); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId(), + CHANGE_REQUEST_FIELD_OPTIONS)).andReturn(changeRequestAfter).times(2); replay(dns); - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId()); assertEquals(changeRequestAfter, result); - result = zone.getChangeRequest(CHANGE_REQUEST.id()); + result = zone.getChangeRequest(CHANGE_REQUEST.generatedId()); assertEquals(changeRequestAfter, result); // check options - result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); + result = zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(changeRequestAfter, result); - result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); + result = zone.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(changeRequestAfter, result); } @Test public void getChangeAndZoneNotFoundByName() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andThrow(EXCEPTION).times(2); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId())).andThrow(EXCEPTION) + .times(2); // again for options - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andThrow(EXCEPTION).times(2); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId(), + CHANGE_REQUEST_FIELD_OPTIONS)).andThrow(EXCEPTION).times(2); replay(dns); try { - zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); + zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId()); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST.id()); + zone.getChangeRequest(CHANGE_REQUEST.generatedId()); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } // check options try { - zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); + zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); + zone.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected @@ -340,15 +341,16 @@ public void getChangeAndZoneNotFoundByName() { @Test public void getChangedWhichDoesNotExistZoneFound() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null).times(2); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId())).andReturn(null).times(2); // again for options - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null).times(2); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId(), + CHANGE_REQUEST_FIELD_OPTIONS)).andReturn(null).times(2); replay(dns); - assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.id())); - assertNull(zone.getChangeRequest(CHANGE_REQUEST.id())); - assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)); - assertNull(zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)); + assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId())); + assertNull(zone.getChangeRequest(CHANGE_REQUEST.generatedId())); + assertNull( + zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(),CHANGE_REQUEST_FIELD_OPTIONS)); + assertNull(zone.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS)); } @Test @@ -384,25 +386,25 @@ public void getNullChangeRequest() { public void getChangeRequestWithNoId() { replay(dns); // no calls expected try { - zone.getChangeRequest(CHANGE_REQUEST_NO_ID.id()); + zone.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId()); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST_NO_ID.id(), CHANGE_REQUEST_FIELD_OPTIONS); + zone.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.id()); + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId()); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.id(), CHANGE_REQUEST_FIELD_OPTIONS); + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected @@ -482,7 +484,7 @@ public void testBuilder() { expect(dns.options()).andReturn(OPTIONS).times(8); replay(dns); assertNotEquals(zone, zone.toBuilder() - .id((new BigInteger(zone.id())).add(BigInteger.ONE).toString()) + .generatedId(new BigInteger(zone.generatedId()).add(BigInteger.ONE).toString()) .build()); assertNotEquals(zone, zone.toBuilder().dnsName(zone.name() + "aaaa").build()); assertNotEquals(zone, zone.toBuilder().nameServerSet(zone.nameServerSet() + "aaaa").build()); @@ -491,7 +493,7 @@ public void testBuilder() { assertNotEquals(zone, zone.toBuilder().creationTimeMillis(zone.creationTimeMillis() + 1) .build()); Zone.Builder builder = zone.toBuilder(); - builder.id(ZONE_ID) + builder.generatedId(ZONE_ID) .dnsName("example.com") .creationTimeMillis(123478946464L) .build(); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index c9070f2eddde..aa6c78461b8b 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -97,7 +97,7 @@ private static void clear() { when the list has been retrieved and executing the subsequent delete operation. */ Iterator iterator = zone.listChangeRequests().iterateAll(); while (iterator.hasNext()) { - waitForChangeToComplete(zoneName, iterator.next().id()); + waitForChangeToComplete(zoneName, iterator.next().generatedId()); } Iterator recordSetIterator = zone.listRecordSets().iterateAll(); List toDelete = new LinkedList<>(); @@ -111,7 +111,7 @@ private static void clear() { if (!toDelete.isEmpty()) { ChangeRequest deletion = zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); - waitForChangeToComplete(zone.name(), deletion.id()); + waitForChangeToComplete(zone.name(), deletion.generatedId()); } zone.delete(); } @@ -142,7 +142,7 @@ public static void after() { private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRequest actual) { assertEquals(expected.additions(), actual.additions()); assertEquals(expected.deletions(), actual.deletions()); - assertEquals(expected.id(), actual.id()); + assertEquals(expected.generatedId(), actual.generatedId()); assertEquals(expected.startTimeMillis(), actual.startTimeMillis()); } @@ -174,7 +174,7 @@ public void testCreateValidZone() { assertNotNull(created.creationTimeMillis()); assertNotNull(created.nameServers()); assertNull(created.nameServerSet()); - assertNotNull(created.id()); + assertNotNull(created.generatedId()); Zone retrieved = DNS.getZone(ZONE1.name()); assertEquals(created, retrieved); created = DNS.create(ZONE_EMPTY_DESCRIPTION); @@ -184,7 +184,7 @@ public void testCreateValidZone() { assertNotNull(created.creationTimeMillis()); assertNotNull(created.nameServers()); assertNull(created.nameServerSet()); - assertNotNull(created.id()); + assertNotNull(created.generatedId()); retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.name()); assertEquals(created, retrieved); } finally { @@ -226,7 +226,7 @@ public void testCreateZoneWithOptions() { assertNull(created.dnsName()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); assertEquals(ZONE1.name(), created.name()); // always returned @@ -235,7 +235,7 @@ public void testCreateZoneWithOptions() { assertNull(created.dnsName()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); assertEquals(ZONE1.name(), created.name()); // always returned @@ -244,7 +244,7 @@ public void testCreateZoneWithOptions() { assertNull(created.description()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); assertEquals(ZONE1.name(), created.name()); // always returned @@ -253,7 +253,7 @@ public void testCreateZoneWithOptions() { assertNull(created.description()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); assertEquals(ZONE1.name(), created.name()); // always returned @@ -262,7 +262,7 @@ public void testCreateZoneWithOptions() { assertNull(created.description()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); // we did not set it - assertNull(created.id()); + assertNull(created.generatedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); assertEquals(ZONE1.name(), created.name()); // always returned @@ -271,7 +271,7 @@ public void testCreateZoneWithOptions() { assertNull(created.description()); assertFalse(created.nameServers().isEmpty()); assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); assertEquals(ZONE1.name(), created.name()); // always returned @@ -280,7 +280,7 @@ public void testCreateZoneWithOptions() { assertNull(created.description()); assertNotNull(created.nameServers()); assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.id()); + assertNotNull(created.generatedId()); created.delete(); // combination of multiple things created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, @@ -291,7 +291,7 @@ public void testCreateZoneWithOptions() { assertEquals(ZONE1.description(), created.description()); assertFalse(created.nameServers().isEmpty()); assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.id()); + assertNotNull(created.generatedId()); } finally { DNS.delete(ZONE1.name()); } @@ -308,7 +308,7 @@ public void testGetZone() { assertNull(created.dnsName()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); assertEquals(ZONE1.name(), created.name()); // always returned assertNull(created.creationTimeMillis()); @@ -316,7 +316,7 @@ public void testGetZone() { assertNull(created.dnsName()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); assertEquals(ZONE1.name(), created.name()); // always returned assertNull(created.creationTimeMillis()); @@ -324,7 +324,7 @@ public void testGetZone() { assertNull(created.description()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME)); assertEquals(ZONE1.name(), created.name()); // always returned assertNull(created.creationTimeMillis()); @@ -332,7 +332,7 @@ public void testGetZone() { assertNull(created.description()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); assertEquals(ZONE1.name(), created.name()); // always returned assertNull(created.creationTimeMillis()); @@ -340,7 +340,7 @@ public void testGetZone() { assertNull(created.description()); assertTrue(created.nameServers().isEmpty()); // never returns null assertNull(created.nameServerSet()); // we did not set it - assertNull(created.id()); + assertNull(created.generatedId()); created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); assertEquals(ZONE1.name(), created.name()); // always returned assertNull(created.creationTimeMillis()); @@ -348,7 +348,7 @@ public void testGetZone() { assertNull(created.description()); assertFalse(created.nameServers().isEmpty()); assertNull(created.nameServerSet()); - assertNull(created.id()); + assertNull(created.generatedId()); created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); assertEquals(ZONE1.name(), created.name()); // always returned assertNull(created.creationTimeMillis()); @@ -356,7 +356,7 @@ public void testGetZone() { assertNull(created.description()); assertNotNull(created.nameServers()); assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.id()); + assertNotNull(created.generatedId()); // combination of multiple things created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); @@ -366,7 +366,7 @@ public void testGetZone() { assertEquals(ZONE1.description(), created.description()); assertFalse(created.nameServers().isEmpty()); assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.id()); + assertNotNull(created.generatedId()); } finally { DNS.delete(ZONE1.name()); } @@ -428,7 +428,7 @@ public void testListZones() { assertNull(zone.description()); assertNull(zone.nameServerSet()); assertTrue(zone.nameServers().isEmpty()); - assertNotNull(zone.id()); + assertNotNull(zone.generatedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), Dns.ZoneListOption.fields(Dns.ZoneField.CREATION_TIME)).iterateAll(); @@ -439,7 +439,7 @@ public void testListZones() { assertNull(zone.description()); assertNull(zone.nameServerSet()); assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); + assertNull(zone.generatedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), Dns.ZoneListOption.fields(Dns.ZoneField.DNS_NAME)).iterateAll(); @@ -450,7 +450,7 @@ public void testListZones() { assertNull(zone.description()); assertNull(zone.nameServerSet()); assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); + assertNull(zone.generatedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)).iterateAll(); @@ -461,7 +461,7 @@ public void testListZones() { assertNotNull(zone.description()); assertNull(zone.nameServerSet()); assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); + assertNull(zone.generatedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVERS)).iterateAll(); @@ -472,7 +472,7 @@ public void testListZones() { assertNull(zone.description()); assertNull(zone.nameServerSet()); assertTrue(!zone.nameServers().isEmpty()); - assertNull(zone.id()); + assertNull(zone.generatedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVER_SET)).iterateAll(); @@ -483,7 +483,7 @@ public void testListZones() { assertNull(zone.description()); assertNull(zone.nameServerSet()); // we cannot set it using gcloud java assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); + assertNull(zone.generatedId()); assertFalse(zoneIterator.hasNext()); // several combined zones = filter(DNS.listZones(Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID, @@ -497,7 +497,7 @@ public void testListZones() { assertNotNull(current.description()); assertNull(current.nameServerSet()); assertTrue(zone.nameServers().isEmpty()); - assertNotNull(current.id()); + assertNotNull(current.generatedId()); } } finally { DNS.delete(ZONE1.name()); @@ -525,7 +525,7 @@ public void testCreateChange() { assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); assertNotNull(created.startTimeMillis()); assertTrue(created.deletions().isEmpty()); - assertEquals("1", created.id()); + assertEquals("1", created.generatedId()); assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) .contains(created.status())); assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); @@ -538,7 +538,7 @@ public void testCreateChange() { assertTrue(created.additions().isEmpty()); assertNull(created.startTimeMillis()); assertTrue(created.deletions().isEmpty()); - assertEquals("3", created.id()); + assertEquals("3", created.generatedId()); assertNull(created.status()); waitForChangeToComplete(ZONE1.name(), "3"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); @@ -548,7 +548,7 @@ public void testCreateChange() { assertTrue(created.additions().isEmpty()); assertNull(created.startTimeMillis()); assertTrue(created.deletions().isEmpty()); - assertEquals("5", created.id()); + assertEquals("5", created.generatedId()); assertNotNull(created.status()); waitForChangeToComplete(ZONE1.name(), "5"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); @@ -558,7 +558,7 @@ public void testCreateChange() { assertTrue(created.additions().isEmpty()); assertNotNull(created.startTimeMillis()); assertTrue(created.deletions().isEmpty()); - assertEquals("7", created.id()); + assertEquals("7", created.generatedId()); assertNull(created.status()); waitForChangeToComplete(ZONE1.name(), "7"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); @@ -568,7 +568,7 @@ public void testCreateChange() { assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); assertNull(created.startTimeMillis()); assertTrue(created.deletions().isEmpty()); - assertEquals("9", created.id()); + assertEquals("9", created.generatedId()); assertNull(created.status()); // finishes with delete otherwise we cannot delete the zone waitForChangeToComplete(ZONE1.name(), "9"); @@ -578,7 +578,7 @@ public void testCreateChange() { assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); assertNull(created.startTimeMillis()); assertTrue(created.additions().isEmpty()); - assertEquals("10", created.id()); + assertEquals("10", created.generatedId()); assertNull(created.status()); waitForChangeToComplete(ZONE1.name(), "10"); } finally { @@ -653,7 +653,7 @@ public void testInvalidChangeRequest() { if (recordAdded) { ChangeRequestInfo deletion = ChangeRequest.builder().delete(validA).build(); ChangeRequest request = zone.applyChangeRequest(deletion); - waitForChangeToComplete(zone.name(), request.id()); + waitForChangeToComplete(zone.name(), request.generatedId()); } zone.delete(); } @@ -678,13 +678,13 @@ public void testListChanges() { assertEquals(1, changes.size()); // default change creating SOA and NS // zone has changes ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); assertEquals(5, changes.size()); // error in options @@ -724,7 +724,7 @@ public void testListChanges() { change = changes.get(1); assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); + assertEquals("1", change.generatedId()); assertNull(change.startTimeMillis()); assertNull(change.status()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), @@ -733,7 +733,7 @@ public void testListChanges() { change = changes.get(2); assertTrue(change.additions().isEmpty()); assertNotNull(change.deletions()); - assertEquals("2", change.id()); + assertEquals("2", change.generatedId()); assertNull(change.startTimeMillis()); assertNull(change.status()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), @@ -742,7 +742,7 @@ public void testListChanges() { change = changes.get(1); assertTrue(change.additions().isEmpty()); assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); + assertEquals("1", change.generatedId()); assertNull(change.startTimeMillis()); assertNull(change.status()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), @@ -751,7 +751,7 @@ public void testListChanges() { change = changes.get(1); assertTrue(change.additions().isEmpty()); assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); + assertEquals("1", change.generatedId()); assertNotNull(change.startTimeMillis()); assertNull(change.status()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), @@ -760,7 +760,7 @@ public void testListChanges() { change = changes.get(1); assertTrue(change.additions().isEmpty()); assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); + assertEquals("1", change.generatedId()); assertNull(change.startTimeMillis()); assertEquals(ChangeRequest.Status.DONE, change.status()); } finally { @@ -773,45 +773,45 @@ public void testGetChange() { try { Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.id()); + ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.generatedId()); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.generatedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); // with options created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), + retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.generatedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), + retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.generatedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), + retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.generatedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), + retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.generatedId()); // finishes with delete otherwise we cannot delete the zone created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), + retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.generatedId()); } finally { clear(); } @@ -904,7 +904,7 @@ public void testListDnsRecords() { assertEquals(1, ImmutableList.copyOf(recordSetPage.values().iterator()).size()); // test name filter ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); recordSetIterator = DNS.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); counter = 0; @@ -916,7 +916,7 @@ public void testListDnsRecords() { } assertEquals(2, counter); // test type filter - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); recordSetIterator = DNS.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name()), Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())) @@ -956,7 +956,7 @@ public void testListDnsRecords() { assertEquals(400, ex.code()); assertFalse(ex.retryable()); } - waitForChangeToComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.generatedId()); } finally { clear(); } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java index a9e5c5d25377..e5f0cf01a6c9 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java @@ -90,7 +90,7 @@ public void run(Dns dns, String... args) { ZoneInfo zoneInfo = ZoneInfo.of(zoneName, dnsName, description); Zone zone = dns.create(zoneInfo); System.out.printf("Successfully created zone with name %s which was assigned ID %s.%n", - zone.name(), zone.id()); + zone.name(), zone.generatedId()); } @Override @@ -213,7 +213,7 @@ public void run(Dns dns, String... args) { .build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for deleting A record %s for zone %s was successfully " - + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.generatedId()); System.out.print("Waiting for deletion to happen..."); waitForChangeToFinish(dns, zoneName, changeRequest); System.out.printf("%nThe deletion has been completed.%n"); @@ -258,7 +258,7 @@ public void run(Dns dns, String... args) { ChangeRequestInfo changeRequest = ChangeRequest.builder().add(recordSet).build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for adding A record %s for zone %s was successfully " - + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.generatedId()); System.out.print("Waiting for addition to happen..."); waitForChangeToFinish(dns, zoneName, changeRequest); System.out.printf("The addition has been completed.%n"); @@ -334,7 +334,7 @@ public void run(Dns dns, String... args) { System.out.printf("Change requests for zone %s:%n", zoneName); while (iterator.hasNext()) { ChangeRequest change = iterator.next(); - System.out.printf("%nID: %s%n", change.id()); + System.out.printf("%nID: %s%n", change.generatedId()); System.out.printf("Status: %s%n", change.status()); System.out.printf("Started: %s%n", FORMATTER.format(change.startTimeMillis())); System.out.printf("Deletions: %s%n", Joiner.on(", ").join(change.deletions())); @@ -439,7 +439,7 @@ public boolean check(String... args) { private static void printZone(Zone zone) { System.out.printf("%nName: %s%n", zone.name()); - System.out.printf("ID: %s%n", zone.id()); + System.out.printf("ID: %s%n", zone.generatedId()); System.out.printf("Description: %s%n", zone.description()); System.out.printf("Created: %s%n", FORMATTER.format(new Date(zone.creationTimeMillis()))); System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); @@ -455,7 +455,7 @@ private static ChangeRequestInfo waitForChangeToFinish(Dns dns, String zoneName, } catch (InterruptedException e) { System.err.println("Thread was interrupted while waiting."); } - current = dns.getChangeRequest(zoneName, current.id()); + current = dns.getChangeRequest(zoneName, current.generatedId()); } return current; } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java index 2c2ba211bd86..dcf8019319c3 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java @@ -46,6 +46,6 @@ public static void main(String... args) { // Create zone in Google Cloud DNS Zone zone = dns.create(zoneInfo); - System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); + System.out.printf("Zone was created and assigned ID %s.%n", zone.generatedId()); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java index 63f26eeebb2a..aaf663920173 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java @@ -73,7 +73,7 @@ public static void main(String... args) { + "processed."); } // Update the change, but fetch only change ID and status - changeRequest = dns.getChangeRequest(zoneName, changeRequest.id(), option); + changeRequest = dns.getChangeRequest(zoneName, changeRequest.generatedId(), option); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java index 9c9a9e77289c..50f3a1a5c951 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java @@ -51,7 +51,7 @@ public static void main(String... args) { // Create zone in Google Cloud DNS Zone zone = dns.create(zoneInfo); - System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); + System.out.printf("Zone was created and assigned ID %s.%n", zone.generatedId()); // Print assigned name servers List nameServers = zone.nameServers(); @@ -89,7 +89,7 @@ public static void main(String... args) { } catch (InterruptedException e) { System.err.println("The thread was interrupted while waiting..."); } - changeRequest = dns.getChangeRequest(zone.name(), changeRequest.id()); + changeRequest = dns.getChangeRequest(zone.name(), changeRequest.generatedId()); } System.out.println("The change request has been applied."); @@ -143,7 +143,7 @@ public static void main(String... args) { } // Update the change, but fetch only change ID and status - changeRequest = dns.getChangeRequest(zoneName, changeRequest.id(), option); + changeRequest = dns.getChangeRequest(zoneName, changeRequest.generatedId(), option); } }