diff --git a/README.md b/README.md index c2eea2a7da6a..a0cc37de00cf 100644 --- a/README.md +++ b/README.md @@ -359,19 +359,19 @@ Dns dns = DnsOptions.defaultInstance().service(); String zoneName = "my-unique-zone"; Zone zone = dns.getZone(zoneName); String ip = "12.13.14.15"; -RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A) - .ttl(24, TimeUnit.HOURS) +RecordSet toCreate = RecordSet.newBuilder("www.someexampledomain.com.", RecordSet.Type.A) + .setTtl(24, TimeUnit.HOURS) .addRecord(ip) .build(); -ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); +ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.newBuilder().add(toCreate); // Verify that the record does not exist yet. // If it does exist, we will overwrite it with our prepared record. Iterator recordSetIterator = zone.listRecordSets().iterateAll(); while (recordSetIterator.hasNext()) { RecordSet current = recordSetIterator.next(); - if (toCreate.name().equals(current.name()) && - toCreate.type().equals(current.type())) { + if (toCreate.name().equals(current.getName()) && + toCreate.type().equals(current.getType())) { changeBuilder.delete(current); } } diff --git a/TESTING.md b/TESTING.md index 830f2b72ca78..c1c0a25307e0 100644 --- a/TESTING.md +++ b/TESTING.md @@ -131,10 +131,11 @@ You can test against an in-memory local DNS by following these steps: The `delay` parameter determines if change requests should be processed synchronously (value `0`) or in a separate thread with a minimum of delay of `delay` milliseconds. -2. In your program, create the DNS service by using the helper's `options()` method. For example: +2. In your program, create the DNS service by using the helper's `getOptions()` method. +For example: ```java - Dns dns = LocalDnsHelper.options().service(); + Dns dns = LocalDnsHelper.getOptions().service(); ``` 3. Run your tests. diff --git a/google-cloud-dns/README.md b/google-cloud-dns/README.md index 2e6b8dba17d6..ebd986d74b31 100644 --- a/google-cloud-dns/README.md +++ b/google-cloud-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.generatedId()); +System.out.printf("Zone was created and assigned ID %s.%n", zone.getGeneratedId()); ``` You now have an empty zone hosted in Google Cloud DNS which is ready to be populated with @@ -142,7 +142,7 @@ and then add ```java // Print assigned name servers -List nameServers = zone.nameServers(); +List nameServers = zone.getNameServers(); for(String nameServer : nameServers) { System.out.println(nameServer); } @@ -170,13 +170,13 @@ and proceed with: ```java // Prepare a www.someexampledomain.com. type A record set with ttl of 24 hours String ip = "12.13.14.15"; -RecordSet toCreate = RecordSet.builder("www." + zone.dnsName(), RecordSet.Type.A) - .ttl(24, TimeUnit.HOURS) +RecordSet toCreate = RecordSet.newBuilder("www." + zone.dnsName(), RecordSet.Type.A) + .setTtl(24, TimeUnit.HOURS) .addRecord(ip) .build(); // Make a change -ChangeRequestInfo changeRequest = ChangeRequestInfo.builder().add(toCreate).build(); +ChangeRequestInfo changeRequest = ChangeRequestInfo.newBuilder().add(toCreate).build(); // Build and apply the change request to our zone changeRequest = zone.applyChangeRequest(changeRequest); @@ -205,7 +205,8 @@ ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCrea Iterator recordSetIterator = zone.listRecordSets().iterateAll(); while (recordSetIterator.hasNext()) { RecordSet current = recordSetIterator.next(); - if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { + if (toCreate.getName().equals(current.getName()) + && toCreate.getType().equals(current.getType())) { changeBuilder.delete(current); } } @@ -255,7 +256,7 @@ while (zoneIterator.hasNext()) { // List the record sets in a particular zone recordSetIterator = zone.listRecordSets().iterateAll(); -System.out.println(String.format("Record sets inside %s:", zone.name())); +System.out.println(String.format("Record sets inside %s:", zone.getName())); while (recordSetIterator.hasNext()) { System.out.println(recordSetIterator.next()); } @@ -274,7 +275,7 @@ and then: // List the change requests applied to a particular zone Iterator changeIterator = zone.listChangeRequests().iterateAll(); -System.out.println(String.format("The history of changes in %s:", zone.name())); +System.out.println(String.format("The history of changes in %s:", zone.getName())); while (changeIterator.hasNext()) { System.out.println(changeIterator.next()); } @@ -287,18 +288,19 @@ First, you need to empty the zone by deleting all its records except for the def ```java // Make a change for deleting the record sets -changeBuilder = ChangeRequestInfo.builder(); +changeBuilder = ChangeRequestInfo.newBuilder(); while (recordIterator.hasNext()) { RecordSet current = recordIterator.next(); // SOA and NS records cannot be deleted - if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) { + if (!RecordSet.Type.SOA.equals(current.getType()) + && !RecordSet.Type.NS.equals(current.getType())) { changeBuilder.delete(current); } } // Build and apply the change request to our zone if it contains records to delete ChangeRequestInfo changeRequest = changeBuilder.build(); -if (!changeRequest.deletions().isEmpty()) { +if (!changeRequest.getDeletions().isEmpty()) { ChangeRequest pendingRequest = dns.applyChangeRequest(zoneName, changeRequest); // Wait for the change request to complete @@ -325,7 +327,7 @@ if (result) { #### Complete Source Code We composed some of the aforementioned snippets into complete executable code samples. In -[CreateZones.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java) +[CreateZone.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java) we create a zone. In [CreateOrUpdateRecordSets.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateOrUpdateRecordSets.java) we create a type A record set for a zone, or update an existing type A record set to a new IP address. We demonstrate how to delete a zone in [DeleteZone.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/DeleteZone.java). diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequest.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequest.java index 267acf199b87..d7ed6ef02dd2 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequest.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequest.java @@ -55,14 +55,26 @@ private Builder(ChangeRequest cr) { } @Override + @Deprecated public Builder additions(List additions) { - infoBuilder.additions(additions); + return setAdditions(additions); + } + + @Override + public Builder setAdditions(List additions) { + infoBuilder.setAdditions(additions); return this; } @Override + @Deprecated public Builder deletions(List deletions) { - infoBuilder.deletions(deletions); + return setDeletions(deletions); + } + + @Override + public Builder setDeletions(List deletions) { + infoBuilder.setDeletions(deletions); return this; } @@ -103,20 +115,20 @@ public Builder removeDeletion(RecordSet recordSet) { } @Override - Builder generatedId(String generatedId) { - infoBuilder.generatedId(generatedId); + Builder setGeneratedId(String generatedId) { + infoBuilder.setGeneratedId(generatedId); return this; } @Override - Builder startTimeMillis(long startTimeMillis) { - infoBuilder.startTimeMillis(startTimeMillis); + Builder setStartTime(long startTimeMillis) { + infoBuilder.setStartTime(startTimeMillis); return this; } @Override - Builder status(Status status) { - infoBuilder.status(status); + Builder setStatus(Status status) { + infoBuilder.setStatus(status); return this; } @@ -137,6 +149,13 @@ public ChangeRequest build() { * Returns the name of the {@link Zone} associated with this change request. */ public String zone() { + return getZone(); + } + + /** + * Returns the name of the {@link Zone} associated with this change request. + */ + public String getZone() { return this.zone; } @@ -144,6 +163,13 @@ public String zone() { * Returns the change request's {@code Dns} object used to issue requests. */ public Dns dns() { + return getDns(); + } + + /** + * Returns the change request's {@code Dns} object used to issue requests. + */ + public Dns getDns() { return dns; } @@ -168,7 +194,7 @@ public ChangeRequest applyTo(String zoneName, Dns.ChangeRequestOption... options * @throws DnsException upon failure of the API call or if the associated zone was not found */ public ChangeRequest reload(Dns.ChangeRequestOption... options) { - return dns.getChangeRequest(zone, generatedId(), options); + return dns.getChangeRequest(zone, getGeneratedId(), options); } /** diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequestInfo.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequestInfo.java index 8ed68765a163..78a529c1e8e6 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequestInfo.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/ChangeRequestInfo.java @@ -74,14 +74,28 @@ public abstract static class Builder { * Sets a collection of {@link RecordSet}s which are to be added to the zone upon executing this * {@code ChangeRequestInfo}. */ + @Deprecated public abstract Builder additions(List additions); + /** + * Sets a collection of {@link RecordSet}s which are to be added to the zone upon executing this + * {@code ChangeRequestInfo}. + */ + public abstract Builder setAdditions(List additions); + /** * Sets a collection of {@link RecordSet}s which are to be deleted from the zone upon executing * this {@code ChangeRequestInfo}. */ + @Deprecated public abstract Builder deletions(List deletions); + /** + * Sets a collection of {@link RecordSet}s which are to be deleted from the zone upon executing + * this {@code ChangeRequestInfo}. + */ + public abstract Builder setDeletions(List deletions); + /** * Adds a {@link RecordSet} to be added to the zone upon executing this {@code * ChangeRequestInfo}. @@ -121,17 +135,17 @@ public abstract static class Builder { /** * Associates a service-generated id to this {@code ChangeRequestInfo}. */ - abstract Builder generatedId(String generatedId); + abstract Builder setGeneratedId(String generatedId); /** * Sets the time when this change request was started by a server. */ - abstract Builder startTimeMillis(long startTimeMillis); + abstract Builder setStartTime(long startTimeMillis); /** * Sets the current status of this {@code ChangeRequest}. */ - abstract Builder status(ChangeRequest.Status status); + abstract Builder setStatus(ChangeRequest.Status status); /** * Creates a {@code ChangeRequestInfo} instance populated by the values associated with this @@ -153,21 +167,33 @@ static class BuilderImpl extends Builder { } BuilderImpl(ChangeRequestInfo info) { - this.additions = Lists.newLinkedList(info.additions()); - this.deletions = Lists.newLinkedList(info.deletions()); + this.additions = Lists.newLinkedList(info.getAdditions()); + this.deletions = Lists.newLinkedList(info.getDeletions()); this.generatedId = info.generatedId; this.startTimeMillis = info.startTimeMillis; this.status = info.status; } @Override + @Deprecated public Builder additions(List additions) { + return setAdditions(additions); + } + + @Override + public Builder setAdditions(List additions) { this.additions = Lists.newLinkedList(checkNotNull(additions)); return this; } @Override + @Deprecated public Builder deletions(List deletions) { + return setDeletions(deletions); + } + + @Override + public Builder setDeletions(List deletions) { this.deletions = Lists.newLinkedList(checkNotNull(deletions)); return this; } @@ -214,19 +240,19 @@ public ChangeRequestInfo build() { } @Override - Builder generatedId(String generatedId) { + Builder setGeneratedId(String generatedId) { this.generatedId = checkNotNull(generatedId); return this; } @Override - Builder startTimeMillis(long startTimeMillis) { + Builder setStartTime(long startTimeMillis) { this.startTimeMillis = startTimeMillis; return this; } @Override - Builder status(ChangeRequestInfo.Status status) { + Builder setStatus(ChangeRequestInfo.Status status) { this.status = checkNotNull(status); return this; } @@ -243,7 +269,15 @@ Builder status(ChangeRequestInfo.Status status) { /** * Returns an empty builder for the {@code ChangeRequestInfo} class. */ + @Deprecated public static Builder builder() { + return newBuilder(); + } + + /** + * Returns an empty builder for the {@code ChangeRequestInfo} class. + */ + public static Builder newBuilder() { return new BuilderImpl(); } @@ -258,7 +292,16 @@ public Builder toBuilder() { * Returns the list of {@link RecordSet}s to be added to the zone upon submitting this change * request. */ + @Deprecated public List additions() { + return getAdditions(); + } + + /** + * Returns the list of {@link RecordSet}s to be added to the zone upon submitting this change + * request. + */ + public List getAdditions() { return additions; } @@ -266,21 +309,46 @@ public List additions() { * Returns the list of {@link RecordSet}s to be deleted from the zone upon submitting this change * request. */ + @Deprecated public List deletions() { + return getDeletions(); + } + + /** + * Returns the list of {@link RecordSet}s to be deleted from the zone upon submitting this change + * request. + */ + public List getDeletions() { return deletions; } /** * Returns the service-generated id for this change request. */ + @Deprecated public String generatedId() { + return getGeneratedId(); + } + + /** + * Returns the service-generated id for this change request. + */ + public String getGeneratedId() { return generatedId; } /** * Returns the time when this change request was started by the server. */ + @Deprecated public Long startTimeMillis() { + return getStartTimeMillis(); + } + + /** + * Returns the time when this change request was started by the server. + */ + public Long getStartTimeMillis() { return startTimeMillis; } @@ -289,47 +357,55 @@ public Long startTimeMillis() { * status is {@code PENDING}. */ public ChangeRequestInfo.Status status() { + return getStatus(); + } + + /** + * Returns the status of this change request. If the change request has not been applied yet, the + * status is {@code PENDING}. + */ + public ChangeRequestInfo.Status getStatus() { return status; } Change toPb() { Change pb = new Change(); // set id - if (generatedId() != null) { - pb.setId(generatedId()); + if (getGeneratedId() != null) { + pb.setId(getGeneratedId()); } // set timestamp - if (startTimeMillis() != null) { - pb.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC().print(startTimeMillis())); + if (getStartTimeMillis() != null) { + pb.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC().print(getStartTimeMillis())); } // set status if (status() != null) { pb.setStatus(status().name().toLowerCase()); } // set a list of additions - pb.setAdditions(Lists.transform(additions(), RecordSet.TO_PB_FUNCTION)); + pb.setAdditions(Lists.transform(getAdditions(), RecordSet.TO_PB_FUNCTION)); // set a list of deletions - pb.setDeletions(Lists.transform(deletions(), RecordSet.TO_PB_FUNCTION)); + pb.setDeletions(Lists.transform(getDeletions(), RecordSet.TO_PB_FUNCTION)); return pb; } static ChangeRequestInfo fromPb(Change pb) { - Builder builder = builder(); + Builder builder = newBuilder(); if (pb.getId() != null) { - builder.generatedId(pb.getId()); + builder.setGeneratedId(pb.getId()); } if (pb.getStartTime() != null) { - builder.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); + builder.setStartTime(DateTime.parse(pb.getStartTime()).getMillis()); } if (pb.getStatus() != null) { // we are assuming that status indicated in pb is a lower case version of the enum name - builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); + builder.setStatus(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); } if (pb.getDeletions() != null) { - builder.deletions(Lists.transform(pb.getDeletions(), RecordSet.FROM_PB_FUNCTION)); + builder.setDeletions(Lists.transform(pb.getDeletions(), RecordSet.FROM_PB_FUNCTION)); } if (pb.getAdditions() != null) { - builder.additions(Lists.transform(pb.getAdditions(), RecordSet.FROM_PB_FUNCTION)); + builder.setAdditions(Lists.transform(pb.getAdditions(), RecordSet.FROM_PB_FUNCTION)); } return builder.build(); } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsBatch.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsBatch.java index 8037b6b28ce2..b1fa7165aeaa 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsBatch.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsBatch.java @@ -53,17 +53,17 @@ public class DnsBatch { } @VisibleForTesting - Object batch() { + Object getBatch() { return batch; } @VisibleForTesting - DnsRpc dnsRpc() { + DnsRpc getDnsRpc() { return dnsRpc; } @VisibleForTesting - DnsOptions options() { + DnsOptions getOptions() { return options; } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsImpl.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsImpl.java index 1bf2a0c1d8cb..abcacf0521e6 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsImpl.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/DnsImpl.java @@ -315,7 +315,7 @@ public DnsBatch batch() { static Map optionMap(Option... options) { Map temp = Maps.newEnumMap(DnsRpc.Option.class); for (Option option : options) { - Object prev = temp.put(option.rpcOption(), option.value()); + Object prev = temp.put(option.getRpcOption(), option.getValue()); checkArgument(prev == null, "Duplicate option %s", option); } return ImmutableMap.copyOf(temp); diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/Option.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/Option.java index 7a1f9955be05..a2429c3578f6 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/Option.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/Option.java @@ -38,11 +38,11 @@ abstract class Option implements Serializable { this.value = value; } - Object value() { + Object getValue() { return value; } - DnsRpc.Option rpcOption() { + DnsRpc.Option getRpcOption() { return rpcOption; } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/ProjectInfo.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/ProjectInfo.java index bc35bacc317d..cf49fada0b77 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/ProjectInfo.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/ProjectInfo.java @@ -79,14 +79,30 @@ public static class Quota implements Serializable { /** * Returns the maximum allowed number of zones in the project. */ + @Deprecated public int zones() { + return getZones(); + } + + /** + * Returns the maximum allowed number of zones in the project. + */ + public int getZones() { return zones; } /** * Returns the maximum allowed number of records per {@link RecordSet}. */ + @Deprecated public int resourceRecordsPerRrset() { + return getResourceRecordsPerRrset(); + } + + /** + * Returns the maximum allowed number of records per {@link RecordSet}. + */ + public int getResourceRecordsPerRrset() { return resourceRecordsPerRrset; } @@ -94,7 +110,16 @@ public int resourceRecordsPerRrset() { * Returns the maximum allowed number of {@link RecordSet}s to add per {@link * ChangeRequest}. */ + @Deprecated public int rrsetAdditionsPerChange() { + return getRrsetAdditionsPerChange(); + } + + /** + * Returns the maximum allowed number of {@link RecordSet}s to add per {@link + * ChangeRequest}. + */ + public int getRrsetAdditionsPerChange() { return rrsetAdditionsPerChange; } @@ -102,7 +127,16 @@ public int rrsetAdditionsPerChange() { * Returns the maximum allowed number of {@link RecordSet}s to delete per {@link * ChangeRequest}. */ + @Deprecated public int rrsetDeletionsPerChange() { + return getRrsetDeletionsPerChange(); + } + + /** + * Returns the maximum allowed number of {@link RecordSet}s to delete per {@link + * ChangeRequest}. + */ + public int getRrsetDeletionsPerChange() { return rrsetDeletionsPerChange; } @@ -110,14 +144,31 @@ public int rrsetDeletionsPerChange() { * Returns the maximum allowed number of {@link RecordSet}s per {@link ZoneInfo} in the * project. */ + @Deprecated public int rrsetsPerZone() { + return getRrsetsPerZone(); + } + + /** + * Returns the maximum allowed number of {@link RecordSet}s per {@link ZoneInfo} in the + * project. + */ + public int getRrsetsPerZone() { return rrsetsPerZone; } /** * Returns the maximum allowed size for total records in one ChangesRequest in bytes. */ + @Deprecated public int totalRrdataSizePerChange() { + return getTotalRrdataSizePerChange(); + } + + /** + * Returns the maximum allowed size for total records in one ChangesRequest in bytes. + */ + public int getTotalRrdataSizePerChange() { return totalRrdataSizePerChange; } @@ -180,7 +231,7 @@ private Builder() { /** * Sets an id of the project. */ - Builder id(String id) { + Builder setId(String id) { this.id = checkNotNull(id); return this; } @@ -188,7 +239,7 @@ Builder id(String id) { /** * Sets a number of the project. */ - Builder number(BigInteger number) { + Builder setNumber(BigInteger number) { this.number = checkNotNull(number); return this; } @@ -196,7 +247,7 @@ Builder number(BigInteger number) { /** * Sets quotas assigned to the project. */ - Builder quota(Quota quota) { + Builder setQuota(Quota quota) { this.quota = checkNotNull(quota); return this; } @@ -218,28 +269,44 @@ private ProjectInfo(Builder builder) { /** * Returns a builder for {@code ProjectInfo}. */ - static Builder builder() { + static Builder newBuilder() { return new Builder(); } /** * Returns the {@code Quota} object which contains quotas assigned to this project. */ + @Deprecated public Quota quota() { + return getQuota(); + } + + /** + * Returns the {@code Quota} object which contains quotas assigned to this project. + */ + public Quota getQuota() { return quota; } /** * Returns project number. For internal use only. */ - BigInteger number() { + BigInteger getNumber() { return number; } /** * Returns project id. For internal use only. */ + @Deprecated String id() { + return getId(); + } + + /** + * Returns project id. For internal use only. + */ + String getId() { return id; } @@ -254,15 +321,15 @@ Project toPb() { } static ProjectInfo fromPb(Project pb) { - Builder builder = builder(); + Builder builder = newBuilder(); if (pb.getId() != null) { - builder.id(pb.getId()); + builder.setId(pb.getId()); } if (pb.getNumber() != null) { - builder.number(pb.getNumber()); + builder.setNumber(pb.getNumber()); } if (pb.getQuota() != null) { - builder.quota(Quota.fromPb(pb.getQuota())); + builder.setQuota(Quota.fromPb(pb.getQuota())); } return builder.build(); } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/RecordSet.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/RecordSet.java index e9d2e1b2527e..5e6a47028ede 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/RecordSet.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/RecordSet.java @@ -180,7 +180,15 @@ public Builder clearRecords() { /** * Replaces the current records with the provided list of records. */ + @Deprecated public Builder records(List records) { + return setRecords(records); + } + + /** + * Replaces the current records with the provided list of records. + */ + public Builder setRecords(List records) { this.rrdatas = Lists.newLinkedList(checkNotNull(records)); return this; } @@ -188,7 +196,15 @@ public Builder records(List records) { /** * Sets the name for this record set. For example, www.example.com. */ + @Deprecated public Builder name(String name) { + return setName(name); + } + + /** + * Sets the name for this record set. For example, www.example.com. + */ + public Builder setName(String name) { this.name = checkNotNull(name); return this; } @@ -200,7 +216,19 @@ public Builder name(String name) { * @param duration A non-negative number of time units * @param unit The unit of the ttl parameter */ + @Deprecated public Builder ttl(int duration, TimeUnit unit) { + return setTtl(duration, unit); + } + + /** + * Sets the time that this record can be cached by resolvers. This number must be non-negative. + * The maximum duration must be equivalent to at most {@link Integer#MAX_VALUE} seconds. + * + * @param duration A non-negative number of time units + * @param unit The unit of the ttl parameter + */ + public Builder setTtl(int duration, TimeUnit unit) { checkArgument(duration >= 0, "Duration cannot be negative. The supplied value was %s.", duration); checkNotNull(unit); @@ -213,7 +241,15 @@ public Builder ttl(int duration, TimeUnit unit) { /** * The identifier of a supported record type, for example, A, AAAA, MX, TXT, and so on. */ + @Deprecated public Builder type(Type type) { + return setType(type); + } + + /** + * The identifier of a supported record type, for example, A, AAAA, MX, TXT, and so on. + */ + public Builder setType(Type type) { this.type = checkNotNull(type); return this; } @@ -243,35 +279,75 @@ public Builder toBuilder() { /** * Creates a {@code RecordSet} builder for the given {@code name} and {@code type}. */ + @Deprecated public static Builder builder(String name, Type type) { + return newBuilder(name, type); + } + + /** + * Creates a {@code RecordSet} builder for the given {@code name} and {@code type}. + */ + public static Builder newBuilder(String name, Type type) { return new Builder(name, type); } /** * Returns the user-assigned name of this record set. */ + @Deprecated public String name() { + return getName(); + } + + /** + * Returns the user-assigned name of this record set. + */ + public String getName() { return name; } /** * Returns a list of records stored in this record set. */ + @Deprecated public List records() { + return getRecords(); + } + + /** + * Returns a list of records stored in this record set. + */ + public List getRecords() { return rrdatas; } /** * Returns the number of seconds that this record set can be cached by resolvers. */ + @Deprecated public Integer ttl() { + return getTtl(); + } + + /** + * Returns the number of seconds that this record set can be cached by resolvers. + */ + public Integer getTtl() { return ttl; } /** * Returns the type of this record set. */ + @Deprecated public Type type() { + return getType(); + } + + /** + * Returns the type of this record set. + */ + public Type getType() { return type; } @@ -289,20 +365,20 @@ public boolean equals(Object obj) { ResourceRecordSet toPb() { ResourceRecordSet pb = new ResourceRecordSet(); - pb.setName(this.name()); - pb.setRrdatas(this.records()); - pb.setTtl(this.ttl()); - pb.setType(this.type().name()); + pb.setName(this.getName()); + pb.setRrdatas(this.getRecords()); + pb.setTtl(this.getTtl()); + pb.setType(this.getType().name()); return pb; } static RecordSet fromPb(ResourceRecordSet pb) { - Builder builder = builder(pb.getName(), Type.valueOf(pb.getType())); + Builder builder = newBuilder(pb.getName(), Type.valueOf(pb.getType())); if (pb.getRrdatas() != null) { - builder.records(pb.getRrdatas()); + builder.setRecords(pb.getRrdatas()); } if (pb.getTtl() != null) { - builder.ttl(pb.getTtl(), TimeUnit.SECONDS); + builder.setTtl(pb.getTtl(), TimeUnit.SECONDS); } return builder.build(); } @@ -310,10 +386,10 @@ static RecordSet fromPb(ResourceRecordSet pb) { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("name", name()) - .add("rrdatas", records()) - .add("ttl", ttl()) - .add("type", type()) + .add("name", getName()) + .add("rrdatas", getRecords()) + .add("ttl", getTtl()) + .add("type", getType()) .toString(); } } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/Zone.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/Zone.java index a01f7212d28e..5680af4c8646 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/Zone.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/Zone.java @@ -56,44 +56,62 @@ private Builder(Zone zone) { } @Override + @Deprecated public Builder name(String name) { - infoBuilder.name(name); + return setName(name); + } + + @Override + public Builder setName(String name) { + infoBuilder.setName(name); return this; } @Override - Builder generatedId(String generatedId) { - infoBuilder.generatedId(generatedId); + Builder setGeneratedId(String generatedId) { + infoBuilder.setGeneratedId(generatedId); return this; } @Override - Builder creationTimeMillis(long creationTimeMillis) { - infoBuilder.creationTimeMillis(creationTimeMillis); + Builder setCreationTimeMillis(long creationTimeMillis) { + infoBuilder.setCreationTimeMillis(creationTimeMillis); return this; } @Override + @Deprecated public Builder dnsName(String dnsName) { - infoBuilder.dnsName(dnsName); + return setDnsName(dnsName); + } + + @Override + public Builder setDnsName(String dnsName) { + infoBuilder.setDnsName(dnsName); return this; } @Override + @Deprecated public Builder description(String description) { - infoBuilder.description(description); + return setDescription(description); + } + + @Override + public Builder setDescription(String description) { + infoBuilder.setDescription(description); return this; } @Override - Builder nameServerSet(String nameServerSet) { - infoBuilder.nameServerSet(nameServerSet); + Builder setNameServerSet(String nameServerSet) { + infoBuilder.setNameServerSet(nameServerSet); return this; } @Override - Builder nameServers(List nameServers) { - infoBuilder.nameServers(nameServers); // infoBuilder makes a copy + Builder setNameServers(List nameServers) { + infoBuilder.setNameServers(nameServers); // infoBuilder makes a copy return this; } @@ -122,7 +140,7 @@ public Builder toBuilder() { * @throws DnsException upon failure */ public Zone reload(Dns.ZoneOption... options) { - return dns.getZone(name(), options); + return dns.getZone(getName(), options); } /** @@ -132,7 +150,7 @@ public Zone reload(Dns.ZoneOption... options) { * @throws DnsException upon failure */ public boolean delete() { - return dns.delete(name()); + return dns.delete(getName()); } /** @@ -143,7 +161,7 @@ public boolean delete() { * @throws DnsException upon failure or if the zone is not found */ public Page listRecordSets(Dns.RecordSetListOption... options) { - return dns.listRecordSets(name(), options); + return dns.listRecordSets(getName(), options); } /** @@ -157,7 +175,7 @@ public Page listRecordSets(Dns.RecordSetListOption... options) { public ChangeRequest applyChangeRequest(ChangeRequestInfo changeRequest, Dns.ChangeRequestOption... options) { checkNotNull(changeRequest); - return dns.applyChangeRequest(name(), changeRequest, options); + return dns.applyChangeRequest(getName(), changeRequest, options); } /** @@ -173,7 +191,7 @@ public ChangeRequest applyChangeRequest(ChangeRequestInfo changeRequest, public ChangeRequest getChangeRequest(String changeRequestId, Dns.ChangeRequestOption... options) { checkNotNull(changeRequestId); - return dns.getChangeRequest(name(), changeRequestId, options); + return dns.getChangeRequest(getName(), changeRequestId, options); } /** @@ -185,13 +203,21 @@ public ChangeRequest getChangeRequest(String changeRequestId, * @throws DnsException upon failure or if the zone is not found */ public Page listChangeRequests(Dns.ChangeRequestListOption... options) { - return dns.listChangeRequests(name(), options); + return dns.listChangeRequests(getName(), options); } /** * Returns the {@link Dns} service object associated with this zone. */ + @Deprecated public Dns dns() { + return getDns(); + } + + /** + * Returns the {@link Dns} service object associated with this zone. + */ + public Dns getDns() { return this.dns; } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/ZoneInfo.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/ZoneInfo.java index d6178479b68b..c4e494d33f09 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/ZoneInfo.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/ZoneInfo.java @@ -55,41 +55,60 @@ public abstract static class Builder { /** * Sets a mandatory user-provided name for the zone. It must be unique within the project. */ + @Deprecated public abstract Builder name(String name); + /** + * Sets a mandatory user-provided name for the zone. It must be unique within the project. + */ + public abstract Builder setName(String name); + /** * Sets service-generated id for the zone. */ - abstract Builder generatedId(String generatedId); + abstract Builder setGeneratedId(String generatedId); /** * Sets the time when this zone was created. */ - abstract Builder creationTimeMillis(long creationTimeMillis); + abstract Builder setCreationTimeMillis(long creationTimeMillis); /** * Sets a mandatory DNS name of this zone, for instance "example.com.". */ + @Deprecated public abstract Builder dnsName(String dnsName); + /** + * Sets a mandatory DNS name of this zone, for instance "example.com.". + */ + public abstract Builder setDnsName(String dnsName); + /** * Sets a mandatory description for this zone. The value is a string of at most 1024 characters * which has no effect on the zone's function. */ + @Deprecated public abstract Builder description(String description); + /** + * Sets a mandatory description for this zone. The value is a string of at most 1024 characters + * which has no effect on the zone's function. + */ + public abstract Builder setDescription(String description); + /** * Optionally specifies the NameServerSet for this zone. A NameServerSet is a set of DNS name * servers that all host the same zones. Most users will not need to specify this value. */ - abstract Builder nameServerSet(String nameServerSet); + abstract Builder setNameServerSet(String nameServerSet); // this should not be included in tooling as per the service owners /** * Sets a list of servers that hold the information about the zone. This information is provided * by Google Cloud DNS and is read only. */ - abstract Builder nameServers(List nameServers); + abstract Builder setNameServers(List nameServers); /** * Builds the instance of {@code ZoneInfo} based on the information set by this builder. @@ -126,43 +145,61 @@ private BuilderImpl(String name) { } @Override + @Deprecated public Builder name(String name) { + return setName(name); + } + + @Override + public Builder setName(String name) { this.name = checkNotNull(name); return this; } @Override - Builder generatedId(String generatedId) { + Builder setGeneratedId(String generatedId) { this.generatedId = generatedId; return this; } @Override - Builder creationTimeMillis(long creationTimeMillis) { + Builder setCreationTimeMillis(long creationTimeMillis) { this.creationTimeMillis = creationTimeMillis; return this; } @Override + @Deprecated public Builder dnsName(String dnsName) { + return setDnsName(dnsName); + } + + @Override + public Builder setDnsName(String dnsName) { this.dnsName = checkNotNull(dnsName); return this; } @Override + @Deprecated public Builder description(String description) { + return setDescription(description); + } + + @Override + public Builder setDescription(String description) { this.description = checkNotNull(description); return this; } @Override - Builder nameServerSet(String nameServerSet) { + Builder setNameServerSet(String nameServerSet) { this.nameServerSet = checkNotNull(nameServerSet); return this; } @Override - Builder nameServers(List nameServers) { + Builder setNameServers(List nameServers) { checkNotNull(nameServers); this.nameServers = Lists.newLinkedList(nameServers); return this; @@ -189,41 +226,81 @@ public ZoneInfo build() { * Returns a ZoneInfo object with assigned {@code name}, {@code dnsName} and {@code description}. */ public static ZoneInfo of(String name, String dnsName, String description) { - return new BuilderImpl(name).dnsName(dnsName).description(description).build(); + return new BuilderImpl(name).setDnsName(dnsName).setDescription(description).build(); } /** * Returns the user-defined name of the zone. */ + @Deprecated public String name() { + return getName(); + } + + /** + * Returns the user-defined name of the zone. + */ + public String getName() { return name; } /** * Returns the service-generated id for this zone. */ + @Deprecated public String generatedId() { + return getGeneratedId(); + } + + /** + * Returns the service-generated id for this zone. + */ + public String getGeneratedId() { return generatedId; } /** * Returns the time when this zone was created on the server. */ + @Deprecated public Long creationTimeMillis() { + return getCreationTimeMillis(); + } + + /** + * Returns the time when this zone was created on the server. + */ + public Long getCreationTimeMillis() { return creationTimeMillis; } /** * Returns the DNS name of this zone, for instance "example.com.". */ + @Deprecated public String dnsName() { + return getDnsName(); + } + + /** + * Returns the DNS name of this zone, for instance "example.com.". + */ + public String getDnsName() { return dnsName; } /** * Returns the description of this zone. */ + @Deprecated public String description() { + return getDescription(); + } + + /** + * Returns the description of this zone. + */ + public String getDescription() { return description; } @@ -231,14 +308,31 @@ public String description() { * Returns the optionally specified set of DNS name servers that all host this zone. This value is * set only for specific use cases and is left empty for vast majority of users. */ + @Deprecated public String nameServerSet() { + return getNameServerSet(); + } + + /** + * Returns the optionally specified set of DNS name servers that all host this zone. This value is + * set only for specific use cases and is left empty for vast majority of users. + */ + public String getNameServerSet() { return nameServerSet; } /** * The nameservers that the zone should be delegated to. This is defined by the Google DNS cloud. */ + @Deprecated public List nameServers() { + return getNameServers(); + } + + /** + * The nameservers that the zone should be delegated to. This is defined by the Google DNS cloud. + */ + public List getNameServers() { return nameServers == null ? ImmutableList.of() : nameServers; } @@ -252,18 +346,18 @@ public Builder toBuilder() { ManagedZone toPb() { ManagedZone pb = new ManagedZone(); - pb.setDescription(this.description()); - pb.setDnsName(this.dnsName()); - if (this.generatedId() != null) { - pb.setId(new BigInteger(this.generatedId())); + pb.setDescription(this.getDescription()); + pb.setDnsName(this.getDnsName()); + if (this.getGeneratedId() != null) { + pb.setId(new BigInteger(this.getGeneratedId())); } - pb.setName(this.name()); + pb.setName(this.getName()); pb.setNameServers(this.nameServers); // do use real attribute value which may be null - pb.setNameServerSet(this.nameServerSet()); - if (this.creationTimeMillis() != null) { + pb.setNameServerSet(this.getNameServerSet()); + if (this.getCreationTimeMillis() != null) { pb.setCreationTime(ISODateTimeFormat.dateTime() .withZoneUTC() - .print(this.creationTimeMillis())); + .print(this.getCreationTimeMillis())); } return pb; } @@ -271,22 +365,22 @@ ManagedZone toPb() { static ZoneInfo fromPb(ManagedZone pb) { Builder builder = new BuilderImpl(pb.getName()); if (pb.getDescription() != null) { - builder.description(pb.getDescription()); + builder.setDescription(pb.getDescription()); } if (pb.getDnsName() != null) { - builder.dnsName(pb.getDnsName()); + builder.setDnsName(pb.getDnsName()); } if (pb.getId() != null) { - builder.generatedId(pb.getId().toString()); + builder.setGeneratedId(pb.getId().toString()); } if (pb.getNameServers() != null) { - builder.nameServers(pb.getNameServers()); + builder.setNameServers(pb.getNameServers()); } if (pb.getNameServerSet() != null) { - builder.nameServerSet(pb.getNameServerSet()); + builder.setNameServerSet(pb.getNameServerSet()); } if (pb.getCreationTime() != null) { - builder.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis()); + builder.setCreationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis()); } return builder.build(); } @@ -308,13 +402,13 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("name", name()) - .add("generatedId", generatedId()) - .add("description", description()) - .add("dnsName", dnsName()) - .add("nameServerSet", nameServerSet()) - .add("nameServers", nameServers()) - .add("creationTimeMillis", creationTimeMillis()) + .add("name", getName()) + .add("generatedId", getGeneratedId()) + .add("description", getDescription()) + .add("dnsName", getDnsName()) + .add("nameServerSet", getNameServerSet()) + .add("nameServers", getNameServers()) + .add("creationTimeMillis", getCreationTimeMillis()) .toString(); } } diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/package-info.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/package-info.java index a9c29efaa0f1..a56db7757db7 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/package-info.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/package-info.java @@ -46,11 +46,11 @@ * String zoneName = "my-unique-zone"; * Zone zone = dns.getZone(zoneName); * String ip = "12.13.14.15"; - * RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A) - * .ttl(24, TimeUnit.HOURS) + * RecordSet toCreate = RecordSet.newBuilder("www.someexampledomain.com.", RecordSet.Type.A) + * .setTtl(24, TimeUnit.HOURS) * .addRecord(ip) * .build(); - * ChangeRequestInfo changeRequest = ChangeRequestInfo.builder().add(toCreate).build(); + * ChangeRequestInfo changeRequest = ChangeRequestInfo.newBuilder().add(toCreate).build(); * zone.applyChangeRequest(changeRequest); * } * diff --git a/google-cloud-dns/src/main/java/com/google/cloud/dns/testing/LocalDnsHelper.java b/google-cloud-dns/src/main/java/com/google/cloud/dns/testing/LocalDnsHelper.java index 774bc566a458..12e2599defcb 100644 --- a/google-cloud-dns/src/main/java/com/google/cloud/dns/testing/LocalDnsHelper.java +++ b/google-cloud-dns/src/main/java/com/google/cloud/dns/testing/LocalDnsHelper.java @@ -39,6 +39,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.ByteStreams; + import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; @@ -494,7 +495,15 @@ public static LocalDnsHelper create(Long delay) { /** * Returns a {@link DnsOptions} instance that sets the host to use the mock server. */ + @Deprecated public DnsOptions options() { + return getOptions(); + } + + /** + * Returns a {@link DnsOptions} instance that sets the host to use the mock server. + */ + public DnsOptions getOptions() { return DnsOptions.builder() .projectId(PROJECT_ID) .host("http://localhost:" + port) diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestInfoTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestInfoTest.java index 2da7ad75c569..9632ac475c09 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestInfoTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestInfoTest.java @@ -41,22 +41,39 @@ public class ChangeRequestInfoTest { private static final RecordSet.Type TYPE2 = RecordSet.Type.AAAA; private static final String NAME3 = "dns3"; private static final RecordSet.Type TYPE3 = RecordSet.Type.MX; - private static final RecordSet RECORD1 = RecordSet.builder(NAME1, TYPE1).build(); - private static final RecordSet RECORD2 = RecordSet.builder(NAME2, TYPE2).build(); - private static final RecordSet RECORD3 = RecordSet.builder(NAME3, TYPE3).build(); + private static final RecordSet RECORD1 = RecordSet.newBuilder(NAME1, TYPE1).build(); + private static final RecordSet RECORD2 = RecordSet.newBuilder(NAME2, TYPE2).build(); + private static final RecordSet RECORD3 = RecordSet.newBuilder(NAME3, TYPE3).build(); private static final List ADDITIONS = ImmutableList.of(RECORD1, RECORD2); private static final List DELETIONS = ImmutableList.of(RECORD3); - private static final ChangeRequestInfo CHANGE = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE = ChangeRequest.newBuilder() .add(RECORD1) .add(RECORD2) .delete(RECORD3) - .startTimeMillis(START_TIME_MILLIS) - .status(STATUS) - .generatedId(GENERATED_ID) + .setStartTime(START_TIME_MILLIS) + .setStatus(STATUS) + .setGeneratedId(GENERATED_ID) + .build(); + private static final ChangeRequestInfo DEPRECATED_CHANGE = ChangeRequest.builder() + .add(RECORD1) + .add(RECORD2) + .delete(RECORD3) + .setStartTime(START_TIME_MILLIS) + .setStatus(STATUS) + .setGeneratedId(GENERATED_ID) .build(); @Test public void testEmptyBuilder() { + ChangeRequestInfo cr = ChangeRequest.newBuilder().build(); + assertNotNull(cr.getDeletions()); + assertTrue(cr.getDeletions().isEmpty()); + assertNotNull(cr.getAdditions()); + assertTrue(cr.getAdditions().isEmpty()); + } + + @Test + public void testEmptyBuilderDeprecated() { ChangeRequestInfo cr = ChangeRequest.builder().build(); assertNotNull(cr.deletions()); assertTrue(cr.deletions().isEmpty()); @@ -66,18 +83,34 @@ public void testEmptyBuilder() { @Test public void testBuilder() { - assertEquals(GENERATED_ID, CHANGE.generatedId()); + assertEquals(GENERATED_ID, CHANGE.getGeneratedId()); assertEquals(STATUS, CHANGE.status()); - assertEquals(START_TIME_MILLIS, CHANGE.startTimeMillis()); - assertEquals(ADDITIONS, CHANGE.additions()); - assertEquals(DELETIONS, CHANGE.deletions()); + assertEquals(START_TIME_MILLIS, CHANGE.getStartTimeMillis()); + assertEquals(ADDITIONS, CHANGE.getAdditions()); + assertEquals(DELETIONS, CHANGE.getDeletions()); + List recordList = ImmutableList.of(RECORD1); + ChangeRequestInfo another = CHANGE.toBuilder().setAdditions(recordList).build(); + assertEquals(recordList, another.getAdditions()); + assertEquals(CHANGE.getDeletions(), another.getDeletions()); + another = CHANGE.toBuilder().setDeletions(recordList).build(); + assertEquals(recordList, another.getDeletions()); + assertEquals(CHANGE.getAdditions(), another.getAdditions()); + } + + @Test + public void testBuilderDeprecated() { + assertEquals(GENERATED_ID, DEPRECATED_CHANGE.generatedId()); + assertEquals(STATUS, DEPRECATED_CHANGE.status()); + assertEquals(START_TIME_MILLIS, DEPRECATED_CHANGE.startTimeMillis()); + assertEquals(ADDITIONS, DEPRECATED_CHANGE.additions()); + assertEquals(DELETIONS, DEPRECATED_CHANGE.deletions()); List recordList = ImmutableList.of(RECORD1); - ChangeRequestInfo another = CHANGE.toBuilder().additions(recordList).build(); + ChangeRequestInfo another = DEPRECATED_CHANGE.toBuilder().additions(recordList).build(); assertEquals(recordList, another.additions()); - assertEquals(CHANGE.deletions(), another.deletions()); - another = CHANGE.toBuilder().deletions(recordList).build(); + assertEquals(DEPRECATED_CHANGE.deletions(), another.deletions()); + another = DEPRECATED_CHANGE.toBuilder().deletions(recordList).build(); assertEquals(recordList, another.deletions()); - assertEquals(CHANGE.additions(), another.additions()); + assertEquals(DEPRECATED_CHANGE.additions(), another.additions()); } @Test @@ -86,17 +119,17 @@ public void testEqualsAndNotEquals() { assertEquals(CHANGE, clone); clone = ChangeRequest.fromPb(CHANGE.toPb()); assertEquals(CHANGE, clone); - clone = CHANGE.toBuilder().generatedId("some-other-id").build(); + clone = CHANGE.toBuilder().setGeneratedId("some-other-id").build(); assertNotEquals(CHANGE, clone); - clone = CHANGE.toBuilder().startTimeMillis(CHANGE.startTimeMillis() + 1).build(); + clone = CHANGE.toBuilder().setStartTime(CHANGE.getStartTimeMillis() + 1).build(); assertNotEquals(CHANGE, clone); clone = CHANGE.toBuilder().add(RECORD3).build(); assertNotEquals(CHANGE, clone); clone = CHANGE.toBuilder().delete(RECORD1).build(); assertNotEquals(CHANGE, clone); - ChangeRequestInfo empty = ChangeRequest.builder().build(); + ChangeRequestInfo empty = ChangeRequest.newBuilder().build(); assertNotEquals(CHANGE, empty); - assertEquals(empty, ChangeRequest.builder().build()); + assertEquals(empty, ChangeRequest.newBuilder().build()); } @Test @@ -104,57 +137,57 @@ public void testSameHashCodeOnEquals() { ChangeRequestInfo clone = CHANGE.toBuilder().build(); assertEquals(CHANGE, clone); assertEquals(CHANGE.hashCode(), clone.hashCode()); - ChangeRequestInfo empty = ChangeRequest.builder().build(); - assertEquals(empty.hashCode(), ChangeRequest.builder().build().hashCode()); + ChangeRequestInfo empty = ChangeRequest.newBuilder().build(); + assertEquals(empty.hashCode(), ChangeRequest.newBuilder().build().hashCode()); } @Test public void testToAndFromPb() { assertEquals(CHANGE, ChangeRequest.fromPb(CHANGE.toPb())); - ChangeRequestInfo partial = ChangeRequest.builder().build(); + ChangeRequestInfo partial = ChangeRequest.newBuilder().build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().generatedId(GENERATED_ID).build(); + partial = ChangeRequest.newBuilder().setGeneratedId(GENERATED_ID).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().add(RECORD1).build(); + partial = ChangeRequest.newBuilder().add(RECORD1).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().delete(RECORD1).build(); + partial = ChangeRequest.newBuilder().delete(RECORD1).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().additions(ADDITIONS).build(); + partial = ChangeRequest.newBuilder().setAdditions(ADDITIONS).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().deletions(DELETIONS).build(); + partial = ChangeRequest.newBuilder().setDeletions(DELETIONS).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); + partial = ChangeRequest.newBuilder().setStartTime(START_TIME_MILLIS).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().status(STATUS).build(); + partial = ChangeRequest.newBuilder().setStatus(STATUS).build(); assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); } @Test public void testToBuilder() { assertEquals(CHANGE, CHANGE.toBuilder().build()); - ChangeRequestInfo partial = ChangeRequest.builder().build(); + ChangeRequestInfo partial = ChangeRequest.newBuilder().build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().generatedId(GENERATED_ID).build(); + partial = ChangeRequest.newBuilder().setGeneratedId(GENERATED_ID).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().add(RECORD1).build(); + partial = ChangeRequest.newBuilder().add(RECORD1).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().delete(RECORD1).build(); + partial = ChangeRequest.newBuilder().delete(RECORD1).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().additions(ADDITIONS).build(); + partial = ChangeRequest.newBuilder().setAdditions(ADDITIONS).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().deletions(DELETIONS).build(); + partial = ChangeRequest.newBuilder().setDeletions(DELETIONS).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); + partial = ChangeRequest.newBuilder().setStartTime(START_TIME_MILLIS).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().status(STATUS).build(); + partial = ChangeRequest.newBuilder().setStatus(STATUS).build(); assertEquals(partial, partial.toBuilder().build()); } @Test public void testClearAdditions() { ChangeRequestInfo clone = CHANGE.toBuilder().clearAdditions().build(); - assertTrue(clone.additions().isEmpty()); - assertFalse(clone.deletions().isEmpty()); + assertTrue(clone.getAdditions().isEmpty()); + assertFalse(clone.getDeletions().isEmpty()); } @Test @@ -166,7 +199,7 @@ public void testAddAddition() { // expected } ChangeRequestInfo clone = CHANGE.toBuilder().add(RECORD1).build(); - assertEquals(CHANGE.additions().size() + 1, clone.additions().size()); + assertEquals(CHANGE.getAdditions().size() + 1, clone.getAdditions().size()); } @Test @@ -178,33 +211,33 @@ public void testAddDeletion() { // expected } ChangeRequestInfo clone = CHANGE.toBuilder().delete(RECORD1).build(); - assertEquals(CHANGE.deletions().size() + 1, clone.deletions().size()); + assertEquals(CHANGE.getDeletions().size() + 1, clone.getDeletions().size()); } @Test public void testClearDeletions() { ChangeRequestInfo clone = CHANGE.toBuilder().clearDeletions().build(); - assertTrue(clone.deletions().isEmpty()); - assertFalse(clone.additions().isEmpty()); + assertTrue(clone.getDeletions().isEmpty()); + assertFalse(clone.getAdditions().isEmpty()); } @Test public void testRemoveAddition() { ChangeRequestInfo clone = CHANGE.toBuilder().removeAddition(RECORD1).build(); - assertTrue(clone.additions().contains(RECORD2)); - assertFalse(clone.additions().contains(RECORD1)); - assertTrue(clone.deletions().contains(RECORD3)); + assertTrue(clone.getAdditions().contains(RECORD2)); + assertFalse(clone.getAdditions().contains(RECORD1)); + assertTrue(clone.getDeletions().contains(RECORD3)); clone = CHANGE.toBuilder().removeAddition(RECORD2).removeAddition(RECORD1).build(); - assertFalse(clone.additions().contains(RECORD2)); - assertFalse(clone.additions().contains(RECORD1)); - assertTrue(clone.additions().isEmpty()); - assertTrue(clone.deletions().contains(RECORD3)); + assertFalse(clone.getAdditions().contains(RECORD2)); + assertFalse(clone.getAdditions().contains(RECORD1)); + assertTrue(clone.getAdditions().isEmpty()); + assertTrue(clone.getDeletions().contains(RECORD3)); } @Test public void testRemoveDeletion() { ChangeRequestInfo clone = CHANGE.toBuilder().removeDeletion(RECORD3).build(); - assertTrue(clone.deletions().isEmpty()); + assertTrue(clone.getDeletions().isEmpty()); } @Test @@ -212,7 +245,7 @@ public void testDateParsing() { String startTime = "2016-01-26T18:33:43.512Z"; // obtained from service Change change = CHANGE.toPb().setStartTime(startTime); ChangeRequestInfo converted = ChangeRequest.fromPb(change); - assertNotNull(converted.startTimeMillis()); + assertNotNull(converted.getStartTimeMillis()); assertEquals(change, converted.toPb()); assertEquals(change.getStartTime(), converted.toPb().getStartTime()); } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestTest.java index 6daa1a0a8cdd..f983ae47e686 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/ChangeRequestTest.java @@ -35,9 +35,9 @@ public class ChangeRequestTest { private static final String ZONE_NAME = "dns-zone-name"; - private static final ChangeRequestInfo CHANGE_REQUEST_INFO = ChangeRequest.builder() - .add(RecordSet.builder("name", RecordSet.Type.A).build()) - .delete(RecordSet.builder("othername", RecordSet.Type.AAAA).build()) + private static final ChangeRequestInfo CHANGE_REQUEST_INFO = ChangeRequest.newBuilder() + .add(RecordSet.newBuilder("name", RecordSet.Type.A).build()) + .delete(RecordSet.newBuilder("othername", RecordSet.Type.AAAA).build()) .build(); private static final DnsOptions OPTIONS = createStrictMock(DnsOptions.class); @@ -53,15 +53,15 @@ public void setUp() throws Exception { replay(dns); changeRequest = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( CHANGE_REQUEST_INFO.toBuilder() - .startTimeMillis(132L) - .generatedId("12") - .status(ChangeRequest.Status.DONE) + .setStartTime(132L) + .setGeneratedId("12") + .setStatus(ChangeRequest.Status.DONE) .build())); changeRequestPending = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( CHANGE_REQUEST_INFO.toBuilder() - .startTimeMillis(132L) - .generatedId("12") - .status(ChangeRequest.Status.PENDING) + .setStartTime(132L) + .setGeneratedId("12") + .setStatus(ChangeRequest.Status.PENDING) .build())); changeRequestPartial = new ChangeRequest(dns, ZONE_NAME, new ChangeRequest.BuilderImpl(CHANGE_REQUEST_INFO)); @@ -106,15 +106,43 @@ public void testEqualsAndToBuilder() { assertEquals(changeRequestPartial.hashCode(), compare.hashCode()); } + @Test 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.getGeneratedId() + "aaa"; + assertEquals(id, changeRequest.toBuilder().setGeneratedId(id).build().getGeneratedId()); + ChangeRequest modified = + changeRequest.toBuilder().setStatus(ChangeRequest.Status.PENDING).build(); + assertEquals(ChangeRequest.Status.PENDING, modified.status()); + modified = changeRequest.toBuilder().clearDeletions().build(); + assertTrue(modified.getDeletions().isEmpty()); + modified = changeRequest.toBuilder().clearAdditions().build(); + assertTrue(modified.getAdditions().isEmpty()); + modified = changeRequest.toBuilder().setAdditions(ImmutableList.of()).build(); + assertTrue(modified.getAdditions().isEmpty()); + modified = changeRequest.toBuilder().setDeletions(ImmutableList.of()).build(); + assertTrue(modified.getDeletions().isEmpty()); + RecordSet cname = RecordSet.newBuilder("last", RecordSet.Type.CNAME).build(); + modified = changeRequest.toBuilder().add(cname).build(); + assertTrue(modified.getAdditions().contains(cname)); + modified = changeRequest.toBuilder().delete(cname).build(); + assertTrue(modified.getDeletions().contains(cname)); + modified = changeRequest.toBuilder().setStartTime(0L).build(); + assertEquals(Long.valueOf(0), modified.getStartTimeMillis()); + } + + @Test + public void testBuilderDeprecated() { // one for each build() call because it invokes a constructor expect(dns.options()).andReturn(OPTIONS).times(9); replay(dns); String id = changeRequest.generatedId() + "aaa"; - assertEquals(id, changeRequest.toBuilder().generatedId(id).build().generatedId()); + assertEquals(id, changeRequest.toBuilder().setGeneratedId(id).build().generatedId()); ChangeRequest modified = - changeRequest.toBuilder().status(ChangeRequest.Status.PENDING).build(); + changeRequest.toBuilder().setStatus(ChangeRequest.Status.PENDING).build(); assertEquals(ChangeRequest.Status.PENDING, modified.status()); modified = changeRequest.toBuilder().clearDeletions().build(); assertTrue(modified.deletions().isEmpty()); @@ -129,7 +157,7 @@ public void testBuilder() { assertTrue(modified.additions().contains(cname)); modified = changeRequest.toBuilder().delete(cname).build(); assertTrue(modified.deletions().contains(cname)); - modified = changeRequest.toBuilder().startTimeMillis(0L).build(); + modified = changeRequest.toBuilder().setStartTime(0L).build(); assertEquals(Long.valueOf(0), modified.startTimeMillis()); } @@ -147,8 +175,9 @@ public void testApplyTo() { @Test public void testReload() { - expect(dns.getChangeRequest(ZONE_NAME, changeRequest.generatedId())).andReturn(changeRequest); - expect(dns.getChangeRequest(ZONE_NAME, changeRequest.generatedId(), + expect(dns.getChangeRequest(ZONE_NAME, changeRequest.getGeneratedId())) + .andReturn(changeRequest); + expect(dns.getChangeRequest(ZONE_NAME, changeRequest.getGeneratedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME))) .andReturn(changeRequest); replay(dns); @@ -163,7 +192,7 @@ public void testIsDone() { assertTrue(changeRequest.isDone()); verify(dns); reset(dns); - expect(dns.getChangeRequest(ZONE_NAME, changeRequest.generatedId(), + expect(dns.getChangeRequest(ZONE_NAME, changeRequest.getGeneratedId(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS))) .andReturn(changeRequest); replay(dns); diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsBatchTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsBatchTest.java index 746a65ab7155..d348e8e9858f 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsBatchTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsBatchTest.java @@ -64,7 +64,7 @@ public class DnsBatchTest { Dns.ZoneListOption.pageSize(MAX_SIZE), Dns.ZoneListOption.pageToken(PAGE_TOKEN), Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION), Dns.ZoneListOption.dnsName(DNS_NAME)}; - private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder().build(); + private static final ProjectInfo PROJECT_INFO = ProjectInfo.newBuilder().build(); private static final Dns.RecordSetListOption[] RECORD_SET_LIST_OPTIONS = { Dns.RecordSetListOption.pageSize(MAX_SIZE), Dns.RecordSetListOption.pageToken(PAGE_TOKEN), @@ -72,16 +72,16 @@ public class DnsBatchTest { Dns.RecordSetListOption.dnsName(DNS_NAME), Dns.RecordSetListOption.type(RecordSet.Type.AAAA)}; private static final RecordSet RECORD_SET = - RecordSet.builder("Something", RecordSet.Type.AAAA).build(); - private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequestInfo.builder() + RecordSet.newBuilder("Something", RecordSet.Type.AAAA).build(); + private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequestInfo.newBuilder() .add(RECORD_SET) .build(); private static final String CHANGE_ID = "some change id"; - private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequestInfo.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequestInfo.newBuilder() .add(RECORD_SET) - .startTimeMillis(123L) - .status(ChangeRequest.Status.PENDING) - .generatedId(CHANGE_ID) + .setStartTime(123L) + .setStatus(ChangeRequest.Status.PENDING) + .setGeneratedId(CHANGE_ID) .build(); private static final Dns.ChangeRequestListOption[] CHANGE_LIST_OPTIONS = { Dns.ChangeRequestListOption.pageSize(MAX_SIZE), @@ -122,9 +122,9 @@ public void tearDown() { @Test public void testConstructor() { - assertSame(batchMock, dnsBatch.batch()); - assertSame(optionsMock, dnsBatch.options()); - assertSame(dnsRpcMock, dnsBatch.dnsRpc()); + assertSame(batchMock, dnsBatch.getBatch()); + assertSame(optionsMock, dnsBatch.getOptions()); + assertSame(dnsRpcMock, dnsBatch.getDnsRpc()); } @Test @@ -163,14 +163,14 @@ public void testListZonesWithOptions() { EasyMock.replay(batchMock); DnsBatchResult> batchResult = dnsBatch.listZones(ZONE_LIST_OPTIONS); assertNotNull(callback.getValue()); - Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].rpcOption()); + Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].getRpcOption()); assertEquals(MAX_SIZE, size); - String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].rpcOption()); + String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].getRpcOption()); assertEquals(PAGE_TOKEN, selector); - selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].rpcOption()); + selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].getRpcOption()); assertTrue(selector.contains(Dns.ZoneField.DESCRIPTION.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); - selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].rpcOption()); + selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].getRpcOption()); assertEquals(DNS_NAME, selector); // check the callback ManagedZonesListResponse response = new ManagedZonesListResponse() @@ -245,7 +245,7 @@ public void testCreateZoneWithOptions() { DnsBatchResult batchResult = dnsBatch.createZone(ZONE_INFO, ZONE_FIELDS); assertEquals(ZONE_INFO.toPb(), capturedZone.getValue()); assertNotNull(callback.getValue()); - String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.getRpcOption()); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); RpcBatch.Callback capturedCallback = callback.getValue(); @@ -311,7 +311,7 @@ public void testGetZoneWithOptions() { EasyMock.replay(dns, batchMock, optionsMock); DnsBatchResult batchResult = dnsBatch.getZone(ZONE_NAME, ZONE_FIELDS); assertNotNull(callback.getValue()); - String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.getRpcOption()); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); RpcBatch.Callback capturedCallback = callback.getValue(); @@ -396,7 +396,7 @@ public void testGetProjectWithOptions() { EasyMock.replay(batchMock); DnsBatchResult batchResult = dnsBatch.getProject(PROJECT_FIELDS); assertNotNull(callback.getValue()); - String selector = (String) capturedOptions.getValue().get(PROJECT_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(PROJECT_FIELDS.getRpcOption()); assertTrue(selector.contains(Dns.ProjectField.QUOTA.selector())); assertTrue(selector.contains(Dns.ProjectField.PROJECT_ID.selector())); RpcBatch.Callback capturedCallback = callback.getValue(); @@ -443,19 +443,20 @@ public void testListRecordSetsWithOptions() { DnsBatchResult> batchResult = dnsBatch.listRecordSets(ZONE_NAME, RECORD_SET_LIST_OPTIONS); assertNotNull(callback.getValue()); - Integer size = (Integer) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[0].rpcOption()); + Integer size = + (Integer) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[0].getRpcOption()); assertEquals(MAX_SIZE, size); String selector = (String) capturedOptions.getValue() - .get(RECORD_SET_LIST_OPTIONS[1].rpcOption()); + .get(RECORD_SET_LIST_OPTIONS[1].getRpcOption()); assertEquals(PAGE_TOKEN, selector); - selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[2].rpcOption()); + selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[2].getRpcOption()); assertTrue(selector.contains(Dns.RecordSetField.NAME.selector())); assertTrue(selector.contains(Dns.RecordSetField.TTL.selector())); - selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[3].rpcOption()); - assertEquals(RECORD_SET_LIST_OPTIONS[3].value(), selector); + selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[3].getRpcOption()); + assertEquals(RECORD_SET_LIST_OPTIONS[3].getValue(), selector); String type = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[4] - .rpcOption()); - assertEquals(RECORD_SET_LIST_OPTIONS[4].value(), type); + .getRpcOption()); + assertEquals(RECORD_SET_LIST_OPTIONS[4].getValue(), type); RpcBatch.Callback capturedCallback = callback.getValue(); ResourceRecordSetsListResponse response = new ResourceRecordSetsListResponse() .setRrsets(RECORD_SET_LIST) @@ -511,14 +512,15 @@ public void testListChangeRequestsWithOptions() { DnsBatchResult> batchResult = dnsBatch.listChangeRequests(ZONE_NAME, CHANGE_LIST_OPTIONS); assertNotNull(callback.getValue()); - Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].rpcOption()); + Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].getRpcOption()); assertEquals(MAX_SIZE, size); - String selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[1].rpcOption()); + String selector = + (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[1].getRpcOption()); assertEquals(PAGE_TOKEN, selector); - selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[2].rpcOption()); + selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[2].getRpcOption()); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); - selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[3].rpcOption()); + selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[3].getRpcOption()); assertTrue(selector.contains(Dns.SortingOrder.ASCENDING.selector())); // check the callback ChangesListResponse response = new ChangesListResponse() @@ -551,11 +553,11 @@ public void testGetChangeRequest() { Capture> callback = Capture.newInstance(); Capture> capturedOptions = Capture.newInstance(); batchMock.addGetChangeRequest(EasyMock.eq(ZONE_NAME), - EasyMock.eq(CHANGE_REQUEST_COMPLETE.generatedId()), EasyMock.capture(callback), + EasyMock.eq(CHANGE_REQUEST_COMPLETE.getGeneratedId()), EasyMock.capture(callback), EasyMock.capture(capturedOptions)); EasyMock.replay(batchMock); DnsBatchResult batchResult = dnsBatch.getChangeRequest(ZONE_NAME, - CHANGE_REQUEST_COMPLETE.generatedId()); + CHANGE_REQUEST_COMPLETE.getGeneratedId()); assertEquals(0, capturedOptions.getValue().size()); assertNotNull(callback.getValue()); try { @@ -582,11 +584,11 @@ public void testGetChangeRequestNotFound() { Capture> callback = Capture.newInstance(); Capture> capturedOptions = Capture.newInstance(); batchMock.addGetChangeRequest(EasyMock.eq(ZONE_NAME), - EasyMock.eq(CHANGE_REQUEST_COMPLETE.generatedId()), EasyMock.capture(callback), + EasyMock.eq(CHANGE_REQUEST_COMPLETE.getGeneratedId()), EasyMock.capture(callback), EasyMock.capture(capturedOptions)); EasyMock.replay(batchMock); DnsBatchResult batchResult = dnsBatch.getChangeRequest(ZONE_NAME, - CHANGE_REQUEST_COMPLETE.generatedId()); + CHANGE_REQUEST_COMPLETE.getGeneratedId()); assertEquals(0, capturedOptions.getValue().size()); RpcBatch.Callback capturedCallback = callback.getValue(); GoogleJsonError error = new GoogleJsonError(); @@ -607,13 +609,13 @@ public void testGetChangeRequestWithOptions() { Capture> callback = Capture.newInstance(); Capture> capturedOptions = Capture.newInstance(); batchMock.addGetChangeRequest(EasyMock.eq(ZONE_NAME), - EasyMock.eq(CHANGE_REQUEST_COMPLETE.generatedId()), EasyMock.capture(callback), + EasyMock.eq(CHANGE_REQUEST_COMPLETE.getGeneratedId()), EasyMock.capture(callback), EasyMock.capture(capturedOptions)); EasyMock.replay(dns, batchMock, optionsMock); DnsBatchResult batchResult = dnsBatch.getChangeRequest(ZONE_NAME, - CHANGE_REQUEST_COMPLETE.generatedId(), CHANGE_GET_FIELDS); + CHANGE_REQUEST_COMPLETE.getGeneratedId(), CHANGE_GET_FIELDS); assertNotNull(callback.getValue()); - String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.getRpcOption()); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); RpcBatch.Callback capturedCallback = callback.getValue(); @@ -630,7 +632,7 @@ public void testApplyChangeRequest() { EasyMock.eq(CHANGE_REQUEST_PARTIAL.toPb()), EasyMock.capture(callback), EasyMock.capture(capturedOptions)); EasyMock.replay(batchMock); - DnsBatchResult batchResult = dnsBatch.applyChangeRequest(ZONE_INFO.name(), + DnsBatchResult batchResult = dnsBatch.applyChangeRequest(ZONE_INFO.getName(), CHANGE_REQUEST_PARTIAL); assertEquals(0, capturedOptions.getValue().size()); assertNotNull(callback.getValue()); @@ -665,9 +667,9 @@ public void testApplyChangeRequestWithOptions() { EasyMock.capture(capturedOptions)); EasyMock.expect(optionsMock.service()).andReturn(dns); EasyMock.replay(dns, batchMock, optionsMock); - DnsBatchResult batchResult = dnsBatch.applyChangeRequest(ZONE_INFO.name(), + DnsBatchResult batchResult = dnsBatch.applyChangeRequest(ZONE_INFO.getName(), CHANGE_REQUEST_PARTIAL, CHANGE_GET_FIELDS); - String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.getRpcOption()); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); RpcBatch.Callback capturedCallback = callback.getValue(); diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsImplTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsImplTest.java index deefe21f36aa..19c143abbeaf 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsImplTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsImplTest.java @@ -47,21 +47,21 @@ public class DnsImplTest { private static final String DESCRIPTION = "desc"; private static final String CHANGE_ID = "some change id"; private static final RecordSet DNS_RECORD1 = - RecordSet.builder("Something", RecordSet.Type.AAAA).build(); + RecordSet.newBuilder("Something", RecordSet.Type.AAAA).build(); private static final RecordSet DNS_RECORD2 = - RecordSet.builder("Different", RecordSet.Type.AAAA).build(); + RecordSet.newBuilder("Different", RecordSet.Type.AAAA).build(); private static final Integer MAX_SIZE = 20; private static final String PAGE_TOKEN = "some token"; private static final ZoneInfo ZONE_INFO = ZoneInfo.of(ZONE_NAME, DNS_NAME, DESCRIPTION); - private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder().build(); - private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequestInfo.builder() + private static final ProjectInfo PROJECT_INFO = ProjectInfo.newBuilder().build(); + private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequestInfo.newBuilder() .add(DNS_RECORD1) .build(); - private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequestInfo.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequestInfo.newBuilder() .add(DNS_RECORD1) - .startTimeMillis(123L) - .status(ChangeRequest.Status.PENDING) - .generatedId(CHANGE_ID) + .setStartTime(123L) + .setStatus(ChangeRequest.Status.PENDING) + .setGeneratedId(CHANGE_ID) .build(); // Result lists @@ -150,7 +150,7 @@ public void testCreateZoneWithOptions() { EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl Zone zone = dns.create(ZONE_INFO, ZONE_FIELDS); - String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.getRpcOption()); assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); @@ -158,23 +158,23 @@ public void testCreateZoneWithOptions() { @Test public void testGetZone() { - EasyMock.expect(dnsRpcMock.getZone(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + EasyMock.expect(dnsRpcMock.getZone(ZONE_INFO.getName(), EMPTY_RPC_OPTIONS)) .andReturn(ZONE_INFO.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - Zone zone = dns.getZone(ZONE_INFO.name()); + Zone zone = dns.getZone(ZONE_INFO.getName()); assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); } @Test public void testGetZoneWithOptions() { Capture> capturedOptions = Capture.newInstance(); - EasyMock.expect(dnsRpcMock.getZone(EasyMock.eq(ZONE_INFO.name()), + EasyMock.expect(dnsRpcMock.getZone(EasyMock.eq(ZONE_INFO.getName()), EasyMock.capture(capturedOptions))).andReturn(ZONE_INFO.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - Zone zone = dns.getZone(ZONE_INFO.name(), ZONE_FIELDS); - String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); + Zone zone = dns.getZone(ZONE_INFO.getName(), ZONE_FIELDS); + String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.getRpcOption()); assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); @@ -182,11 +182,11 @@ public void testGetZoneWithOptions() { @Test public void testDeleteZone() { - EasyMock.expect(dnsRpcMock.deleteZone(ZONE_INFO.name())) + EasyMock.expect(dnsRpcMock.deleteZone(ZONE_INFO.getName())) .andReturn(true); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - assertTrue(dns.delete(ZONE_INFO.name())); + assertTrue(dns.delete(ZONE_INFO.getName())); } @Test @@ -207,7 +207,7 @@ public void testProjectGetWithOptions() { EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl ProjectInfo projectInfo = dns.getProject(PROJECT_FIELDS); - String selector = (String) capturedOptions.getValue().get(PROJECT_FIELDS.rpcOption()); + String selector = (String) capturedOptions.getValue().get(PROJECT_FIELDS.getRpcOption()); assertEquals(PROJECT_INFO, projectInfo); assertTrue(selector.contains(Dns.ProjectField.QUOTA.selector())); assertTrue(selector.contains(Dns.ProjectField.PROJECT_ID.selector())); @@ -215,29 +215,29 @@ public void testProjectGetWithOptions() { @Test public void testGetChangeRequest() { - EasyMock.expect(dnsRpcMock.getChangeRequest(ZONE_INFO.name(), - CHANGE_REQUEST_COMPLETE.generatedId(), EMPTY_RPC_OPTIONS)) + EasyMock.expect(dnsRpcMock.getChangeRequest(ZONE_INFO.getName(), + CHANGE_REQUEST_COMPLETE.getGeneratedId(), 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.generatedId()); - assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.getName(), + CHANGE_REQUEST_COMPLETE.getGeneratedId()); + assertEquals(new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); } @Test public void testGetChangeRequestWithOptions() { Capture> capturedOptions = Capture.newInstance(); - EasyMock.expect(dnsRpcMock.getChangeRequest(EasyMock.eq(ZONE_INFO.name()), - EasyMock.eq(CHANGE_REQUEST_COMPLETE.generatedId()), EasyMock.capture(capturedOptions))) + EasyMock.expect(dnsRpcMock.getChangeRequest(EasyMock.eq(ZONE_INFO.getName()), + EasyMock.eq(CHANGE_REQUEST_COMPLETE.getGeneratedId()), 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.generatedId(), CHANGE_GET_FIELDS); - String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); - assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.getName(), + CHANGE_REQUEST_COMPLETE.getGeneratedId(), CHANGE_GET_FIELDS); + String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.getRpcOption()); + assertEquals(new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); @@ -245,28 +245,29 @@ public void testGetChangeRequestWithOptions() { @Test public void testApplyChangeRequest() { - EasyMock.expect(dnsRpcMock.applyChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_PARTIAL.toPb(), - EMPTY_RPC_OPTIONS)).andReturn(CHANGE_REQUEST_COMPLETE.toPb()); + EasyMock.expect(dnsRpcMock.applyChangeRequest(ZONE_INFO.getName(), + CHANGE_REQUEST_PARTIAL.toPb(), EMPTY_RPC_OPTIONS)) + .andReturn(CHANGE_REQUEST_COMPLETE.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.name(), + ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.getName(), CHANGE_REQUEST_PARTIAL); - assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + assertEquals(new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); } @Test public void testApplyChangeRequestWithOptions() { Capture> capturedOptions = Capture.newInstance(); - EasyMock.expect(dnsRpcMock.applyChangeRequest(EasyMock.eq(ZONE_INFO.name()), + EasyMock.expect(dnsRpcMock.applyChangeRequest(EasyMock.eq(ZONE_INFO.getName()), EasyMock.eq(CHANGE_REQUEST_PARTIAL.toPb()), EasyMock.capture(capturedOptions))) .andReturn(CHANGE_REQUEST_COMPLETE.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.name(), + ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.getName(), CHANGE_REQUEST_PARTIAL, CHANGE_GET_FIELDS); - String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); - assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.getRpcOption()); + assertEquals(new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); @@ -275,16 +276,16 @@ public void testApplyChangeRequestWithOptions() { // lists @Test public void testListChangeRequests() { - EasyMock.expect(dnsRpcMock.listChangeRequests(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + EasyMock.expect(dnsRpcMock.listChangeRequests(ZONE_INFO.getName(), EMPTY_RPC_OPTIONS)) .andReturn(LIST_RESULT_OF_PB_CHANGES); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - Page changeRequestPage = dns.listChangeRequests(ZONE_INFO.name()); + Page changeRequestPage = dns.listChangeRequests(ZONE_INFO.getName()); assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( - new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)))); assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( - new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_PARTIAL)))); assertEquals(2, Lists.newArrayList(changeRequestPage.values()).size()); } @@ -298,20 +299,21 @@ public void testListChangeRequestsWithOptions() { dns = options.service(); // creates DnsImpl Page changeRequestPage = dns.listChangeRequests(ZONE_NAME, CHANGE_LIST_OPTIONS); assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( - new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)))); assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( - new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequest(dns, ZONE_INFO.getName(), new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_PARTIAL)))); assertEquals(2, Lists.newArrayList(changeRequestPage.values()).size()); - Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].rpcOption()); + Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].getRpcOption()); assertEquals(MAX_SIZE, size); - String selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[1].rpcOption()); + String selector = + (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[1].getRpcOption()); assertEquals(PAGE_TOKEN, selector); - selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[2].rpcOption()); + selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[2].getRpcOption()); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); - selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[3].rpcOption()); + selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[3].getRpcOption()); assertTrue(selector.contains(Dns.SortingOrder.ASCENDING.selector())); } @@ -338,24 +340,24 @@ public void testListZonesWithOptions() { assertEquals(1, Lists.newArrayList(zonePage.values()).size()); assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), Lists.newArrayList(zonePage.values()).get(0)); - Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].rpcOption()); + Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].getRpcOption()); assertEquals(MAX_SIZE, size); - String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].rpcOption()); + String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].getRpcOption()); assertEquals(PAGE_TOKEN, selector); - selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].rpcOption()); + selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].getRpcOption()); assertTrue(selector.contains(Dns.ZoneField.DESCRIPTION.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); - selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].rpcOption()); + selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].getRpcOption()); assertEquals(DNS_NAME, selector); } @Test public void testListRecordSets() { - EasyMock.expect(dnsRpcMock.listRecordSets(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + EasyMock.expect(dnsRpcMock.listRecordSets(ZONE_INFO.getName(), EMPTY_RPC_OPTIONS)) .andReturn(LIST_OF_PB_DNS_RECORDS); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - Page dnsPage = dns.listRecordSets(ZONE_INFO.name()); + Page dnsPage = dns.listRecordSets(ZONE_INFO.getName()); assertEquals(2, Lists.newArrayList(dnsPage.values()).size()); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD1)); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD2)); @@ -372,18 +374,19 @@ public void testListRecordSetsWithOptions() { assertEquals(2, Lists.newArrayList(dnsPage.values()).size()); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD1)); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD2)); - Integer size = (Integer) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[0].rpcOption()); + Integer size = + (Integer) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[0].getRpcOption()); assertEquals(MAX_SIZE, size); String selector = (String) capturedOptions.getValue() - .get(RECORD_SET_LIST_OPTIONS[1].rpcOption()); + .get(RECORD_SET_LIST_OPTIONS[1].getRpcOption()); assertEquals(PAGE_TOKEN, selector); - selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[2].rpcOption()); + selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[2].getRpcOption()); assertTrue(selector.contains(Dns.RecordSetField.NAME.selector())); assertTrue(selector.contains(Dns.RecordSetField.TTL.selector())); - selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[3].rpcOption()); - assertEquals(RECORD_SET_LIST_OPTIONS[3].value(), selector); + selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[3].getRpcOption()); + assertEquals(RECORD_SET_LIST_OPTIONS[3].getValue(), selector); String type = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[4] - .rpcOption()); - assertEquals(RECORD_SET_LIST_OPTIONS[4].value(), type); + .getRpcOption()); + assertEquals(RECORD_SET_LIST_OPTIONS[4].getValue(), type); } } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsTest.java index 91d46e94262d..b5561235da45 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/DnsTest.java @@ -34,31 +34,31 @@ public void testRecordSetListOption() { // dns name String dnsName = "some name"; Dns.RecordSetListOption recordSetListOption = Dns.RecordSetListOption.dnsName(dnsName); - assertEquals(dnsName, recordSetListOption.value()); - assertEquals(DnsRpc.Option.NAME, recordSetListOption.rpcOption()); + assertEquals(dnsName, recordSetListOption.getValue()); + assertEquals(DnsRpc.Option.NAME, recordSetListOption.getRpcOption()); // page token recordSetListOption = Dns.RecordSetListOption.pageToken(PAGE_TOKEN); - assertEquals(PAGE_TOKEN, recordSetListOption.value()); - assertEquals(DnsRpc.Option.PAGE_TOKEN, recordSetListOption.rpcOption()); + assertEquals(PAGE_TOKEN, recordSetListOption.getValue()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, recordSetListOption.getRpcOption()); // page size recordSetListOption = Dns.RecordSetListOption.pageSize(PAGE_SIZE); - assertEquals(PAGE_SIZE, recordSetListOption.value()); - assertEquals(DnsRpc.Option.PAGE_SIZE, recordSetListOption.rpcOption()); + assertEquals(PAGE_SIZE, recordSetListOption.getValue()); + assertEquals(DnsRpc.Option.PAGE_SIZE, recordSetListOption.getRpcOption()); // record type RecordSet.Type recordType = RecordSet.Type.AAAA; recordSetListOption = Dns.RecordSetListOption.type(recordType); - assertEquals(recordType.name(), recordSetListOption.value()); - assertEquals(DnsRpc.Option.DNS_TYPE, recordSetListOption.rpcOption()); + assertEquals(recordType.name(), recordSetListOption.getValue()); + assertEquals(DnsRpc.Option.DNS_TYPE, recordSetListOption.getRpcOption()); // fields recordSetListOption = Dns.RecordSetListOption.fields(Dns.RecordSetField.NAME, Dns.RecordSetField.TTL); - assertEquals(DnsRpc.Option.FIELDS, recordSetListOption.rpcOption()); - assertTrue(recordSetListOption.value() instanceof String); - assertTrue(((String) recordSetListOption.value()).contains( + assertEquals(DnsRpc.Option.FIELDS, recordSetListOption.getRpcOption()); + assertTrue(recordSetListOption.getValue() instanceof String); + assertTrue(((String) recordSetListOption.getValue()).contains( Dns.RecordSetField.NAME.selector())); - assertTrue(((String) recordSetListOption.value()).contains( + assertTrue(((String) recordSetListOption.getValue()).contains( Dns.RecordSetField.TTL.selector())); - assertTrue(((String) recordSetListOption.value()).contains( + assertTrue(((String) recordSetListOption.getValue()).contains( Dns.RecordSetField.NAME.selector())); } @@ -66,10 +66,10 @@ public void testRecordSetListOption() { public void testZoneOption() { Dns.ZoneOption fields = Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME, Dns.ZoneField.DESCRIPTION); - assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); - assertTrue(fields.value() instanceof String); - assertTrue(((String) fields.value()).contains(Dns.ZoneField.CREATION_TIME.selector())); - assertTrue(((String) fields.value()).contains(Dns.ZoneField.DESCRIPTION.selector())); + assertEquals(DnsRpc.Option.FIELDS, fields.getRpcOption()); + assertTrue(fields.getValue() instanceof String); + assertTrue(((String) fields.getValue()).contains(Dns.ZoneField.CREATION_TIME.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ZoneField.DESCRIPTION.selector())); } @Test @@ -77,33 +77,33 @@ public void testZoneList() { // fields Dns.ZoneListOption fields = Dns.ZoneListOption.fields(Dns.ZoneField.CREATION_TIME, Dns.ZoneField.DESCRIPTION); - assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); - assertTrue(fields.value() instanceof String); - assertTrue(((String) fields.value()).contains(Dns.ZoneField.CREATION_TIME.selector())); - assertTrue(((String) fields.value()).contains(Dns.ZoneField.DESCRIPTION.selector())); - assertTrue(((String) fields.value()).contains(Dns.ZoneField.NAME.selector())); + assertEquals(DnsRpc.Option.FIELDS, fields.getRpcOption()); + assertTrue(fields.getValue() instanceof String); + assertTrue(((String) fields.getValue()).contains(Dns.ZoneField.CREATION_TIME.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ZoneField.DESCRIPTION.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ZoneField.NAME.selector())); // page token Dns.ZoneListOption option = Dns.ZoneListOption.pageToken(PAGE_TOKEN); - assertEquals(PAGE_TOKEN, option.value()); - assertEquals(DnsRpc.Option.PAGE_TOKEN, option.rpcOption()); + assertEquals(PAGE_TOKEN, option.getValue()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, option.getRpcOption()); // page size option = Dns.ZoneListOption.pageSize(PAGE_SIZE); - assertEquals(PAGE_SIZE, option.value()); - assertEquals(DnsRpc.Option.PAGE_SIZE, option.rpcOption()); + assertEquals(PAGE_SIZE, option.getValue()); + assertEquals(DnsRpc.Option.PAGE_SIZE, option.getRpcOption()); // dnsName filter option = Dns.ZoneListOption.dnsName(DNS_NAME); - assertEquals(DNS_NAME, option.value()); - assertEquals(DnsRpc.Option.DNS_NAME, option.rpcOption()); + assertEquals(DNS_NAME, option.getValue()); + assertEquals(DnsRpc.Option.DNS_NAME, option.getRpcOption()); } @Test public void testProjectGetOption() { // fields Dns.ProjectOption fields = Dns.ProjectOption.fields(Dns.ProjectField.QUOTA); - assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); - assertTrue(fields.value() instanceof String); - assertTrue(((String) fields.value()).contains(Dns.ProjectField.QUOTA.selector())); - assertTrue(((String) fields.value()).contains(Dns.ProjectField.PROJECT_ID.selector())); + assertEquals(DnsRpc.Option.FIELDS, fields.getRpcOption()); + assertTrue(fields.getValue() instanceof String); + assertTrue(((String) fields.getValue()).contains(Dns.ProjectField.QUOTA.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ProjectField.PROJECT_ID.selector())); } @Test @@ -111,12 +111,12 @@ public void testChangeRequestOption() { // fields Dns.ChangeRequestOption fields = Dns.ChangeRequestOption.fields( Dns.ChangeRequestField.START_TIME, Dns.ChangeRequestField.STATUS); - assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); - assertTrue(fields.value() instanceof String); - assertTrue(((String) fields.value()).contains( + assertEquals(DnsRpc.Option.FIELDS, fields.getRpcOption()); + assertTrue(fields.getValue() instanceof String); + assertTrue(((String) fields.getValue()).contains( Dns.ChangeRequestField.START_TIME.selector())); - assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.STATUS.selector())); - assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.ID.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ChangeRequestField.ID.selector())); } @Test @@ -124,23 +124,23 @@ public void testChangeRequestListOption() { // fields Dns.ChangeRequestListOption fields = Dns.ChangeRequestListOption.fields( Dns.ChangeRequestField.START_TIME, Dns.ChangeRequestField.STATUS); - assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); - assertTrue(fields.value() instanceof String); - assertTrue(((String) fields.value()).contains( + assertEquals(DnsRpc.Option.FIELDS, fields.getRpcOption()); + assertTrue(fields.getValue() instanceof String); + assertTrue(((String) fields.getValue()).contains( Dns.ChangeRequestField.START_TIME.selector())); - assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.STATUS.selector())); - assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.ID.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(((String) fields.getValue()).contains(Dns.ChangeRequestField.ID.selector())); // page token Dns.ChangeRequestListOption option = Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN); - assertEquals(PAGE_TOKEN, option.value()); - assertEquals(DnsRpc.Option.PAGE_TOKEN, option.rpcOption()); + assertEquals(PAGE_TOKEN, option.getValue()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, option.getRpcOption()); // page size option = Dns.ChangeRequestListOption.pageSize(PAGE_SIZE); - assertEquals(PAGE_SIZE, option.value()); - assertEquals(DnsRpc.Option.PAGE_SIZE, option.rpcOption()); + assertEquals(PAGE_SIZE, option.getValue()); + assertEquals(DnsRpc.Option.PAGE_SIZE, option.getRpcOption()); // sort order option = Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING); - assertEquals(DnsRpc.Option.SORTING_ORDER, option.rpcOption()); - assertEquals(Dns.SortingOrder.ASCENDING.selector(), option.value()); + assertEquals(DnsRpc.Option.SORTING_ORDER, option.getRpcOption()); + assertEquals(Dns.SortingOrder.ASCENDING.selector(), option.getValue()); } } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/OptionTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/OptionTest.java index 1e5be1287ceb..1b92ad65b0b4 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/OptionTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/OptionTest.java @@ -54,11 +54,11 @@ public void testHashCode() { @Test public void testConstructor() { - assertEquals(RPC_OPTION, OPTION.rpcOption()); - assertEquals(VALUE, OPTION.value()); + assertEquals(RPC_OPTION, OPTION.getRpcOption()); + assertEquals(VALUE, OPTION.getValue()); Option option = new Option(RPC_OPTION, null) {}; - assertEquals(RPC_OPTION, option.rpcOption()); - assertNull(option.value()); + assertEquals(RPC_OPTION, option.getRpcOption()); + assertNull(option.getValue()); thrown.expect(NullPointerException.class); new Option(null, VALUE) {}; } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/ProjectInfoTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/ProjectInfoTest.java index 70086250e6dd..1bef06d2d705 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/ProjectInfoTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/ProjectInfoTest.java @@ -29,30 +29,59 @@ public class ProjectInfoTest { private static final String ID = "project-id-123"; private static final BigInteger NUMBER = new BigInteger("123"); private static final ProjectInfo.Quota QUOTA = new ProjectInfo.Quota(1, 2, 3, 4, 5, 6); - private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder() - .id(ID).number(NUMBER).quota(QUOTA).build(); + private static final ProjectInfo PROJECT_INFO = ProjectInfo.newBuilder() + .setId(ID).setNumber(NUMBER).setQuota(QUOTA).build(); @Test public void testBuilder() { - ProjectInfo withId = ProjectInfo.builder().id(ID).build(); + ProjectInfo withId = ProjectInfo.newBuilder().setId(ID).build(); + assertEquals(ID, withId.getId()); + assertNull(withId.getNumber()); + assertNull(withId.getQuota()); + ProjectInfo withNumber = ProjectInfo.newBuilder().setNumber(NUMBER).build(); + assertEquals(NUMBER, withNumber.getNumber()); + assertNull(withNumber.getQuota()); + assertNull(withNumber.getId()); + ProjectInfo withQuota = ProjectInfo.newBuilder().setQuota(QUOTA).build(); + assertEquals(QUOTA, withQuota.getQuota()); + assertNull(withQuota.getId()); + assertNull(withQuota.getNumber()); + assertEquals(QUOTA, PROJECT_INFO.getQuota()); + assertEquals(NUMBER, PROJECT_INFO.getNumber()); + assertEquals(ID, PROJECT_INFO.getId()); + } + + @Test + public void testBuilderDeprecated() { + ProjectInfo withId = ProjectInfo.newBuilder().setId(ID).build(); assertEquals(ID, withId.id()); - assertNull(withId.number()); + assertNull(withId.getNumber()); assertNull(withId.quota()); - ProjectInfo withNumber = ProjectInfo.builder().number(NUMBER).build(); - assertEquals(NUMBER, withNumber.number()); + ProjectInfo withNumber = ProjectInfo.newBuilder().setNumber(NUMBER).build(); + assertEquals(NUMBER, withNumber.getNumber()); assertNull(withNumber.quota()); assertNull(withNumber.id()); - ProjectInfo withQuota = ProjectInfo.builder().quota(QUOTA).build(); + ProjectInfo withQuota = ProjectInfo.newBuilder().setQuota(QUOTA).build(); assertEquals(QUOTA, withQuota.quota()); assertNull(withQuota.id()); - assertNull(withQuota.number()); + assertNull(withQuota.getNumber()); assertEquals(QUOTA, PROJECT_INFO.quota()); - assertEquals(NUMBER, PROJECT_INFO.number()); + assertEquals(NUMBER, PROJECT_INFO.getNumber()); assertEquals(ID, PROJECT_INFO.id()); } @Test public void testQuotaConstructor() { + assertEquals(1, QUOTA.getZones()); + assertEquals(2, QUOTA.getResourceRecordsPerRrset()); + assertEquals(3, QUOTA.getRrsetAdditionsPerChange()); + assertEquals(4, QUOTA.getRrsetDeletionsPerChange()); + assertEquals(5, QUOTA.getRrsetsPerZone()); + assertEquals(6, QUOTA.getTotalRrdataSizePerChange()); + } + + @Test + public void testQuotaConstructorDeprecated() { assertEquals(1, QUOTA.zones()); assertEquals(2, QUOTA.resourceRecordsPerRrset()); assertEquals(3, QUOTA.rrsetAdditionsPerChange()); @@ -78,13 +107,22 @@ public void testSameHashCodeOnEqualsQuota() { @Test public void testEqualsAndNotEquals() { - ProjectInfo clone = ProjectInfo.builder().build(); + ProjectInfo clone = ProjectInfo.newBuilder().build(); assertNotEquals(PROJECT_INFO, clone); - clone = ProjectInfo.builder().id(PROJECT_INFO.id()).number(PROJECT_INFO.number()).build(); + clone = ProjectInfo.newBuilder() + .setId(PROJECT_INFO.getId()) + .setNumber(PROJECT_INFO.getNumber()) + .build(); assertNotEquals(PROJECT_INFO, clone); - clone = ProjectInfo.builder().id(PROJECT_INFO.id()).quota(PROJECT_INFO.quota()).build(); + clone = ProjectInfo.newBuilder() + .setId(PROJECT_INFO.getId()) + .setQuota(PROJECT_INFO.getQuota()) + .build(); assertNotEquals(PROJECT_INFO, clone); - clone = ProjectInfo.builder().number(PROJECT_INFO.number()).quota(PROJECT_INFO.quota()).build(); + clone = ProjectInfo.newBuilder() + .setNumber(PROJECT_INFO.getNumber()) + .setQuota(PROJECT_INFO.getQuota()) + .build(); assertNotEquals(PROJECT_INFO, clone); clone = ProjectInfo.fromPb(PROJECT_INFO.toPb()); assertEquals(PROJECT_INFO, clone); @@ -100,11 +138,11 @@ public void testSameHashCodeOnEquals() { @Test public void testToAndFromPb() { assertEquals(PROJECT_INFO, ProjectInfo.fromPb(PROJECT_INFO.toPb())); - ProjectInfo partial = ProjectInfo.builder().id(ID).build(); + ProjectInfo partial = ProjectInfo.newBuilder().setId(ID).build(); assertEquals(partial, ProjectInfo.fromPb(partial.toPb())); - partial = ProjectInfo.builder().number(NUMBER).build(); + partial = ProjectInfo.newBuilder().setNumber(NUMBER).build(); assertEquals(partial, ProjectInfo.fromPb(partial.toPb())); - partial = ProjectInfo.builder().quota(QUOTA).build(); + partial = ProjectInfo.newBuilder().setQuota(QUOTA).build(); assertEquals(partial, ProjectInfo.fromPb(partial.toPb())); assertNotEquals(PROJECT_INFO, partial); } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/RecordSetTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/RecordSetTest.java index f5c515b6752d..2200e7844302 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/RecordSetTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/RecordSetTest.java @@ -32,12 +32,23 @@ public class RecordSetTest { private static final TimeUnit UNIT = TimeUnit.HOURS; private static final Integer UNIT_TTL = 1; private static final RecordSet.Type TYPE = RecordSet.Type.AAAA; - private static final RecordSet recordSet = RecordSet.builder(NAME, TYPE) + private static final RecordSet RECORD_SET = RecordSet.newBuilder(NAME, TYPE) + .setTtl(UNIT_TTL, UNIT) + .build(); + private static final RecordSet DEPRECATED_RECORD_SET = RecordSet.builder(NAME, TYPE) .ttl(UNIT_TTL, UNIT) .build(); @Test public void testDefaultDnsRecord() { + RecordSet recordSet = RecordSet.newBuilder(NAME, TYPE).build(); + assertEquals(0, recordSet.getRecords().size()); + assertEquals(TYPE, recordSet.getType()); + assertEquals(NAME, recordSet.getName()); + } + + @Test + public void testDefaultDnsRecordDeprecated() { RecordSet recordSet = RecordSet.builder(NAME, TYPE).build(); assertEquals(0, recordSet.records().size()); assertEquals(TYPE, recordSet.type()); @@ -46,14 +57,32 @@ public void testDefaultDnsRecord() { @Test public void testBuilder() { - assertEquals(NAME, recordSet.name()); - assertEquals(TTL, recordSet.ttl()); - assertEquals(TYPE, recordSet.type()); - assertEquals(0, recordSet.records().size()); + assertEquals(NAME, RECORD_SET.getName()); + assertEquals(TTL, RECORD_SET.getTtl()); + assertEquals(TYPE, RECORD_SET.getType()); + assertEquals(0, RECORD_SET.getRecords().size()); // verify that one can add records to the record set String testingRecord = "Testing recordSet"; String anotherTestingRecord = "Another recordSet 123"; - RecordSet anotherRecord = recordSet.toBuilder() + RecordSet anotherRecord = RECORD_SET.toBuilder() + .addRecord(testingRecord) + .addRecord(anotherTestingRecord) + .build(); + assertEquals(2, anotherRecord.getRecords().size()); + assertTrue(anotherRecord.getRecords().contains(testingRecord)); + assertTrue(anotherRecord.getRecords().contains(anotherTestingRecord)); + } + + @Test + public void testBuilderDeprecated() { + assertEquals(NAME, DEPRECATED_RECORD_SET.name()); + assertEquals(TTL, DEPRECATED_RECORD_SET.ttl()); + assertEquals(TYPE, DEPRECATED_RECORD_SET.type()); + assertEquals(0, DEPRECATED_RECORD_SET.records().size()); + // verify that one can add records to the record set + String testingRecord = "Testing recordSet"; + String anotherTestingRecord = "Another recordSet 123"; + RecordSet anotherRecord = RECORD_SET.toBuilder() .addRecord(testingRecord) .addRecord(anotherTestingRecord) .build(); @@ -64,6 +93,26 @@ public void testBuilder() { @Test public void testValidTtl() { + try { + RecordSet.newBuilder(NAME, TYPE).setTtl(-1, TimeUnit.SECONDS); + fail("A negative value is not acceptable for ttl."); + } catch (IllegalArgumentException e) { + // expected + } + RecordSet.newBuilder(NAME, TYPE).setTtl(0, TimeUnit.SECONDS); + RecordSet.newBuilder(NAME, TYPE).setTtl(Integer.MAX_VALUE, TimeUnit.SECONDS); + try { + RecordSet.newBuilder(NAME, TYPE).setTtl(Integer.MAX_VALUE, TimeUnit.HOURS); + fail("This value is too large for int."); + } catch (IllegalArgumentException e) { + // expected + } + RecordSet record = RecordSet.newBuilder(NAME, TYPE).setTtl(UNIT_TTL, UNIT).build(); + assertEquals(TTL, record.getTtl()); + } + + @Test + public void testValidTtlDeprecated() { try { RecordSet.builder(NAME, TYPE).ttl(-1, TimeUnit.SECONDS); fail("A negative value is not acceptable for ttl."); @@ -84,45 +133,45 @@ public void testValidTtl() { @Test public void testEqualsAndNotEquals() { - RecordSet clone = recordSet.toBuilder().build(); - assertEquals(recordSet, clone); - clone = recordSet.toBuilder().addRecord("another recordSet").build(); - assertNotEquals(recordSet, clone); + RecordSet clone = RECORD_SET.toBuilder().build(); + assertEquals(RECORD_SET, clone); + clone = RECORD_SET.toBuilder().addRecord("another recordSet").build(); + assertNotEquals(RECORD_SET, clone); String differentName = "totally different name"; - clone = recordSet.toBuilder().name(differentName).build(); - assertNotEquals(recordSet, clone); - clone = recordSet.toBuilder().ttl(recordSet.ttl() + 1, TimeUnit.SECONDS).build(); - assertNotEquals(recordSet, clone); - clone = recordSet.toBuilder().type(RecordSet.Type.TXT).build(); - assertNotEquals(recordSet, clone); + clone = RECORD_SET.toBuilder().setName(differentName).build(); + assertNotEquals(RECORD_SET, clone); + clone = RECORD_SET.toBuilder().setTtl(RECORD_SET.getTtl() + 1, TimeUnit.SECONDS).build(); + assertNotEquals(RECORD_SET, clone); + clone = RECORD_SET.toBuilder().setType(RecordSet.Type.TXT).build(); + assertNotEquals(RECORD_SET, clone); } @Test public void testSameHashCodeOnEquals() { - int hash = recordSet.hashCode(); - RecordSet clone = recordSet.toBuilder().build(); + int hash = RECORD_SET.hashCode(); + RecordSet clone = RECORD_SET.toBuilder().build(); assertEquals(clone.hashCode(), hash); } @Test public void testToAndFromPb() { - assertEquals(recordSet, RecordSet.fromPb(recordSet.toPb())); - RecordSet partial = RecordSet.builder(NAME, TYPE).build(); + assertEquals(RECORD_SET, RecordSet.fromPb(RECORD_SET.toPb())); + RecordSet partial = RecordSet.newBuilder(NAME, TYPE).build(); assertEquals(partial, RecordSet.fromPb(partial.toPb())); - partial = RecordSet.builder(NAME, TYPE).addRecord("test").build(); + partial = RecordSet.newBuilder(NAME, TYPE).addRecord("test").build(); assertEquals(partial, RecordSet.fromPb(partial.toPb())); - partial = RecordSet.builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build(); + partial = RecordSet.newBuilder(NAME, TYPE).setTtl(15, TimeUnit.SECONDS).build(); assertEquals(partial, RecordSet.fromPb(partial.toPb())); } @Test public void testToBuilder() { - assertEquals(recordSet, recordSet.toBuilder().build()); - RecordSet partial = RecordSet.builder(NAME, TYPE).build(); + assertEquals(RECORD_SET, RECORD_SET.toBuilder().build()); + RecordSet partial = RecordSet.newBuilder(NAME, TYPE).build(); assertEquals(partial, partial.toBuilder().build()); - partial = RecordSet.builder(NAME, TYPE).addRecord("test").build(); + partial = RecordSet.newBuilder(NAME, TYPE).addRecord("test").build(); assertEquals(partial, partial.toBuilder().build()); - partial = RecordSet.builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build(); + partial = RecordSet.newBuilder(NAME, TYPE).setTtl(15, TimeUnit.SECONDS).build(); assertEquals(partial, partial.toBuilder().build()); } @@ -130,10 +179,10 @@ public void testToBuilder() { public void clearRecordSet() { // make sure that we are starting not empty RecordSet clone = - recordSet.toBuilder().addRecord("record").addRecord("another").build(); - assertNotEquals(0, clone.records().size()); + RECORD_SET.toBuilder().addRecord("record").addRecord("another").build(); + assertNotEquals(0, clone.getRecords().size()); clone = clone.toBuilder().clearRecords().build(); - assertEquals(0, clone.records().size()); + assertEquals(0, clone.getRecords().size()); clone.toPb(); // verify that pb allows it } @@ -141,9 +190,9 @@ public void clearRecordSet() { public void removeFromRecordSet() { String recordString = "record"; // make sure that we are starting not empty - RecordSet clone = recordSet.toBuilder().addRecord(recordString).build(); - assertNotEquals(0, clone.records().size()); + RecordSet clone = RECORD_SET.toBuilder().addRecord(recordString).build(); + assertNotEquals(0, clone.getRecords().size()); clone = clone.toBuilder().removeRecord(recordString).build(); - assertEquals(0, clone.records().size()); + assertEquals(0, clone.getRecords().size()); } } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/SerializationTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/SerializationTest.java index 2115c9dd98bf..15af4d07c6a9 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/SerializationTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/SerializationTest.java @@ -22,8 +22,6 @@ import com.google.cloud.RetryParams; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList; - import java.io.Serializable; import java.math.BigInteger; import java.util.concurrent.TimeUnit; @@ -32,18 +30,19 @@ 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) - .generatedId("123333") - .nameServers(ImmutableList.of("server 1", "server 2")) - .nameServerSet("specificationstring") + .setCreationTimeMillis(132L) + .setGeneratedId("123333") + .setNameServers(ImmutableList.of("server 1", "server 2")) + .setNameServerSet("specificationstring") .build(); private static final ZoneInfo PARTIAL_ZONE_INFO = Zone.of("some zone name", "www.example.com", "some descriptions").toBuilder().build(); - private static final ProjectInfo PARTIAL_PROJECT_INFO = ProjectInfo.builder().id("13").build(); - private static final ProjectInfo FULL_PROJECT_INFO = ProjectInfo.builder() - .id("342") - .number(new BigInteger("2343245")) - .quota(new ProjectInfo.Quota(12, 13, 14, 15, 16, 17)) + private static final ProjectInfo PARTIAL_PROJECT_INFO = + ProjectInfo.newBuilder().setId("13").build(); + private static final ProjectInfo FULL_PROJECT_INFO = ProjectInfo.newBuilder() + .setId("342") + .setNumber(new BigInteger("2343245")) + .setQuota(new ProjectInfo.Quota(12, 13, 14, 15, 16, 17)) .build(); private static final Dns.ZoneListOption ZONE_LIST_OPTION = Dns.ZoneListOption.dnsName("www.example.com."); @@ -66,23 +65,24 @@ public class SerializationTest extends BaseSerializationTest { private static final Zone PARTIAL_ZONE = new Zone(DNS, new ZoneInfo.BuilderImpl(PARTIAL_ZONE_INFO)); private static final ChangeRequestInfo CHANGE_REQUEST_INFO_PARTIAL = - ChangeRequest.builder().build(); + ChangeRequest.newBuilder().build(); private static final ChangeRequest CHANGE_REQUEST_PARTIAL = new ChangeRequest(DNS, "name", new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_INFO_PARTIAL)); private static final RecordSet RECORD_SET_PARTIAL = - RecordSet.builder("www.www.com", RecordSet.Type.AAAA).build(); + RecordSet.newBuilder("www.www.com", RecordSet.Type.AAAA).build(); private static final RecordSet RECORD_SET_COMPLETE = - RecordSet.builder("www.sadfa.com", RecordSet.Type.A) - .ttl(12, TimeUnit.HOURS) + RecordSet.newBuilder("www.sadfa.com", RecordSet.Type.A) + .setTtl(12, TimeUnit.HOURS) .addRecord("record") .build(); - private static final ChangeRequestInfo CHANGE_REQUEST_INFO_COMPLETE = ChangeRequestInfo.builder() - .add(RECORD_SET_COMPLETE) - .delete(RECORD_SET_PARTIAL) - .status(ChangeRequest.Status.PENDING) - .generatedId("some id") - .startTimeMillis(132L) - .build(); + private static final ChangeRequestInfo CHANGE_REQUEST_INFO_COMPLETE = + ChangeRequestInfo.newBuilder() + .add(RECORD_SET_COMPLETE) + .delete(RECORD_SET_PARTIAL) + .setStatus(ChangeRequest.Status.PENDING) + .setGeneratedId("some id") + .setStartTime(132L) + .build(); private static final ChangeRequest CHANGE_REQUEST_COMPLETE = new ChangeRequest(DNS, "name", new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_INFO_COMPLETE)); diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneInfoTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneInfoTest.java index 215d377f6a67..7de2cdac1d57 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneInfoTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneInfoTest.java @@ -43,26 +43,40 @@ public class ZoneInfoTest { private static final String NS3 = "name server 3"; 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) - .generatedId(GENERATED_ID) - .nameServerSet(NAME_SERVER_SET) - .nameServers(NAME_SERVERS) + .setCreationTimeMillis(CREATION_TIME_MILLIS) + .setGeneratedId(GENERATED_ID) + .setNameServerSet(NAME_SERVER_SET) + .setNameServers(NAME_SERVERS) .build(); @Test public void testOf() { ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); - assertTrue(partial.nameServers().isEmpty()); - assertEquals(NAME, partial.name()); - assertNull(partial.generatedId()); - assertNull(partial.creationTimeMillis()); - assertNull(partial.nameServerSet()); - assertEquals(DESCRIPTION, partial.description()); - assertEquals(DNS_NAME, partial.dnsName()); + assertTrue(partial.getNameServers().isEmpty()); + assertEquals(NAME, partial.getName()); + assertNull(partial.getGeneratedId()); + assertNull(partial.getCreationTimeMillis()); + assertNull(partial.getNameServerSet()); + assertEquals(DESCRIPTION, partial.getDescription()); + assertEquals(DNS_NAME, partial.getDnsName()); } @Test public void testBuilder() { + assertEquals(3, INFO.getNameServers().size()); + assertEquals(NS1, INFO.getNameServers().get(0)); + assertEquals(NS2, INFO.getNameServers().get(1)); + assertEquals(NS3, INFO.getNameServers().get(2)); + assertEquals(NAME, INFO.getName()); + assertEquals(GENERATED_ID, INFO.getGeneratedId()); + assertEquals(CREATION_TIME_MILLIS, INFO.getCreationTimeMillis()); + assertEquals(NAME_SERVER_SET, INFO.getNameServerSet()); + assertEquals(DESCRIPTION, INFO.getDescription()); + assertEquals(DNS_NAME, INFO.getDnsName()); + } + + @Test + public void testBuilderDeprecated() { assertEquals(3, INFO.nameServers().size()); assertEquals(NS1, INFO.nameServers().get(0)); assertEquals(NS2, INFO.nameServers().get(1)); @@ -81,20 +95,20 @@ public void testEqualsAndNotEquals() { assertEquals(INFO, clone); List moreServers = Lists.newLinkedList(NAME_SERVERS); moreServers.add(NS1); - clone = INFO.toBuilder().nameServers(moreServers).build(); + clone = INFO.toBuilder().setNameServers(moreServers).build(); assertNotEquals(INFO, clone); String differentName = "totally different name"; - clone = INFO.toBuilder().name(differentName).build(); + clone = INFO.toBuilder().setName(differentName).build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().creationTimeMillis(INFO.creationTimeMillis() + 1).build(); + clone = INFO.toBuilder().setCreationTimeMillis(INFO.getCreationTimeMillis() + 1).build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().description(INFO.description() + "aaaa").build(); + clone = INFO.toBuilder().setDescription(INFO.getDescription() + "aaaa").build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().dnsName(differentName).build(); + clone = INFO.toBuilder().setDnsName(differentName).build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().generatedId(INFO.generatedId() + "1111").build(); + clone = INFO.toBuilder().setGeneratedId(INFO.getGeneratedId() + "1111").build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().nameServerSet(INFO.nameServerSet() + "salt").build(); + clone = INFO.toBuilder().setNameServerSet(INFO.getNameServerSet() + "salt").build(); assertNotEquals(INFO, clone); } @@ -111,17 +125,17 @@ public void testToBuilder() { ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertEquals(partial, partial.toBuilder().build()); partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() - .generatedId(GENERATED_ID) + .setGeneratedId(GENERATED_ID) .build(); assertEquals(partial, partial.toBuilder().build()); partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() - .creationTimeMillis(CREATION_TIME_MILLIS).build(); + .setCreationTimeMillis(CREATION_TIME_MILLIS).build(); assertEquals(partial, partial.toBuilder().build()); List nameServers = new LinkedList<>(); nameServers.add(NS1); - partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServers(nameServers).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().setNameServers(nameServers).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServerSet(NAME_SERVER_SET) + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().setNameServerSet(NAME_SERVER_SET) .build(); assertEquals(partial, partial.toBuilder().build()); } @@ -132,25 +146,25 @@ public void testToAndFromPb() { ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() - .generatedId(GENERATED_ID) + .setGeneratedId(GENERATED_ID) .build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() - .creationTimeMillis(CREATION_TIME_MILLIS).build(); + .setCreationTimeMillis(CREATION_TIME_MILLIS).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); List nameServers = new LinkedList<>(); nameServers.add(NS1); - partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServers(nameServers).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().setNameServers(nameServers).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServerSet(NAME_SERVER_SET) + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().setNameServerSet(NAME_SERVER_SET) .build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); } @Test public void testEmptyNameServers() { - ZoneInfo clone = INFO.toBuilder().nameServers(new LinkedList()).build(); - assertTrue(clone.nameServers().isEmpty()); + ZoneInfo clone = INFO.toBuilder().setNameServers(new LinkedList()).build(); + assertTrue(clone.getNameServers().isEmpty()); clone.toPb(); // test that this is allowed } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneTest.java index aefc716bf46a..05846d120fd6 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/ZoneTest.java @@ -45,12 +45,12 @@ public class ZoneTest { private static final String ZONE_ID = "123"; private static final ZoneInfo ZONE_INFO = Zone.of(ZONE_NAME, "example.com", "description") .toBuilder() - .generatedId(ZONE_ID) - .creationTimeMillis(123478946464L) + .setGeneratedId(ZONE_ID) + .setCreationTimeMillis(123478946464L) .build(); private static final ZoneInfo NO_ID_INFO = ZoneInfo.of(ZONE_NAME, "another-example.com", "description").toBuilder() - .creationTimeMillis(893123464L) + .setCreationTimeMillis(893123464L) .build(); private static final Dns.ZoneOption ZONE_FIELD_OPTIONS = Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME); @@ -61,9 +61,9 @@ 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().generatedId("someid").build(); + ChangeRequestInfo.newBuilder().setGeneratedId("someid").build(); private static final ChangeRequestInfo CHANGE_REQUEST_NO_ID = - ChangeRequestInfo.builder().build(); + ChangeRequestInfo.newBuilder().build(); private static final DnsException EXCEPTION = new DnsException(-1, "message", null); private static final DnsOptions OPTIONS = createStrictMock(DnsOptions.class); @@ -80,7 +80,7 @@ public void setUp() throws Exception { zone = new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)); zoneNoId = new Zone(dns, new ZoneInfo.BuilderImpl(NO_ID_INFO)); changeRequestAfter = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( - CHANGE_REQUEST.toBuilder().startTimeMillis(123465L).build())); + CHANGE_REQUEST.toBuilder().setStartTime(123465L).build())); reset(dns); } @@ -91,6 +91,14 @@ public void tearDown() throws Exception { @Test public void testConstructor() { + replay(dns); + assertEquals(ZONE_INFO.toPb(), zone.toPb()); + assertNotNull(zone.getDns()); + assertEquals(dns, zone.getDns()); + } + + @Test + public void testConstructorDeprecated() { replay(dns); assertEquals(ZONE_INFO.toPb(), zone.toPb()); assertNotNull(zone.dns()); @@ -175,10 +183,10 @@ public void reloadByNameAndFound() { expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone); replay(dns); Zone result = zoneNoId.reload(); - assertSame(zone.dns(), result.dns()); + assertSame(zone.getDns(), result.getDns()); assertEquals(zone, result); result = zone.reload(); - assertSame(zone.dns(), result.dns()); + assertSame(zone.getDns(), result.getDns()); assertEquals(zone, result); zoneNoId.reload(ZONE_FIELD_OPTIONS); // check options zone.reload(ZONE_FIELD_OPTIONS); // check options @@ -287,52 +295,52 @@ public void applyNullChangeRequest() { @Test public void getChangeAndZoneFoundByName() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId())) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.getGeneratedId())) .andReturn(changeRequestAfter).times(2); // again for options - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId(), + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS)).andReturn(changeRequestAfter).times(2); replay(dns); - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId()); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.getGeneratedId()); assertEquals(changeRequestAfter, result); - result = zone.getChangeRequest(CHANGE_REQUEST.generatedId()); + result = zone.getChangeRequest(CHANGE_REQUEST.getGeneratedId()); assertEquals(changeRequestAfter, result); // check options - result = zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); + result = zoneNoId.getChangeRequest(CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(changeRequestAfter, result); - result = zone.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); + result = zone.getChangeRequest(CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(changeRequestAfter, result); } @Test public void getChangeAndZoneNotFoundByName() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId())).andThrow(EXCEPTION) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.getGeneratedId())).andThrow(EXCEPTION) .times(2); // again for options - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId(), + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS)).andThrow(EXCEPTION).times(2); replay(dns); try { - zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId()); + zoneNoId.getChangeRequest(CHANGE_REQUEST.getGeneratedId()); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST.generatedId()); + zone.getChangeRequest(CHANGE_REQUEST.getGeneratedId()); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } // check options try { - zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); + zoneNoId.getChangeRequest(CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); + zone.getChangeRequest(CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected @@ -341,16 +349,18 @@ public void getChangeAndZoneNotFoundByName() { @Test public void getChangedWhichDoesNotExistZoneFound() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId())).andReturn(null).times(2); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.getGeneratedId())) + .andReturn(null).times(2); // again for options - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.generatedId(), + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS)).andReturn(null).times(2); replay(dns); - 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)); + assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.getGeneratedId())); + assertNull(zone.getChangeRequest(CHANGE_REQUEST.getGeneratedId())); + assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.getGeneratedId(), + CHANGE_REQUEST_FIELD_OPTIONS)); + assertNull(zone.getChangeRequest(CHANGE_REQUEST.getGeneratedId(), + CHANGE_REQUEST_FIELD_OPTIONS)); } @Test @@ -386,25 +396,26 @@ public void getNullChangeRequest() { public void getChangeRequestWithNoId() { replay(dns); // no calls expected try { - zone.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId()); + zone.getChangeRequest(CHANGE_REQUEST_NO_ID.getGeneratedId()); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); + zone.getChangeRequest(CHANGE_REQUEST_NO_ID.getGeneratedId(), CHANGE_REQUEST_FIELD_OPTIONS); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId()); + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.getGeneratedId()); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS); + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.getGeneratedId(), + CHANGE_REQUEST_FIELD_OPTIONS); fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected @@ -484,18 +495,42 @@ public void testBuilder() { expect(dns.options()).andReturn(OPTIONS).times(8); replay(dns); assertNotEquals(zone, zone.toBuilder() - .generatedId(new BigInteger(zone.generatedId()).add(BigInteger.ONE).toString()) + .setGeneratedId(new BigInteger(zone.getGeneratedId()).add(BigInteger.ONE).toString()) + .build()); + assertNotEquals(zone, zone.toBuilder().setDnsName(zone.getName() + "aaaa").build()); + assertNotEquals(zone, + zone.toBuilder().setNameServerSet(zone.getNameServerSet() + "aaaa").build()); + assertNotEquals(zone, + zone.toBuilder().setNameServers(ImmutableList.of("nameserverpppp")).build()); + assertNotEquals(zone, zone.toBuilder().setDnsName(zone.getDnsName() + "aaaa").build()); + assertNotEquals(zone, zone.toBuilder().setCreationTimeMillis(zone.getCreationTimeMillis() + 1) + .build()); + Zone.Builder builder = zone.toBuilder(); + builder.setGeneratedId(ZONE_ID) + .setDnsName("example.com") + .setCreationTimeMillis(123478946464L) + .build(); + assertEquals(zone, builder.build()); + } + + @Test + public void testBuilderDeprecated() { + // one for each build() call because it invokes a constructor + expect(dns.options()).andReturn(OPTIONS).times(8); + replay(dns); + assertNotEquals(zone, zone.toBuilder() + .setGeneratedId(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()); - assertNotEquals(zone, zone.toBuilder().nameServers(ImmutableList.of("nameserverpppp")).build()); + assertNotEquals(zone, zone.toBuilder().setNameServerSet(zone.nameServerSet() + "aaaa").build()); + assertNotEquals(zone, zone.toBuilder().setNameServers(ImmutableList.of("nameserverpppp")).build()); assertNotEquals(zone, zone.toBuilder().dnsName(zone.dnsName() + "aaaa").build()); - assertNotEquals(zone, zone.toBuilder().creationTimeMillis(zone.creationTimeMillis() + 1) + assertNotEquals(zone, zone.toBuilder().setCreationTimeMillis(zone.creationTimeMillis() + 1) .build()); Zone.Builder builder = zone.toBuilder(); - builder.generatedId(ZONE_ID) + builder.setGeneratedId(ZONE_ID) .dnsName("example.com") - .creationTimeMillis(123478946464L) + .setCreationTimeMillis(123478946464L) .build(); assertEquals(zone, builder.build()); } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/it/ITDnsTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/it/ITDnsTest.java index 68e3bcfa0678..f3dabf2fdfcb 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/it/ITDnsTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/it/ITDnsTest.java @@ -75,20 +75,20 @@ public class ITDnsTest { private static final ZoneInfo ZONE_DNS_NO_PERIOD = ZoneInfo.of(ZONE_NAME1, ZONE_DNS_NAME_NO_PERIOD, ZONE_DESCRIPTION1); private static final RecordSet A_RECORD_ZONE1 = - RecordSet.builder("www." + ZONE1.dnsName(), RecordSet.Type.A) - .records(ImmutableList.of("123.123.55.1")) - .ttl(25, TimeUnit.SECONDS) + RecordSet.newBuilder("www." + ZONE1.getDnsName(), RecordSet.Type.A) + .setRecords(ImmutableList.of("123.123.55.1")) + .setTtl(25, TimeUnit.SECONDS) .build(); private static final RecordSet AAAA_RECORD_ZONE1 = - RecordSet.builder("www." + ZONE1.dnsName(), RecordSet.Type.AAAA) - .records(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) - .ttl(25, TimeUnit.SECONDS) + RecordSet.newBuilder("www." + ZONE1.getDnsName(), RecordSet.Type.AAAA) + .setRecords(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) + .setTtl(25, TimeUnit.SECONDS) .build(); - private static final ChangeRequestInfo CHANGE_ADD_ZONE1 = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_ADD_ZONE1 = ChangeRequest.newBuilder() .add(A_RECORD_ZONE1) .add(AAAA_RECORD_ZONE1) .build(); - private static final ChangeRequestInfo CHANGE_DELETE_ZONE1 = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_DELETE_ZONE1 = ChangeRequest.newBuilder() .delete(A_RECORD_ZONE1) .delete(AAAA_RECORD_ZONE1) .build(); @@ -107,20 +107,21 @@ 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().generatedId()); + waitForChangeToComplete(zoneName, iterator.next().getGeneratedId()); } Iterator recordSetIterator = zone.listRecordSets().iterateAll(); List toDelete = new LinkedList<>(); while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - if (!ImmutableList.of(RecordSet.Type.NS, RecordSet.Type.SOA).contains(recordSet.type())) { + if (!ImmutableList.of(RecordSet.Type.NS, RecordSet.Type.SOA).contains( + recordSet.getType())) { toDelete.add(recordSet); } } if (!toDelete.isEmpty()) { ChangeRequest deletion = - zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); - waitForChangeToComplete(zone.name(), deletion.generatedId()); + zone.applyChangeRequest(ChangeRequest.newBuilder().setDeletions(toDelete).build()); + waitForChangeToComplete(zone.getName(), deletion.getGeneratedId()); } zone.delete(); } @@ -131,7 +132,7 @@ private static List filter(Iterator iterator) { List result = new LinkedList<>(); while (iterator.hasNext()) { Zone zone = iterator.next(); - if (ZONE_NAMES.contains(zone.name())) { + if (ZONE_NAMES.contains(zone.getName())) { result.add(zone); } } @@ -149,10 +150,10 @@ public static void after() { } private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRequest actual) { - assertEquals(expected.additions(), actual.additions()); - assertEquals(expected.deletions(), actual.deletions()); - assertEquals(expected.generatedId(), actual.generatedId()); - assertEquals(expected.startTimeMillis(), actual.startTimeMillis()); + assertEquals(expected.getAdditions(), actual.getAdditions()); + assertEquals(expected.getDeletions(), actual.getDeletions()); + assertEquals(expected.getGeneratedId(), actual.getGeneratedId()); + assertEquals(expected.getStartTimeMillis(), actual.getStartTimeMillis()); } private static void waitForChangeToComplete(String zoneName, String changeId) { @@ -175,28 +176,28 @@ private static void waitForChangeToComplete(ChangeRequest changeRequest) { public void testCreateValidZone() { try { Zone created = DNS.create(ZONE1); - assertEquals(ZONE1.description(), created.description()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertEquals(ZONE1.name(), created.name()); - assertNotNull(created.creationTimeMillis()); - assertNotNull(created.nameServers()); - assertNull(created.nameServerSet()); - assertNotNull(created.generatedId()); - Zone retrieved = DNS.getZone(ZONE1.name()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertEquals(ZONE1.getDnsName(), created.getDnsName()); + assertEquals(ZONE1.getName(), created.getName()); + assertNotNull(created.getCreationTimeMillis()); + assertNotNull(created.getNameServers()); + assertNull(created.getNameServerSet()); + assertNotNull(created.getGeneratedId()); + Zone retrieved = DNS.getZone(ZONE1.getName()); assertEquals(created, retrieved); created = DNS.create(ZONE_EMPTY_DESCRIPTION); - assertEquals(ZONE_EMPTY_DESCRIPTION.description(), created.description()); - assertEquals(ZONE_EMPTY_DESCRIPTION.dnsName(), created.dnsName()); - assertEquals(ZONE_EMPTY_DESCRIPTION.name(), created.name()); - assertNotNull(created.creationTimeMillis()); - assertNotNull(created.nameServers()); - assertNull(created.nameServerSet()); - assertNotNull(created.generatedId()); - retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.name()); + assertEquals(ZONE_EMPTY_DESCRIPTION.getDescription(), created.getDescription()); + assertEquals(ZONE_EMPTY_DESCRIPTION.getDnsName(), created.getDnsName()); + assertEquals(ZONE_EMPTY_DESCRIPTION.getName(), created.getName()); + assertNotNull(created.getCreationTimeMillis()); + assertNotNull(created.getNameServers()); + assertNull(created.getNameServerSet()); + assertNotNull(created.getGeneratedId()); + retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.getName()); assertEquals(created, retrieved); } finally { - DNS.delete(ZONE1.name()); - DNS.delete(ZONE_EMPTY_DESCRIPTION.name()); + DNS.delete(ZONE1.getName()); + DNS.delete(ZONE_EMPTY_DESCRIPTION.getName()); } } @@ -218,8 +219,8 @@ public void testCreateZoneWithErrors() { assertFalse(ex.retryable()); } } finally { - DNS.delete(ZONE_NAME_ERROR.name()); - DNS.delete(ZONE_DNS_NO_PERIOD.name()); + DNS.delete(ZONE_NAME_ERROR.getName()); + DNS.delete(ZONE_DNS_NO_PERIOD.getName()); } } @@ -227,80 +228,80 @@ public void testCreateZoneWithErrors() { public void testCreateZoneWithOptions() { try { Zone created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.CREATION_TIME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNotNull(created.getCreationTimeMillis()); + assertNull(created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.DNS_NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDnsName(), created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME_SERVER_SET)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); // we did not set it + assertNull(created.getGeneratedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME_SERVERS)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.ZONE_ID)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertNotNull(created.getNameServers()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNotNull(created.getGeneratedId()); created.delete(); // combination of multiple things created = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.ZONE_ID, ZoneField.NAME_SERVERS, ZoneField.NAME_SERVER_SET, ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); // we did not set it + assertNotNull(created.getGeneratedId()); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } @@ -308,74 +309,74 @@ public void testCreateZoneWithOptions() { public void testGetZone() { try { DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); - Zone created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.CREATION_TIME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.DNS_NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.NAME_SERVER_SET)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.generatedId()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.NAME_SERVERS)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.ZONE_ID)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.generatedId()); + Zone created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.CREATION_TIME)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNotNull(created.getCreationTimeMillis()); + assertNull(created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.DESCRIPTION)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.DNS_NAME)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDnsName(), created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.NAME)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.NAME_SERVER_SET)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); // we did not set it + assertNull(created.getGeneratedId()); + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.NAME_SERVERS)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.ZONE_ID)); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertNotNull(created.getNameServers()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNotNull(created.getGeneratedId()); // combination of multiple things - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.ZONE_ID, + created = DNS.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.ZONE_ID, ZoneField.NAME_SERVERS, ZoneField.NAME_SERVER_SET, ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); // we did not set it + assertNotNull(created.getGeneratedId()); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } @@ -423,74 +424,74 @@ public void testListZones() { assertFalse(ex.retryable()); } // ok name - zones = filter(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName())).iterateAll()); + zones = filter(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName())).iterateAll()); assertEquals(1, zones.size()); // field options - Iterator zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Iterator zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.ZONE_ID)).iterateAll(); Zone zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNotNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNotNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); - zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.CREATION_TIME)).iterateAll(); zone = zoneIterator.next(); - assertNotNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNotNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); - zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.DNS_NAME)).iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNotNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNotNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); - zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.DESCRIPTION)).iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNotNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); - zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.NAME_SERVERS)).iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertFalse(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertFalse(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); - zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.NAME_SERVER_SET)).iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); // we cannot set it using google-cloud - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); // we cannot set it using google-cloud + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); // several combined zones = filter(DNS.listZones(Dns.ZoneListOption.fields(ZoneField.ZONE_ID, @@ -498,17 +499,17 @@ public void testListZones() { Dns.ZoneListOption.pageSize(1)).iterateAll()); assertEquals(2, zones.size()); for (Zone current : zones) { - assertNull(current.creationTimeMillis()); - assertNotNull(current.name()); - assertNull(current.dnsName()); - assertNotNull(current.description()); - assertNull(current.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNotNull(current.generatedId()); + assertNull(current.getCreationTimeMillis()); + assertNotNull(current.getName()); + assertNull(current.getDnsName()); + assertNotNull(current.getDescription()); + assertNull(current.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNotNull(current.getGeneratedId()); } } finally { - DNS.delete(ZONE1.name()); - DNS.delete(ZONE_EMPTY_DESCRIPTION.name()); + DNS.delete(ZONE1.getName()); + DNS.delete(ZONE_EMPTY_DESCRIPTION.getName()); } } @@ -516,11 +517,11 @@ public void testListZones() { public void testDeleteZone() { try { Zone created = DNS.create(ZONE1); - assertEquals(created, DNS.getZone(ZONE1.name())); - DNS.delete(ZONE1.name()); - assertNull(DNS.getZone(ZONE1.name())); + assertEquals(created, DNS.getZone(ZONE1.getName())); + DNS.delete(ZONE1.getName()); + assertNull(DNS.getZone(ZONE1.getName())); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } @@ -528,64 +529,64 @@ public void testDeleteZone() { public void testCreateChange() { try { DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); - ChangeRequest created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + ChangeRequest created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); + assertEquals(CHANGE_ADD_ZONE1.getAdditions(), created.getAdditions()); + assertNotNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) .contains(created.status())); - assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); + assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.getName(), "1")); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); // with options - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.ID)); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertTrue(created.getAdditions().isEmpty()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.STATUS)); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertTrue(created.getAdditions().isEmpty()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNotNull(created.status()); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.START_TIME)); - assertTrue(created.additions().isEmpty()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertTrue(created.getAdditions().isEmpty()); + assertNotNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.ADDITIONS)); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertEquals(CHANGE_ADD_ZONE1.getAdditions(), created.getAdditions()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); // finishes with delete otherwise we cannot delete the zone waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.DELETIONS)); waitForChangeToComplete(created); - assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); - assertNull(created.startTimeMillis()); - assertTrue(created.additions().isEmpty()); - assertNotNull(created.generatedId()); + assertEquals(CHANGE_DELETE_ZONE1.getDeletions(), created.getDeletions()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getAdditions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); waitForChangeToComplete(created); } finally { @@ -597,12 +598,12 @@ public void testCreateChange() { public void testInvalidChangeRequest() { Zone zone = DNS.create(ZONE1); RecordSet validA = - RecordSet.builder("subdomain." + zone.dnsName(), RecordSet.Type.A) - .records(ImmutableList.of("0.255.1.5")) + RecordSet.newBuilder("subdomain." + zone.getDnsName(), RecordSet.Type.A) + .setRecords(ImmutableList.of("0.255.1.5")) .build(); boolean recordAdded = false; try { - ChangeRequestInfo validChange = ChangeRequest.builder().add(validA).build(); + ChangeRequestInfo validChange = ChangeRequest.newBuilder().add(validA).build(); zone.applyChangeRequest(validChange); recordAdded = true; try { @@ -614,8 +615,8 @@ public void testInvalidChangeRequest() { assertEquals(409, ex.code()); } // delete with field mismatch - RecordSet mismatch = validA.toBuilder().ttl(20, TimeUnit.SECONDS).build(); - ChangeRequestInfo deletion = ChangeRequest.builder().delete(mismatch).build(); + RecordSet mismatch = validA.toBuilder().setTtl(20, TimeUnit.SECONDS).build(); + ChangeRequestInfo deletion = ChangeRequest.newBuilder().delete(mismatch).build(); try { zone.applyChangeRequest(deletion); fail("Deleted a record set without a complete match."); @@ -630,16 +631,16 @@ public void testInvalidChangeRequest() { LinkedList additions = new LinkedList<>(); while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - if (recordSet.type() == RecordSet.Type.SOA) { + if (recordSet.getType() == RecordSet.Type.SOA) { deletions.add(recordSet); // the subdomain is necessary to get 400 instead of 412 - RecordSet copy = recordSet.toBuilder().name("x." + recordSet.name()).build(); + RecordSet copy = recordSet.toBuilder().setName("x." + recordSet.getName()).build(); additions.add(copy); break; } } - deletion = deletion.toBuilder().deletions(deletions).build(); - ChangeRequestInfo addition = ChangeRequest.builder().additions(additions).build(); + deletion = deletion.toBuilder().setDeletions(deletions).build(); + ChangeRequestInfo addition = ChangeRequest.newBuilder().setAdditions(additions).build(); try { zone.applyChangeRequest(deletion); fail("Deleted SOA."); @@ -658,9 +659,9 @@ public void testInvalidChangeRequest() { } } finally { if (recordAdded) { - ChangeRequestInfo deletion = ChangeRequest.builder().delete(validA).build(); + ChangeRequestInfo deletion = ChangeRequest.newBuilder().delete(validA).build(); ChangeRequest request = zone.applyChangeRequest(deletion); - waitForChangeToComplete(zone.name(), request.generatedId()); + waitForChangeToComplete(zone.getName(), request.getGeneratedId()); } zone.delete(); } @@ -671,7 +672,7 @@ public void testListChanges() { try { // no such zone exists try { - DNS.listChangeRequests(ZONE1.name()); + DNS.listChangeRequests(ZONE1.getName()); fail(); } catch (DnsException ex) { // expected @@ -681,22 +682,22 @@ public void testListChanges() { // zone exists but has no changes DNS.create(ZONE1); ImmutableList changes = ImmutableList.copyOf( - DNS.listChangeRequests(ZONE1.name()).iterateAll()); + DNS.listChangeRequests(ZONE1.getName()).iterateAll()); 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.generatedId()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); + ChangeRequest change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName()).iterateAll()); assertEquals(5, changes.size()); // error in options try { - DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(0)); + DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.pageSize(0)); fail(); } catch (DnsException ex) { // expected @@ -704,7 +705,7 @@ public void testListChanges() { assertFalse(ex.retryable()); } try { - DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(-1)); + DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.pageSize(-1)); fail(); } catch (DnsException ex) { // expected @@ -713,10 +714,10 @@ public void testListChanges() { } // sorting order ImmutableList ascending = ImmutableList.copyOf(DNS.listChangeRequests( - ZONE1.name(), + ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)).iterateAll()); ImmutableList descending = ImmutableList.copyOf(DNS.listChangeRequests( - ZONE1.name(), + ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)).iterateAll()); int size = 5; assertEquals(size, descending.size()); @@ -725,50 +726,50 @@ public void testListChanges() { assertEquals(descending.get(i), ascending.get(size - i - 1)); } // field options - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.ADDITIONS)).iterateAll()); change = changes.get(1); - assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertEquals(CHANGE_ADD_ZONE1.getAdditions(), change.getAdditions()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.DELETIONS)).iterateAll()); change = changes.get(2); - assertTrue(change.additions().isEmpty()); - assertNotNull(change.deletions()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertNotNull(change.getDeletions()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.ID)).iterateAll()); change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.START_TIME)).iterateAll()); change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNotNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNotNull(change.getStartTimeMillis()); assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.STATUS)).iterateAll()); change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertEquals(ChangeRequest.Status.DONE, change.status()); } finally { clear(); @@ -780,45 +781,45 @@ public void testGetChange() { try { Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.generatedId()); + ChangeRequest retrieved = DNS.getChangeRequest(zone.getName(), created.getGeneratedId()); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); // with options created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.ID)); - retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), + retrieved = DNS.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.ID)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.STATUS)); - retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), + retrieved = DNS.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.STATUS)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.START_TIME)); - retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), + retrieved = DNS.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.START_TIME)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.ADDITIONS)); - retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), + retrieved = DNS.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.ADDITIONS)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); // finishes with delete otherwise we cannot delete the zone created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.DELETIONS)); - retrieved = DNS.getChangeRequest(zone.name(), created.generatedId(), + retrieved = DNS.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.DELETIONS)); assertEqChangesIgnoreStatus(created, retrieved); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); } finally { clear(); } @@ -828,17 +829,17 @@ public void testGetChange() { public void testGetProject() { // fetches all fields ProjectInfo project = DNS.getProject(); - assertNotNull(project.quota()); + assertNotNull(project.getQuota()); // options project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.QUOTA)); - assertNotNull(project.quota()); + assertNotNull(project.getQuota()); project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_ID)); - assertNull(project.quota()); + assertNull(project.getQuota()); project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER)); - assertNull(project.quota()); + assertNull(project.getQuota()); project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER, ProjectField.QUOTA, ProjectField.PROJECT_ID)); - assertNotNull(project.quota()); + assertNotNull(project.getQuota()); } @Test @@ -846,87 +847,87 @@ public void testListDnsRecords() { try { Zone zone = DNS.create(ZONE1); ImmutableList recordSets = ImmutableList.copyOf( - DNS.listRecordSets(zone.name()).iterateAll()); + DNS.listRecordSets(zone.getName()).iterateAll()); assertEquals(2, recordSets.size()); ImmutableList defaultRecords = ImmutableList.of(RecordSet.Type.NS, RecordSet.Type.SOA); for (RecordSet recordSet : recordSets) { - assertTrue(defaultRecords.contains(recordSet.type())); + assertTrue(defaultRecords.contains(recordSet.getType())); } // field options - Iterator recordSetIterator = DNS.listRecordSets(zone.name(), + Iterator recordSetIterator = DNS.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.TTL)).iterateAll(); int counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).ttl(), recordSet.ttl()); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertTrue(recordSet.records().isEmpty()); + assertEquals(recordSets.get(counter).getTtl(), recordSet.getTtl()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertTrue(recordSet.getRecords().isEmpty()); counter++; } assertEquals(2, counter); - recordSetIterator = DNS.listRecordSets(zone.name(), + recordSetIterator = DNS.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.NAME)).iterateAll(); counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertTrue(recordSet.records().isEmpty()); - assertNull(recordSet.ttl()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertTrue(recordSet.getRecords().isEmpty()); + assertNull(recordSet.getTtl()); counter++; } assertEquals(2, counter); - recordSetIterator = DNS.listRecordSets(zone.name(), + recordSetIterator = DNS.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.DNS_RECORDS)) .iterateAll(); counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).records(), recordSet.records()); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertNull(recordSet.ttl()); + assertEquals(recordSets.get(counter).getRecords(), recordSet.getRecords()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertNull(recordSet.getTtl()); counter++; } assertEquals(2, counter); - recordSetIterator = DNS.listRecordSets(zone.name(), + recordSetIterator = DNS.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.TYPE), Dns.RecordSetListOption.pageSize(1)).iterateAll(); // also test paging counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertTrue(recordSet.records().isEmpty()); - assertNull(recordSet.ttl()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertTrue(recordSet.getRecords().isEmpty()); + assertNull(recordSet.getTtl()); counter++; } assertEquals(2, counter); // test page size - Page recordSetPage = DNS.listRecordSets(zone.name(), + Page recordSetPage = DNS.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.TYPE), Dns.RecordSetListOption.pageSize(1)); assertEquals(1, ImmutableList.copyOf(recordSetPage.values().iterator()).size()); // test name filter - ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); - recordSetIterator = DNS.listRecordSets(ZONE1.name(), - Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); + ChangeRequest change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + recordSetIterator = DNS.listRecordSets(ZONE1.getName(), + Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.getName())).iterateAll(); counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) - .contains(recordSet.type())); + assertTrue(ImmutableList.of(A_RECORD_ZONE1.getType(), AAAA_RECORD_ZONE1.getType()) + .contains(recordSet.getType())); counter++; } assertEquals(2, counter); // test type filter - waitForChangeToComplete(ZONE1.name(), change.generatedId()); - recordSetIterator = DNS.listRecordSets(ZONE1.name(), - Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name()), - Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())).iterateAll(); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + recordSetIterator = DNS.listRecordSets(ZONE1.getName(), + Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.getName()), + Dns.RecordSetListOption.type(A_RECORD_ZONE1.getType())).iterateAll(); counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); @@ -938,8 +939,8 @@ public void testListDnsRecords() { // check wrong arguments try { // name is not set - DNS.listRecordSets(ZONE1.name(), - Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())); + DNS.listRecordSets(ZONE1.getName(), + Dns.RecordSetListOption.type(A_RECORD_ZONE1.getType())); fail(); } catch (DnsException ex) { // expected @@ -947,7 +948,7 @@ public void testListDnsRecords() { assertFalse(ex.retryable()); } try { - DNS.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.pageSize(0)); + DNS.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.pageSize(0)); fail(); } catch (DnsException ex) { // expected @@ -955,14 +956,14 @@ public void testListDnsRecords() { assertFalse(ex.retryable()); } try { - DNS.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.pageSize(-1)); + DNS.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.pageSize(-1)); fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); assertFalse(ex.retryable()); } - waitForChangeToComplete(ZONE1.name(), change.generatedId()); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); } finally { clear(); } @@ -994,24 +995,24 @@ public void testListZonesBatch() { DnsBatchResult> okSize = batch.listZones(Dns.ZoneListOption.pageSize(1)); DnsBatchResult> nameError = batch.listZones(Dns.ZoneListOption.dnsName("aaaaa")); DnsBatchResult> okName = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName())); + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName())); DnsBatchResult> idResult = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.ZONE_ID)); DnsBatchResult> timeResult = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.CREATION_TIME)); DnsBatchResult> dnsNameResult = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.DNS_NAME)); DnsBatchResult> descriptionResult = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.DESCRIPTION)); DnsBatchResult> nameServersResult = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.NAME_SERVERS)); DnsBatchResult> nameServerSetResult = - batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + batch.listZones(Dns.ZoneListOption.dnsName(ZONE1.getDnsName()), Dns.ZoneListOption.fields(ZoneField.NAME_SERVER_SET)); DnsBatchResult> combinationResult = batch.listZones(Dns.ZoneListOption.fields(ZoneField.ZONE_ID, ZoneField.DESCRIPTION), @@ -1055,79 +1056,79 @@ public void testListZonesBatch() { // field options Iterator zoneIterator = idResult.get().iterateAll(); Zone zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNotNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNotNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = timeResult.get().iterateAll(); zone = zoneIterator.next(); - assertNotNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNotNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = dnsNameResult.get().iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNotNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNotNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = descriptionResult.get().iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNotNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = nameServersResult.get().iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertFalse(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); + assertFalse(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); zoneIterator = nameServerSetResult.get().iterateAll(); zone = zoneIterator.next(); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); // we cannot set it using google-cloud - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.generatedId()); + assertNull(zone.getCreationTimeMillis()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServerSet()); // we cannot set it using google-cloud + assertTrue(zone.getNameServers().isEmpty()); + assertNull(zone.getGeneratedId()); assertFalse(zoneIterator.hasNext()); // several combined zones = filter(combinationResult.get().iterateAll()); assertEquals(2, zones.size()); for (Zone current : zones) { - assertNull(current.creationTimeMillis()); - assertNotNull(current.name()); - assertNull(current.dnsName()); - assertNotNull(current.description()); - assertNull(current.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNotNull(current.generatedId()); + assertNull(current.getCreationTimeMillis()); + assertNotNull(current.getName()); + assertNull(current.getDnsName()); + assertNotNull(current.getDescription()); + assertNull(current.getNameServerSet()); + assertTrue(zone.getNameServers().isEmpty()); + assertNotNull(current.getGeneratedId()); } } finally { - DNS.delete(ZONE1.name()); - DNS.delete(ZONE_EMPTY_DESCRIPTION.name()); + DNS.delete(ZONE1.getName()); + DNS.delete(ZONE_EMPTY_DESCRIPTION.getName()); } } @@ -1139,28 +1140,28 @@ public void testCreateValidZoneBatch() { DnsBatchResult partialZoneResult = batch.createZone(ZONE_EMPTY_DESCRIPTION); batch.submit(); Zone created = completeZoneResult.get(); - assertEquals(ZONE1.description(), created.description()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertEquals(ZONE1.name(), created.name()); - assertNotNull(created.creationTimeMillis()); - assertNotNull(created.nameServers()); - assertNull(created.nameServerSet()); - assertNotNull(created.generatedId()); - Zone retrieved = DNS.getZone(ZONE1.name()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertEquals(ZONE1.getDnsName(), created.getDnsName()); + assertEquals(ZONE1.getName(), created.getName()); + assertNotNull(created.getCreationTimeMillis()); + assertNotNull(created.getNameServers()); + assertNull(created.getNameServerSet()); + assertNotNull(created.getGeneratedId()); + Zone retrieved = DNS.getZone(ZONE1.getName()); assertEquals(created, retrieved); created = partialZoneResult.get(); - assertEquals(ZONE_EMPTY_DESCRIPTION.description(), created.description()); - assertEquals(ZONE_EMPTY_DESCRIPTION.dnsName(), created.dnsName()); - assertEquals(ZONE_EMPTY_DESCRIPTION.name(), created.name()); - assertNotNull(created.creationTimeMillis()); - assertNotNull(created.nameServers()); - assertNull(created.nameServerSet()); - assertNotNull(created.generatedId()); - retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.name()); + assertEquals(ZONE_EMPTY_DESCRIPTION.getDescription(), created.getDescription()); + assertEquals(ZONE_EMPTY_DESCRIPTION.getDnsName(), created.getDnsName()); + assertEquals(ZONE_EMPTY_DESCRIPTION.getName(), created.getName()); + assertNotNull(created.getCreationTimeMillis()); + assertNotNull(created.getNameServers()); + assertNull(created.getNameServerSet()); + assertNotNull(created.getGeneratedId()); + retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.getName()); assertEquals(created, retrieved); } finally { - DNS.delete(ZONE1.name()); - DNS.delete(ZONE_EMPTY_DESCRIPTION.name()); + DNS.delete(ZONE1.getName()); + DNS.delete(ZONE_EMPTY_DESCRIPTION.getName()); } } @@ -1186,8 +1187,8 @@ public void testCreateZoneWithErrorsBatch() { assertFalse(ex.retryable()); } } finally { - DNS.delete(ZONE_NAME_ERROR.name()); - DNS.delete(ZONE_DNS_NO_PERIOD.name()); + DNS.delete(ZONE_NAME_ERROR.getName()); + DNS.delete(ZONE_DNS_NO_PERIOD.getName()); } } @@ -1199,85 +1200,85 @@ public void testCreateZoneWithOptionsBatch() { batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.CREATION_TIME)); batch.submit(); Zone created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNotNull(created.getCreationTimeMillis()); + assertNull(created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.DESCRIPTION)); batch.submit(); created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.DNS_NAME)); batch.submit(); created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDnsName(), created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); batch.submit(); created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME_SERVER_SET)); batch.submit(); created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); // we did not set it + assertNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME_SERVERS)); batch.submit(); created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.ZONE_ID)); batch.submit(); created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertNotNull(created.getNameServers()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNotNull(created.getGeneratedId()); created.delete(); batch = DNS.batch(); batchResult = batch.createZone(ZONE1, Dns.ZoneOption.fields(ZoneField.ZONE_ID, @@ -1285,15 +1286,15 @@ public void testCreateZoneWithOptionsBatch() { batch.submit(); // combination of multiple things created = batchResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); // we did not set it + assertNotNull(created.getGeneratedId()); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } @@ -1303,90 +1304,90 @@ public void testGetZoneBatch() { DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); DnsBatch batch = DNS.batch(); DnsBatchResult timeResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.CREATION_TIME)); + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.CREATION_TIME)); DnsBatchResult descriptionResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.DESCRIPTION)); + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.DESCRIPTION)); DnsBatchResult dnsNameResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.DNS_NAME)); + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.DNS_NAME)); DnsBatchResult nameResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.NAME)); + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.NAME)); DnsBatchResult nameServerSetResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.NAME_SERVER_SET)); + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.NAME_SERVER_SET)); DnsBatchResult nameServersResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.NAME_SERVERS)); + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.NAME_SERVERS)); DnsBatchResult idResult = - batch.getZone(ZONE1.name(), Dns.ZoneOption.fields(ZoneField.ZONE_ID)); - DnsBatchResult combinationResult = batch.getZone(ZONE1.name(), + batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.ZONE_ID)); + DnsBatchResult combinationResult = batch.getZone(ZONE1.getName(), Dns.ZoneOption.fields(ZoneField.ZONE_ID, ZoneField.NAME_SERVERS, ZoneField.NAME_SERVER_SET, ZoneField.DESCRIPTION)); batch.submit(); Zone created = timeResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNotNull(created.getCreationTimeMillis()); + assertNull(created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created = descriptionResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertNull(created.getDnsName()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created = dnsNameResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertEquals(ZONE1.getDnsName(), created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created = nameResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created = nameServerSetResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNull(created.getNameServerSet()); // we did not set it + assertNull(created.getGeneratedId()); created = nameServersResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); + assertNull(created.getGeneratedId()); created = idResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertNull(created.getDescription()); + assertNotNull(created.getNameServers()); + assertTrue(created.getNameServers().isEmpty()); // never returns null + assertNotNull(created.getGeneratedId()); // combination of multiple things created = combinationResult.get(); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.generatedId()); + assertEquals(ZONE1.getName(), created.getName()); // always returned + assertNull(created.getCreationTimeMillis()); + assertNull(created.getDnsName()); + assertEquals(ZONE1.getDescription(), created.getDescription()); + assertFalse(created.getNameServers().isEmpty()); + assertNull(created.getNameServerSet()); // we did not set it + assertNotNull(created.getGeneratedId()); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } @@ -1394,14 +1395,14 @@ public void testGetZoneBatch() { public void testDeleteZoneBatch() { try { Zone created = DNS.create(ZONE1); - assertEquals(created, DNS.getZone(ZONE1.name())); + assertEquals(created, DNS.getZone(ZONE1.getName())); DnsBatch batch = DNS.batch(); - DnsBatchResult result = batch.deleteZone(ZONE1.name()); + DnsBatchResult result = batch.deleteZone(ZONE1.getName()); batch.submit(); - assertNull(DNS.getZone(ZONE1.name())); + assertNull(DNS.getZone(ZONE1.getName())); assertTrue(result.get()); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } @@ -1420,11 +1421,11 @@ public void testGetProjectBatch() { batch.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER, ProjectField.QUOTA, ProjectField.PROJECT_ID)); batch.submit(); - assertNotNull(result.get().quota()); - assertNotNull(resultQuota.get().quota()); - assertNull(resultId.get().quota()); - assertNull(resultNumber.get().quota()); - assertNotNull(resultCombination.get().quota()); + assertNotNull(result.get().getQuota()); + assertNotNull(resultQuota.get().getQuota()); + assertNull(resultId.get().getQuota()); + assertNull(resultNumber.get().getQuota()); + assertNotNull(resultCombination.get().getQuota()); } @Test @@ -1433,81 +1434,81 @@ public void testCreateChangeBatch() { DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); DnsBatch batch = DNS.batch(); DnsBatchResult result = - batch.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + batch.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); batch.submit(); ChangeRequest created = result.get(); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertEquals(CHANGE_ADD_ZONE1.getAdditions(), created.getAdditions()); + assertNotNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) .contains(created.status())); - assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); + assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.getName(), "1")); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); // with options batch = DNS.batch(); - result = batch.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + result = batch.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.ID)); batch.submit(); created = result.get(); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertTrue(created.getAdditions().isEmpty()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); batch = DNS.batch(); - result = batch.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + result = batch.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.STATUS)); batch.submit(); created = result.get(); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertTrue(created.getAdditions().isEmpty()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNotNull(created.status()); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); batch = DNS.batch(); - result = batch.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + result = batch.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.START_TIME)); batch.submit(); created = result.get(); - assertTrue(created.additions().isEmpty()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertTrue(created.getAdditions().isEmpty()); + assertNotNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); waitForChangeToComplete(created); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + created = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); waitForChangeToComplete(created); batch = DNS.batch(); - result = batch.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + result = batch.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.ADDITIONS)); batch.submit(); created = result.get(); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertNotNull(created.generatedId()); + assertEquals(CHANGE_ADD_ZONE1.getAdditions(), created.getAdditions()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getDeletions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); // finishes with delete otherwise we cannot delete the zone waitForChangeToComplete(created); batch = DNS.batch(); - result = batch.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, + result = batch.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.DELETIONS)); batch.submit(); created = result.get(); waitForChangeToComplete(created); - assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); - assertNull(created.startTimeMillis()); - assertTrue(created.additions().isEmpty()); - assertNotNull(created.generatedId()); + assertEquals(CHANGE_DELETE_ZONE1.getDeletions(), created.getDeletions()); + assertNull(created.getStartTimeMillis()); + assertTrue(created.getAdditions().isEmpty()); + assertNotNull(created.getGeneratedId()); assertNull(created.status()); waitForChangeToComplete(created); } finally { @@ -1520,68 +1521,68 @@ public void testGetChangeBatch() { try { Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(ZoneField.NAME)); ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); DnsBatch batch = DNS.batch(); DnsBatchResult completeResult = - batch.getChangeRequest(zone.name(), created.generatedId()); + batch.getChangeRequest(zone.getName(), created.getGeneratedId()); DnsBatchResult idResult = - batch.getChangeRequest(zone.name(), created.generatedId(), + batch.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.ID)); DnsBatchResult statusResult = - batch.getChangeRequest(zone.name(), created.generatedId(), + batch.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.STATUS)); DnsBatchResult timeResult = - batch.getChangeRequest(zone.name(), created.generatedId(), + batch.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.START_TIME)); DnsBatchResult additionsResult = - batch.getChangeRequest(zone.name(), created.generatedId(), + batch.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.ADDITIONS)); batch.submit(); assertEqChangesIgnoreStatus(created, completeResult.get()); // with options ChangeRequest retrieved = idResult.get(); - assertEquals(created.generatedId(), retrieved.generatedId()); - assertEquals(0, retrieved.additions().size()); - assertEquals(0, retrieved.deletions().size()); - assertNull(retrieved.startTimeMillis()); + assertEquals(created.getGeneratedId(), retrieved.getGeneratedId()); + assertEquals(0, retrieved.getAdditions().size()); + assertEquals(0, retrieved.getDeletions().size()); + assertNull(retrieved.getStartTimeMillis()); assertNull(retrieved.status()); retrieved = statusResult.get(); - assertEquals(created.generatedId(), retrieved.generatedId()); - assertEquals(0, retrieved.additions().size()); - assertEquals(0, retrieved.deletions().size()); - assertNull(retrieved.startTimeMillis()); + assertEquals(created.getGeneratedId(), retrieved.getGeneratedId()); + assertEquals(0, retrieved.getAdditions().size()); + assertEquals(0, retrieved.getDeletions().size()); + assertNull(retrieved.getStartTimeMillis()); assertEquals(ChangeRequestInfo.Status.DONE, retrieved.status()); retrieved = timeResult.get(); - assertEquals(created.generatedId(), retrieved.generatedId()); - assertEquals(0, retrieved.additions().size()); - assertEquals(0, retrieved.deletions().size()); - assertEquals(created.startTimeMillis(), retrieved.startTimeMillis()); + assertEquals(created.getGeneratedId(), retrieved.getGeneratedId()); + assertEquals(0, retrieved.getAdditions().size()); + assertEquals(0, retrieved.getDeletions().size()); + assertEquals(created.getStartTimeMillis(), retrieved.getStartTimeMillis()); assertNull(retrieved.status()); retrieved = additionsResult.get(); - assertEquals(created.generatedId(), retrieved.generatedId()); - assertEquals(2, retrieved.additions().size()); - assertTrue(retrieved.additions().contains(A_RECORD_ZONE1)); - assertTrue(retrieved.additions().contains(AAAA_RECORD_ZONE1)); - assertEquals(0, retrieved.deletions().size()); - assertNull(retrieved.startTimeMillis()); + assertEquals(created.getGeneratedId(), retrieved.getGeneratedId()); + assertEquals(2, retrieved.getAdditions().size()); + assertTrue(retrieved.getAdditions().contains(A_RECORD_ZONE1)); + assertTrue(retrieved.getAdditions().contains(AAAA_RECORD_ZONE1)); + assertEquals(0, retrieved.getDeletions().size()); + assertNull(retrieved.getStartTimeMillis()); assertNull(retrieved.status()); // finishes with delete otherwise we cannot delete the zone created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(ChangeRequestField.DELETIONS)); batch = DNS.batch(); DnsBatchResult deletionsResult = - batch.getChangeRequest(zone.name(), created.generatedId(), + batch.getChangeRequest(zone.getName(), created.getGeneratedId(), Dns.ChangeRequestOption.fields(ChangeRequestField.DELETIONS)); batch.submit(); retrieved = deletionsResult.get(); - assertEquals(created.generatedId(), retrieved.generatedId()); - assertEquals(0, retrieved.additions().size()); - assertEquals(2, retrieved.deletions().size()); - assertTrue(retrieved.deletions().contains(AAAA_RECORD_ZONE1)); - assertTrue(retrieved.deletions().contains(A_RECORD_ZONE1)); - assertNull(retrieved.startTimeMillis()); + assertEquals(created.getGeneratedId(), retrieved.getGeneratedId()); + assertEquals(0, retrieved.getAdditions().size()); + assertEquals(2, retrieved.getDeletions().size()); + assertTrue(retrieved.getDeletions().contains(AAAA_RECORD_ZONE1)); + assertTrue(retrieved.getDeletions().contains(A_RECORD_ZONE1)); + assertNull(retrieved.getStartTimeMillis()); assertNull(retrieved.status()); - waitForChangeToComplete(zone.name(), created.generatedId()); + waitForChangeToComplete(zone.getName(), created.getGeneratedId()); } finally { clear(); } @@ -1591,7 +1592,7 @@ public void testGetChangeBatch() { public void testListChangesBatch() { try { DnsBatch batch = DNS.batch(); - DnsBatchResult> result = batch.listChangeRequests(ZONE1.name()); + DnsBatchResult> result = batch.listChangeRequests(ZONE1.getName()); batch.submit(); try { result.get(); @@ -1604,37 +1605,42 @@ public void testListChangesBatch() { // zone exists but has no changes DNS.create(ZONE1); batch = DNS.batch(); - result = batch.listChangeRequests(ZONE1.name()); + result = batch.listChangeRequests(ZONE1.getName()); batch.submit(); assertEquals(1, Iterables.size(result.get().values())); // default change creating SOA and NS // zone has changes - ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); + ChangeRequest change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); + change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_DELETE_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); batch = DNS.batch(); - result = batch.listChangeRequests(ZONE1.name()); - DnsBatchResult> errorPageSize = batch.listChangeRequests(ZONE1.name(), + result = batch.listChangeRequests(ZONE1.getName()); + DnsBatchResult> errorPageSize = batch.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.pageSize(0)); - DnsBatchResult> errorPageNegative = batch.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.pageSize(-1)); - DnsBatchResult> resultAscending = batch.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)); - DnsBatchResult> resultDescending = batch.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)); - DnsBatchResult> resultAdditions = batch.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(ChangeRequestField.ADDITIONS)); - DnsBatchResult> resultDeletions = batch.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(ChangeRequestField.DELETIONS)); - DnsBatchResult> resultId = batch.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(ChangeRequestField.ID)); - DnsBatchResult> resultTime = batch.listChangeRequests(ZONE1.name(), + DnsBatchResult> errorPageNegative = + batch.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.pageSize(-1)); + DnsBatchResult> resultAscending = + batch.listChangeRequests(ZONE1.getName(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)); + DnsBatchResult> resultDescending = + batch.listChangeRequests(ZONE1.getName(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)); + DnsBatchResult> resultAdditions = + batch.listChangeRequests(ZONE1.getName(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(ChangeRequestField.ADDITIONS)); + DnsBatchResult> resultDeletions = + batch.listChangeRequests(ZONE1.getName(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(ChangeRequestField.DELETIONS)); + DnsBatchResult> resultId = + batch.listChangeRequests(ZONE1.getName(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(ChangeRequestField.ID)); + DnsBatchResult> resultTime = batch.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.START_TIME)); - DnsBatchResult> resultStatus = batch.listChangeRequests(ZONE1.name(), + DnsBatchResult> resultStatus = batch.listChangeRequests(ZONE1.getName(), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), Dns.ChangeRequestListOption.fields(ChangeRequestField.STATUS)); batch.submit(); @@ -1669,34 +1675,34 @@ public void testListChangesBatch() { } // field options change = Iterables.get(resultAdditions.get().values(), 1); - assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertEquals(CHANGE_ADD_ZONE1.getAdditions(), change.getAdditions()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertNull(change.status()); change = Iterables.get(resultDeletions.get().values(), 2); - assertTrue(change.additions().isEmpty()); - assertNotNull(change.deletions()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertNotNull(change.getDeletions()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertNull(change.status()); change = Iterables.get(resultId.get().values(), 1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertNull(change.status()); change = Iterables.get(resultTime.get().values(), 1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNotNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNotNull(change.getStartTimeMillis()); assertNull(change.status()); change = Iterables.get(resultStatus.get().values(), 1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertNotNull(change.generatedId()); - assertNull(change.startTimeMillis()); + assertTrue(change.getAdditions().isEmpty()); + assertTrue(change.getDeletions().isEmpty()); + assertNotNull(change.getGeneratedId()); + assertNull(change.getStartTimeMillis()); assertEquals(ChangeRequest.Status.DONE, change.status()); } finally { clear(); @@ -1708,24 +1714,24 @@ public void testListDnsRecordSetsBatch() { try { Zone zone = DNS.create(ZONE1); DnsBatch batch = DNS.batch(); - DnsBatchResult> result = batch.listRecordSets(zone.name()); + DnsBatchResult> result = batch.listRecordSets(zone.getName()); batch.submit(); ImmutableList recordSets = ImmutableList.copyOf(result.get().iterateAll()); assertEquals(2, recordSets.size()); ImmutableList defaultRecords = ImmutableList.of(RecordSet.Type.NS, RecordSet.Type.SOA); for (RecordSet recordSet : recordSets) { - assertTrue(defaultRecords.contains(recordSet.type())); + assertTrue(defaultRecords.contains(recordSet.getType())); } // field options batch = DNS.batch(); - DnsBatchResult> ttlResult = batch.listRecordSets(zone.name(), + DnsBatchResult> ttlResult = batch.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.TTL)); - DnsBatchResult> nameResult = batch.listRecordSets(zone.name(), + DnsBatchResult> nameResult = batch.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.NAME)); - DnsBatchResult> recordsResult = batch.listRecordSets(zone.name(), + DnsBatchResult> recordsResult = batch.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.DNS_RECORDS)); - DnsBatchResult> pageSizeResult = batch.listRecordSets(zone.name(), + DnsBatchResult> pageSizeResult = batch.listRecordSets(zone.getName(), Dns.RecordSetListOption.fields(RecordSetField.TYPE), Dns.RecordSetListOption.pageSize(1)); batch.submit(); @@ -1733,10 +1739,10 @@ public void testListDnsRecordSetsBatch() { int counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).ttl(), recordSet.ttl()); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertTrue(recordSet.records().isEmpty()); + assertEquals(recordSets.get(counter).getTtl(), recordSet.getTtl()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertTrue(recordSet.getRecords().isEmpty()); counter++; } assertEquals(2, counter); @@ -1744,10 +1750,10 @@ public void testListDnsRecordSetsBatch() { counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertTrue(recordSet.records().isEmpty()); - assertNull(recordSet.ttl()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertTrue(recordSet.getRecords().isEmpty()); + assertNull(recordSet.getTtl()); counter++; } assertEquals(2, counter); @@ -1755,10 +1761,10 @@ public void testListDnsRecordSetsBatch() { counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).records(), recordSet.records()); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertNull(recordSet.ttl()); + assertEquals(recordSets.get(counter).getRecords(), recordSet.getRecords()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertNull(recordSet.getTtl()); counter++; } assertEquals(2, counter); @@ -1766,10 +1772,10 @@ public void testListDnsRecordSetsBatch() { counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertEquals(recordSets.get(counter).type(), recordSet.type()); - assertEquals(recordSets.get(counter).name(), recordSet.name()); - assertTrue(recordSet.records().isEmpty()); - assertNull(recordSet.ttl()); + assertEquals(recordSets.get(counter).getType(), recordSet.getType()); + assertEquals(recordSets.get(counter).getName(), recordSet.getName()); + assertTrue(recordSet.getRecords().isEmpty()); + assertNull(recordSet.getTtl()); counter++; } assertEquals(2, counter); @@ -1777,26 +1783,26 @@ public void testListDnsRecordSetsBatch() { Page recordSetPage = pageSizeResult.get(); assertEquals(1, ImmutableList.copyOf(recordSetPage.values().iterator()).size()); // test name filter - ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitForChangeToComplete(ZONE1.name(), change.generatedId()); + ChangeRequest change = DNS.applyChangeRequest(ZONE1.getName(), CHANGE_ADD_ZONE1); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); batch = DNS.batch(); - result = batch.listRecordSets(ZONE1.name(), - Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name())); + result = batch.listRecordSets(ZONE1.getName(), + Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.getName())); batch.submit(); recordSetIterator = result.get().iterateAll(); counter = 0; while (recordSetIterator.hasNext()) { RecordSet recordSet = recordSetIterator.next(); - assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) - .contains(recordSet.type())); + assertTrue(ImmutableList.of(A_RECORD_ZONE1.getType(), AAAA_RECORD_ZONE1.getType()) + .contains(recordSet.getType())); counter++; } assertEquals(2, counter); // test type filter batch = DNS.batch(); - result = batch.listRecordSets(ZONE1.name(), - Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name()), - Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())); + result = batch.listRecordSets(ZONE1.getName(), + Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.getName()), + Dns.RecordSetListOption.type(A_RECORD_ZONE1.getType())); batch.submit(); recordSetIterator = result.get().iterateAll(); counter = 0; @@ -1807,12 +1813,12 @@ public void testListDnsRecordSetsBatch() { } assertEquals(1, counter); batch = DNS.batch(); - DnsBatchResult> noNameError = batch.listRecordSets(ZONE1.name(), - Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())); + DnsBatchResult> noNameError = batch.listRecordSets(ZONE1.getName(), + Dns.RecordSetListOption.type(A_RECORD_ZONE1.getType())); DnsBatchResult> zeroSizeError = - batch.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.pageSize(0)); + batch.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.pageSize(0)); DnsBatchResult> negativeSizeError = - batch.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.pageSize(-1)); + batch.listRecordSets(ZONE1.getName(), Dns.RecordSetListOption.pageSize(-1)); batch.submit(); // check wrong arguments try { @@ -1840,7 +1846,7 @@ public void testListDnsRecordSetsBatch() { assertEquals(400, ex.code()); assertFalse(ex.retryable()); } - waitForChangeToComplete(ZONE1.name(), change.generatedId()); + waitForChangeToComplete(ZONE1.getName(), change.getGeneratedId()); } finally { clear(); } @@ -1865,17 +1871,17 @@ public void testBatchCombined() { // expected } batch.submit(); - assertNotNull(zoneResult.get().creationTimeMillis()); - assertEquals(ZONE1.dnsName(), zoneResult.get().dnsName()); - assertEquals(ZONE1.description(), zoneResult.get().description()); - assertFalse(zoneResult.get().nameServers().isEmpty()); - assertNull(zoneResult.get().nameServerSet()); // we did not set it - assertNotNull(zoneResult.get().generatedId()); - assertNotNull(projectResult.get().quota()); + assertNotNull(zoneResult.get().getCreationTimeMillis()); + assertEquals(ZONE1.getDnsName(), zoneResult.get().getDnsName()); + assertEquals(ZONE1.getDescription(), zoneResult.get().getDescription()); + assertFalse(zoneResult.get().getNameServers().isEmpty()); + assertNull(zoneResult.get().getNameServerSet()); // we did not set it + assertNotNull(zoneResult.get().getGeneratedId()); + assertNotNull(projectResult.get().getQuota()); assertEquals(2, Iterables.size(pageResult.get().values())); assertNotNull(changeRequestResult.get()); } finally { - DNS.delete(ZONE1.name()); + DNS.delete(ZONE1.getName()); } } } diff --git a/google-cloud-dns/src/test/java/com/google/cloud/dns/testing/LocalDnsHelperTest.java b/google-cloud-dns/src/test/java/com/google/cloud/dns/testing/LocalDnsHelperTest.java index 6831485f821e..fd9ee2126013 100644 --- a/google-cloud-dns/src/test/java/com/google/cloud/dns/testing/LocalDnsHelperTest.java +++ b/google-cloud-dns/src/test/java/com/google/cloud/dns/testing/LocalDnsHelperTest.java @@ -74,8 +74,8 @@ public class LocalDnsHelperTest { private static final Change CHANGE_COMPLEX = new Change(); private static final LocalDnsHelper LOCAL_DNS_HELPER = LocalDnsHelper.create(0L); private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); - private static final DnsRpc RPC = new DefaultDnsRpc(LOCAL_DNS_HELPER.options()); - private static final String REAL_PROJECT_ID = LOCAL_DNS_HELPER.options().projectId(); + private static final DnsRpc RPC = new DefaultDnsRpc(LOCAL_DNS_HELPER.getOptions()); + private static final String REAL_PROJECT_ID = LOCAL_DNS_HELPER.getOptions().projectId(); private Map optionsMap; private static abstract class FailExpectedCallback implements RpcBatch.Callback { diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/DnsExample.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/DnsExample.java index 65b6178ae486..783cccb699d6 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/DnsExample.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/DnsExample.java @@ -87,7 +87,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.generatedId()); + zone.getName(), zone.getGeneratedId()); } @Override @@ -201,16 +201,17 @@ public void run(Dns dns, String... args) { if (args.length > 3) { ttl = Integer.parseInt(args[3]); } - RecordSet recordSet = RecordSet.builder(recordName, RecordSet.Type.A) - .records(ImmutableList.of(ip)) - .ttl(ttl, TimeUnit.SECONDS) + RecordSet recordSet = RecordSet.newBuilder(recordName, RecordSet.Type.A) + .setRecords(ImmutableList.of(ip)) + .setTtl(ttl, TimeUnit.SECONDS) .build(); - ChangeRequestInfo changeRequest = ChangeRequest.builder() + ChangeRequestInfo changeRequest = ChangeRequest.newBuilder() .delete(recordSet) .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.generatedId()); + + "submitted and assigned ID %s.%n", recordName, zoneName, + changeRequest.getGeneratedId()); System.out.print("Waiting for deletion to happen..."); waitForChangeToFinish(dns, zoneName, changeRequest); System.out.printf("%nThe deletion has been completed.%n"); @@ -248,14 +249,15 @@ public void run(Dns dns, String... args) { if (args.length > 3) { ttl = Integer.parseInt(args[3]); } - RecordSet recordSet = RecordSet.builder(recordName, RecordSet.Type.A) - .records(ImmutableList.of(ip)) - .ttl(ttl, TimeUnit.SECONDS) + RecordSet recordSet = RecordSet.newBuilder(recordName, RecordSet.Type.A) + .setRecords(ImmutableList.of(ip)) + .setTtl(ttl, TimeUnit.SECONDS) .build(); - ChangeRequestInfo changeRequest = ChangeRequest.builder().add(recordSet).build(); + ChangeRequestInfo changeRequest = ChangeRequest.newBuilder().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.generatedId()); + + "submitted and assigned ID %s.%n", recordName, zoneName, + changeRequest.getGeneratedId()); System.out.print("Waiting for addition to happen..."); waitForChangeToFinish(dns, zoneName, changeRequest); System.out.printf("The addition has been completed.%n"); @@ -291,8 +293,8 @@ public void run(Dns dns, String... args) { System.out.printf("Record sets for zone %s:%n", zoneName); while (iterator.hasNext()) { RecordSet recordSet = iterator.next(); - System.out.printf("%nRecord name: %s%nTTL: %s%nRecords: %s%n", recordSet.name(), - recordSet.ttl(), Joiner.on(", ").join(recordSet.records())); + System.out.printf("%nRecord name: %s%nTTL: %s%nRecords: %s%n", recordSet.getName(), + recordSet.getTtl(), Joiner.on(", ").join(recordSet.getRecords())); } } else { System.out.printf("Zone %s has no record sets records.%n", zoneName); @@ -331,11 +333,11 @@ 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.generatedId()); + System.out.printf("%nID: %s%n", change.getGeneratedId()); System.out.printf("Status: %s%n", change.status()); - System.out.printf("Started: %s%n", FORMATTER.print(change.startTimeMillis())); - System.out.printf("Deletions: %s%n", Joiner.on(", ").join(change.deletions())); - System.out.printf("Additions: %s%n", Joiner.on(", ").join(change.additions())); + System.out.printf("Started: %s%n", FORMATTER.print(change.getStartTimeMillis())); + System.out.printf("Deletions: %s%n", Joiner.on(", ").join(change.getDeletions())); + System.out.printf("Additions: %s%n", Joiner.on(", ").join(change.getAdditions())); } } else { System.out.printf("Zone %s has no change requests.%n", zoneName); @@ -401,16 +403,16 @@ private static class GetProjectAction implements DnsAction { @Override public void run(Dns dns, String... args) { ProjectInfo project = dns.getProject(); - ProjectInfo.Quota quota = project.quota(); + ProjectInfo.Quota quota = project.getQuota(); System.out.printf("Project id: %s%nQuota:%n", dns.options().projectId()); - System.out.printf("\tZones: %d%n", quota.zones()); - System.out.printf("\tRecord sets per zone: %d%n", quota.rrsetsPerZone()); + System.out.printf("\tZones: %d%n", quota.getZones()); + System.out.printf("\tRecord sets per zone: %d%n", quota.getRrsetsPerZone()); System.out.printf("\tRecord sets per DNS record: %d%n", - quota.resourceRecordsPerRrset()); - System.out.printf("\tAdditions per change: %d%n", quota.rrsetAdditionsPerChange()); - System.out.printf("\tDeletions per change: %d%n", quota.rrsetDeletionsPerChange()); + quota.getResourceRecordsPerRrset()); + System.out.printf("\tAdditions per change: %d%n", quota.getRrsetAdditionsPerChange()); + System.out.printf("\tDeletions per change: %d%n", quota.getRrsetDeletionsPerChange()); System.out.printf("\tTotal data size per change: %d%n", - quota.totalRrdataSizePerChange()); + quota.getTotalRrdataSizePerChange()); } @Override @@ -435,11 +437,11 @@ 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.generatedId()); - System.out.printf("Description: %s%n", zone.description()); - System.out.printf("Created: %s%n", FORMATTER.print(zone.creationTimeMillis())); - System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); + System.out.printf("%nName: %s%n", zone.getName()); + System.out.printf("ID: %s%n", zone.getGeneratedId()); + System.out.printf("Description: %s%n", zone.getDescription()); + System.out.printf("Created: %s%n", FORMATTER.print(zone.getCreationTimeMillis())); + System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.getNameServers())); } private static ChangeRequestInfo waitForChangeToFinish(Dns dns, String zoneName, @@ -452,7 +454,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.generatedId()); + current = dns.getChangeRequest(zoneName, current.getGeneratedId()); } return current; } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateOrUpdateRecordSets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateOrUpdateRecordSets.java index b49cdeede5fb..997e35e6a8e6 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateOrUpdateRecordSets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateOrUpdateRecordSets.java @@ -49,20 +49,21 @@ public static void main(String... args) { // Prepare a www.. type A record set with ttl of 24 hours String ip = "12.13.14.15"; - RecordSet toCreate = RecordSet.builder("www." + zone.dnsName(), RecordSet.Type.A) - .ttl(24, TimeUnit.HOURS) + RecordSet toCreate = RecordSet.newBuilder("www." + zone.getDnsName(), RecordSet.Type.A) + .setTtl(24, TimeUnit.HOURS) .addRecord(ip) .build(); // Make a change - ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); + ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.newBuilder().add(toCreate); // Verify a www.. type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. Iterator recordSetIterator = zone.listRecordSets().iterateAll(); while (recordSetIterator.hasNext()) { RecordSet current = recordSetIterator.next(); - if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { + if (toCreate.getName().equals(current.getName()) + && toCreate.getType().equals(current.getType())) { changeBuilder.delete(current); } } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java index f205cc0d2c9a..57939ca9e07a 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/CreateZone.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/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.generatedId()); + System.out.printf("Zone was created and assigned ID %s.%n", zone.getGeneratedId()); } } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/DeleteZone.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/DeleteZone.java index 317daf0c2e7d..1202c66b51ac 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/DeleteZone.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/DeleteZone.java @@ -48,18 +48,19 @@ public static void main(String... args) { Iterator recordIterator = dns.listRecordSets(zoneName).iterateAll(); // Make a change for deleting the records - ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder(); + ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.newBuilder(); while (recordIterator.hasNext()) { RecordSet current = recordIterator.next(); // SOA and NS records cannot be deleted - if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) { + if (!RecordSet.Type.SOA.equals(current.getType()) + && !RecordSet.Type.NS.equals(current.getType())) { changeBuilder.delete(current); } } // Build and apply the change request to our zone if it contains records to delete ChangeRequestInfo changeRequest = changeBuilder.build(); - if (!changeRequest.deletions().isEmpty()) { + if (!changeRequest.getDeletions().isEmpty()) { ChangeRequest pendingRequest = dns.applyChangeRequest(zoneName, changeRequest); // Wait for the change request to complete diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java index 1afceefeea23..1cfa768c220e 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java @@ -51,30 +51,31 @@ 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.generatedId()); + System.out.printf("Zone was created and assigned ID %s.%n", zone.getGeneratedId()); // Print assigned name servers - List nameServers = zone.nameServers(); + List nameServers = zone.getNameServers(); for (String nameServer : nameServers) { System.out.println(nameServer); } // Prepare a www.someexampledomain.com. type A record with ttl of 24 hours String ip = "12.13.14.15"; - RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A) - .ttl(24, TimeUnit.HOURS) + RecordSet toCreate = RecordSet.newBuilder("www.someexampledomain.com.", RecordSet.Type.A) + .setTtl(24, TimeUnit.HOURS) .addRecord(ip) .build(); // Make a change - ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); + ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.newBuilder().add(toCreate); // Verify the type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. Iterator recordSetIterator = zone.listRecordSets().iterateAll(); while (recordSetIterator.hasNext()) { RecordSet current = recordSetIterator.next(); - if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { + if (toCreate.getName().equals(current.getName()) + && toCreate.getType().equals(current.getType())) { changeBuilder.delete(current); } } @@ -89,7 +90,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.generatedId()); + changeRequest = dns.getChangeRequest(zone.getName(), changeRequest.getGeneratedId()); } System.out.println("The change request has been applied."); @@ -103,31 +104,32 @@ public static void main(String... args) { // List the record sets in a particular zone recordSetIterator = zone.listRecordSets().iterateAll(); - System.out.println(String.format("Record sets inside %s:", zone.name())); + System.out.println(String.format("Record sets inside %s:", zone.getName())); while (recordSetIterator.hasNext()) { System.out.println(recordSetIterator.next()); } // List the change requests applied to a particular zone Iterator changeIterator = zone.listChangeRequests().iterateAll(); - System.out.println(String.format("The history of changes in %s:", zone.name())); + System.out.println(String.format("The history of changes in %s:", zone.getName())); while (changeIterator.hasNext()) { System.out.println(changeIterator.next()); } // Make a change for deleting the record sets - changeBuilder = ChangeRequestInfo.builder(); + changeBuilder = ChangeRequestInfo.newBuilder(); while (recordSetIterator.hasNext()) { RecordSet current = recordSetIterator.next(); // SOA and NS records cannot be deleted - if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) { + if (!RecordSet.Type.SOA.equals(current.getType()) + && !RecordSet.Type.NS.equals(current.getType())) { changeBuilder.delete(current); } } // Build and apply the change request to our zone if it contains records to delete changeRequest = changeBuilder.build(); - if (!changeRequest.deletions().isEmpty()) { + if (!changeRequest.getDeletions().isEmpty()) { ChangeRequest pendingRequest = dns.applyChangeRequest(zoneName, changeRequest); // Wait for the change request to complete