additions) {
this.additions = Lists.newLinkedList(checkNotNull(additions));
return this;
}
-
+
/**
* Sets a collection of {@link DnsRecord}s which are to be deleted from the zone upon executing
* this {@code ChangeRequest}.
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java
index 4236d9c1c561..99ca20386419 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java
@@ -22,19 +22,21 @@
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import com.google.common.primitives.Ints;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.TimeUnit;
/**
* A class that represents a Google Cloud DNS record set.
*
* A {@code DnsRecord} is the unit of data that will be returned by the DNS servers upon a DNS
* request for a specific domain. The {@code DnsRecord} holds the current state of the DNS records
- * that make up a managed zone. You can read the records but you cannot modify them directly.
- * Rather, you edit the records in a managed zone by creating a ChangeRequest.
+ * that make up a zone. You can read the records but you cannot modify them directly. Rather, you
+ * edit the records in a zone by creating a ChangeRequest.
*
* @see Google Cloud DNS
* documentation
@@ -44,7 +46,7 @@ public class DnsRecord implements Serializable {
private static final long serialVersionUID = 2016011914302204L;
private final String name;
private final List rrdatas;
- private final Integer ttl;
+ private final Integer ttl; // this is in seconds
private final Type type;
/**
@@ -176,14 +178,19 @@ public Builder name(String name) {
}
/**
- * Sets the number of seconds that this record can be cached by resolvers. This number must be
- * non-negative.
+ * 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 ttl A non-negative number of seconds
+ * @param duration A non-negative number of time units
+ * @param unit The unit of the ttl parameter
*/
- public Builder ttl(int ttl) {
- checkArgument(ttl >= 0, "TTL cannot be negative. The supplied value was %s.", ttl);
- this.ttl = ttl;
+ public Builder ttl(int duration, TimeUnit unit) {
+ checkArgument(duration >= 0,
+ "Duration cannot be negative. The supplied value was %s.", duration);
+ checkNotNull(unit);
+ // we cannot have long because pb does not support it
+ long converted = unit.toSeconds(duration);
+ ttl = Ints.checkedCast(converted);
return this;
}
@@ -278,7 +285,7 @@ static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb)
builder.records(pb.getRrdatas());
}
if (pb.getTtl() != null) {
- builder.ttl(pb.getTtl());
+ builder.ttl(pb.getTtl(), TimeUnit.SECONDS);
}
return builder.build();
}
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java
index e65524913920..4db0497946b1 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java
@@ -26,7 +26,7 @@
/**
* The class provides the Google Cloud DNS information associated with this project. A project is a
- * top level container for resources including {@code ManagedZone}s. Projects can be created only in
+ * top level container for resources including {@code Zone}s. Projects can be created only in
* the APIs console.
*
* @see Google Cloud DNS documentation
@@ -50,7 +50,7 @@ public static class Quota {
private final int resourceRecordsPerRrset;
private final int rrsetAdditionsPerChange;
private final int rrsetDeletionsPerChange;
- private final int rrsetsPerManagedZone;
+ private final int rrsetsPerZone;
private final int totalRrdataSizePerChange;
/**
@@ -64,18 +64,18 @@ public static class Quota {
int resourceRecordsPerRrset,
int rrsetAdditionsPerChange,
int rrsetDeletionsPerChange,
- int rrsetsPerManagedZone,
+ int rrsetsPerZone,
int totalRrdataSizePerChange) {
this.zones = zones;
this.resourceRecordsPerRrset = resourceRecordsPerRrset;
this.rrsetAdditionsPerChange = rrsetAdditionsPerChange;
this.rrsetDeletionsPerChange = rrsetDeletionsPerChange;
- this.rrsetsPerManagedZone = rrsetsPerManagedZone;
+ this.rrsetsPerZone = rrsetsPerZone;
this.totalRrdataSizePerChange = totalRrdataSizePerChange;
}
/**
- * Returns the maximum allowed number of managed zones in the project.
+ * Returns the maximum allowed number of zones in the project.
*/
public int zones() {
return zones;
@@ -104,11 +104,11 @@ public int rrsetDeletionsPerChange() {
}
/**
- * Returns the maximum allowed number of {@link DnsRecord}s per {@link ManagedZoneInfo} in the
+ * Returns the maximum allowed number of {@link DnsRecord}s per {@link ZoneInfo} in the
* project.
*/
- public int rrsetsPerManagedZone() {
- return rrsetsPerManagedZone;
+ public int rrsetsPerZone() {
+ return rrsetsPerZone;
}
/**
@@ -126,7 +126,7 @@ public boolean equals(Object other) {
@Override
public int hashCode() {
return Objects.hash(zones, resourceRecordsPerRrset, rrsetAdditionsPerChange,
- rrsetDeletionsPerChange, rrsetsPerManagedZone, totalRrdataSizePerChange);
+ rrsetDeletionsPerChange, rrsetsPerZone, totalRrdataSizePerChange);
}
com.google.api.services.dns.model.Quota toPb() {
@@ -135,7 +135,7 @@ com.google.api.services.dns.model.Quota toPb() {
pb.setResourceRecordsPerRrset(resourceRecordsPerRrset);
pb.setRrsetAdditionsPerChange(rrsetAdditionsPerChange);
pb.setRrsetDeletionsPerChange(rrsetDeletionsPerChange);
- pb.setRrsetsPerManagedZone(rrsetsPerManagedZone);
+ pb.setRrsetsPerManagedZone(rrsetsPerZone);
pb.setTotalRrdataSizePerChange(totalRrdataSizePerChange);
return pb;
}
@@ -158,7 +158,7 @@ public String toString() {
.add("resourceRecordsPerRrset", resourceRecordsPerRrset)
.add("rrsetAdditionsPerChange", rrsetAdditionsPerChange)
.add("rrsetDeletionsPerChange", rrsetDeletionsPerChange)
- .add("rrsetsPerManagedZone", rrsetsPerManagedZone)
+ .add("rrsetsPerZone", rrsetsPerZone)
.add("totalRrdataSizePerChange", totalRrdataSizePerChange)
.toString();
}
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java
similarity index 70%
rename from gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java
rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java
index d27e134ad908..524309eaa8e9 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java
@@ -32,12 +32,12 @@
import java.util.Objects;
/**
- * A {@code ManagedZone} represents a DNS zone hosted by the Google Cloud DNS service. A zone is a
- * subtree of the DNS namespace under one administrative responsibility. See Google Cloud DNS documentation for
* more information.
*/
-public class ManagedZoneInfo implements Serializable {
+public class ZoneInfo implements Serializable {
private static final long serialVersionUID = 201601191647L;
private final String name;
@@ -49,7 +49,7 @@ public class ManagedZoneInfo implements Serializable {
private final List nameServers;
/**
- * A builder for {@code ManagedZoneInfo}.
+ * A builder for {@code ZoneInfo}.
*/
public static class Builder {
private String name;
@@ -61,8 +61,7 @@ public static class Builder {
private List nameServers = new LinkedList<>();
/**
- * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code
- * toPb()}.
+ * Returns an empty builder for {@code ZoneInfo}. We use it internally in {@code toPb()}.
*/
private Builder() {
}
@@ -81,9 +80,9 @@ private Builder(String name, BigInteger id) {
}
/**
- * Creates a builder from an existing ManagedZoneInfo object.
+ * Creates a builder from an existing ZoneInfo object.
*/
- Builder(ManagedZoneInfo info) {
+ Builder(ZoneInfo info) {
this.name = info.name;
this.id = info.id;
this.creationTimeMillis = info.creationTimeMillis;
@@ -102,7 +101,7 @@ public Builder name(String name) {
}
/**
- * Sets an id for the managed zone which is assigned to the managed zone by the server.
+ * Sets an id for the zone which is assigned to the zone by the server.
*/
Builder id(BigInteger id) {
this.id = id;
@@ -110,7 +109,7 @@ Builder id(BigInteger id) {
}
/**
- * Sets the time when this managed zone was created.
+ * Sets the time when this zone was created.
*/
Builder creationTimeMillis(long creationTimeMillis) {
this.creationTimeMillis = creationTimeMillis;
@@ -118,7 +117,7 @@ Builder creationTimeMillis(long creationTimeMillis) {
}
/**
- * Sets a mandatory DNS name of this managed zone, for instance "example.com.".
+ * Sets a mandatory DNS name of this zone, for instance "example.com.".
*/
public Builder dnsName(String dnsName) {
this.dnsName = checkNotNull(dnsName);
@@ -126,8 +125,8 @@ public Builder dnsName(String dnsName) {
}
/**
- * Sets a mandatory description for this managed zone. The value is a string of at most 1024
- * characters which has no effect on the managed zone's function.
+ * 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 Builder description(String description) {
this.description = checkNotNull(description);
@@ -135,9 +134,8 @@ public Builder description(String description) {
}
/**
- * Optionally specifies the NameServerSet for this managed zone. A NameServerSet is a set of DNS
- * name servers that all host the same ManagedZones. Most users will not need to specify this
- * value.
+ * 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.
*/
public Builder nameServerSet(String nameServerSet) {
// todo(mderka) add more to the doc when questions are answered by the service owner
@@ -146,8 +144,8 @@ public Builder nameServerSet(String nameServerSet) {
}
/**
- * Sets a list of servers that hold the information about the managed zone. This information is
- * provided by Google Cloud DNS and is read only.
+ * Sets a list of servers that hold the information about the zone. This information is provided
+ * by Google Cloud DNS and is read only.
*/
Builder nameServers(List nameServers) {
checkNotNull(nameServers);
@@ -156,14 +154,14 @@ Builder nameServers(List nameServers) {
}
/**
- * Builds the instance of {@code ManagedZoneInfo} based on the information set by this builder.
+ * Builds the instance of {@code ZoneInfo} based on the information set by this builder.
*/
- public ManagedZoneInfo build() {
- return new ManagedZoneInfo(this);
+ public ZoneInfo build() {
+ return new ZoneInfo(this);
}
}
- private ManagedZoneInfo(Builder builder) {
+ private ZoneInfo(Builder builder) {
this.name = builder.name;
this.id = builder.id;
this.creationTimeMillis = builder.creationTimeMillis;
@@ -174,63 +172,63 @@ private ManagedZoneInfo(Builder builder) {
}
/**
- * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name}.
+ * Returns a builder for {@code ZoneInfo} with an assigned {@code name}.
*/
public static Builder builder(String name) {
return new Builder(name);
}
/**
- * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code id}.
+ * Returns a builder for {@code ZoneInfo} with an assigned {@code id}.
*/
public static Builder builder(BigInteger id) {
return new Builder(id);
}
/**
- * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name} and {@code id}.
+ * Returns a builder for {@code ZoneInfo} with an assigned {@code name} and {@code id}.
*/
public static Builder builder(String name, BigInteger id) {
return new Builder(name, id);
}
/**
- * Returns the user-defined name of the managed zone.
+ * Returns the user-defined name of the zone.
*/
public String name() {
return name;
}
/**
- * Returns the read-only managed zone id assigned by the server.
+ * Returns the read-only zone id assigned by the server.
*/
public BigInteger id() {
return id;
}
/**
- * Returns the time when this time that this managed zone was created on the server.
+ * Returns the time when this zone was created on the server.
*/
public Long creationTimeMillis() {
return creationTimeMillis;
}
/**
- * Returns the DNS name of this managed zone, for instance "example.com.".
+ * Returns the DNS name of this zone, for instance "example.com.".
*/
public String dnsName() {
return dnsName;
}
/**
- * Returns the description of this managed zone.
+ * Returns the description of this zone.
*/
public String description() {
return description;
}
/**
- * Returns the optionally specified set of DNS name servers that all host this managed zone.
+ * Returns the optionally specified set of DNS name servers that all host this zone.
*/
public String nameServerSet() {
// todo(mderka) update this doc after finding out more about this from the service owners
@@ -238,16 +236,14 @@ public String nameServerSet() {
}
/**
- * The nameservers that the managed zone should be delegated to. This is defined by the Google DNS
- * cloud.
+ * The nameservers that the zone should be delegated to. This is defined by the Google DNS cloud.
*/
public List nameServers() {
return nameServers;
}
/**
- * Returns a builder for {@code ManagedZoneInfo} prepopulated with the metadata of this managed
- * zone.
+ * Returns a builder for {@code ZoneInfo} prepopulated with the metadata of this zone.
*/
public Builder toBuilder() {
return new Builder(this);
@@ -272,35 +268,35 @@ com.google.api.services.dns.model.ManagedZone toPb() {
return pb;
}
- static ManagedZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) {
- Builder b = new Builder();
+ static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) {
+ Builder builder = new Builder();
if (pb.getDescription() != null) {
- b.description(pb.getDescription());
+ builder.description(pb.getDescription());
}
if (pb.getDnsName() != null) {
- b.dnsName(pb.getDnsName());
+ builder.dnsName(pb.getDnsName());
}
if (pb.getId() != null) {
- b.id(pb.getId());
+ builder.id(pb.getId());
}
if (pb.getName() != null) {
- b.name(pb.getName());
+ builder.name(pb.getName());
}
if (pb.getNameServers() != null) {
- b.nameServers(pb.getNameServers());
+ builder.nameServers(pb.getNameServers());
}
if (pb.getNameServerSet() != null) {
- b.nameServerSet(pb.getNameServerSet());
+ builder.nameServerSet(pb.getNameServerSet());
}
if (pb.getCreationTime() != null) {
- b.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis());
+ builder.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis());
}
- return b.build();
+ return builder.build();
}
@Override
public boolean equals(Object obj) {
- return obj instanceof ManagedZoneInfo && Objects.equals(toPb(), ((ManagedZoneInfo) obj).toPb());
+ return obj instanceof ZoneInfo && Objects.equals(toPb(), ((ZoneInfo) obj).toPb());
}
@Override
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java
index 7a7daf8aac3c..5fc972cede78 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java
@@ -16,6 +16,7 @@
package com.google.gcloud.dns;
+import static com.google.gcloud.dns.DnsRecord.builder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@@ -23,18 +24,22 @@
import org.junit.Test;
+import java.util.concurrent.TimeUnit;
+
public class DnsRecordTest {
private static final String NAME = "example.com.";
private static final Integer TTL = 3600;
+ private static final TimeUnit UNIT = TimeUnit.HOURS;
+ private static final Integer UNIT_TTL = 1;
private static final DnsRecord.Type TYPE = DnsRecord.Type.AAAA;
- private static final DnsRecord record = DnsRecord.builder(NAME, TYPE)
- .ttl(TTL)
+ private static final DnsRecord record = builder(NAME, TYPE)
+ .ttl(UNIT_TTL, UNIT)
.build();
@Test
public void testDefaultDnsRecord() {
- DnsRecord record = DnsRecord.builder(NAME, TYPE).build();
+ DnsRecord record = builder(NAME, TYPE).build();
assertEquals(0, record.records().size());
assertEquals(TYPE, record.type());
assertEquals(NAME, record.name());
@@ -61,13 +66,21 @@ public void testBuilder() {
@Test
public void testValidTtl() {
try {
- DnsRecord.builder(NAME, TYPE).ttl(-1);
+ builder(NAME, TYPE).ttl(-1, TimeUnit.SECONDS);
fail("A negative value is not acceptable for ttl.");
} catch (IllegalArgumentException e) {
// expected
}
- DnsRecord.builder(NAME, TYPE).ttl(0);
- DnsRecord.builder(NAME, TYPE).ttl(Integer.MAX_VALUE);
+ builder(NAME, TYPE).ttl(0, TimeUnit.SECONDS);
+ builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.SECONDS);
+ try {
+ builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.HOURS);
+ fail("This value is too large for int.");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ DnsRecord record = DnsRecord.builder(NAME, TYPE).ttl(UNIT_TTL, UNIT).build();
+ assertEquals(TTL, record.ttl());
}
@Test
@@ -79,7 +92,7 @@ public void testEqualsAndNotEquals() {
String differentName = "totally different name";
clone = record.toBuilder().name(differentName).build();
assertNotEquals(record, clone);
- clone = record.toBuilder().ttl(record.ttl() + 1).build();
+ clone = record.toBuilder().ttl(record.ttl() + 1, TimeUnit.SECONDS).build();
assertNotEquals(record, clone);
clone = record.toBuilder().type(DnsRecord.Type.TXT).build();
assertNotEquals(record, clone);
@@ -95,22 +108,22 @@ public void testSameHashCodeOnEquals() {
@Test
public void testToAndFromPb() {
assertEquals(record, DnsRecord.fromPb(record.toPb()));
- DnsRecord partial = DnsRecord.builder(NAME, TYPE).build();
+ DnsRecord partial = builder(NAME, TYPE).build();
assertEquals(partial, DnsRecord.fromPb(partial.toPb()));
- partial = DnsRecord.builder(NAME, TYPE).addRecord("test").build();
+ partial = builder(NAME, TYPE).addRecord("test").build();
assertEquals(partial, DnsRecord.fromPb(partial.toPb()));
- partial = DnsRecord.builder(NAME, TYPE).ttl(15).build();
+ partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build();
assertEquals(partial, DnsRecord.fromPb(partial.toPb()));
}
@Test
public void testToBuilder() {
assertEquals(record, record.toBuilder().build());
- DnsRecord partial = DnsRecord.builder(NAME, TYPE).build();
+ DnsRecord partial = builder(NAME, TYPE).build();
assertEquals(partial, partial.toBuilder().build());
- partial = DnsRecord.builder(NAME, TYPE).addRecord("test").build();
+ partial = builder(NAME, TYPE).addRecord("test").build();
assertEquals(partial, partial.toBuilder().build());
- partial = DnsRecord.builder(NAME, TYPE).ttl(15).build();
+ partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build();
assertEquals(partial, partial.toBuilder().build());
}
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java
index 2af8b5ad3995..d959d44d4351 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java
@@ -57,7 +57,7 @@ public void testQuotaConstructor() {
assertEquals(2, QUOTA.resourceRecordsPerRrset());
assertEquals(3, QUOTA.rrsetAdditionsPerChange());
assertEquals(4, QUOTA.rrsetDeletionsPerChange());
- assertEquals(5, QUOTA.rrsetsPerManagedZone());
+ assertEquals(5, QUOTA.rrsetsPerZone());
assertEquals(6, QUOTA.totalRrdataSizePerChange());
}
@@ -101,11 +101,11 @@ public void testSameHashCodeOnEquals() {
public void testToAndFromPb() {
assertEquals(PROJECT_INFO, ProjectInfo.fromPb(PROJECT_INFO.toPb()));
ProjectInfo partial = ProjectInfo.builder().id(ID).build();
- assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb()));
+ assertEquals(partial, ProjectInfo.fromPb(partial.toPb()));
partial = ProjectInfo.builder().number(NUMBER).build();
- assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb()));
+ assertEquals(partial, ProjectInfo.fromPb(partial.toPb()));
partial = ProjectInfo.builder().quota(QUOTA).build();
- assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb()));
+ assertEquals(partial, ProjectInfo.fromPb(partial.toPb()));
assertNotEquals(PROJECT_INFO, partial);
}
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java
similarity index 72%
rename from gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java
rename to gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java
index 936164c81723..2c9fea8f7bde 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java
@@ -30,7 +30,7 @@
import java.util.LinkedList;
import java.util.List;
-public class ManagedZoneInfoTest {
+public class ZoneInfoTest {
private static final String NAME = "mz-example.com";
private static final BigInteger ID = BigInteger.valueOf(123L);
@@ -42,7 +42,7 @@ public class ManagedZoneInfoTest {
private static final String NS2 = "name server 2";
private static final String NS3 = "name server 3";
private static final List NAME_SERVERS = ImmutableList.of(NS1, NS2, NS3);
- private static final ManagedZoneInfo INFO = ManagedZoneInfo.builder(NAME, ID)
+ private static final ZoneInfo INFO = ZoneInfo.builder(NAME, ID)
.creationTimeMillis(CREATION_TIME_MILLIS)
.dnsName(DNS_NAME)
.description(DESCRIPTION)
@@ -52,7 +52,7 @@ public class ManagedZoneInfoTest {
@Test
public void testDefaultBuilders() {
- ManagedZoneInfo withName = ManagedZoneInfo.builder(NAME).build();
+ ZoneInfo withName = ZoneInfo.builder(NAME).build();
assertTrue(withName.nameServers().isEmpty());
assertEquals(NAME, withName.name());
assertNull(withName.id());
@@ -60,7 +60,7 @@ public void testDefaultBuilders() {
assertNull(withName.nameServerSet());
assertNull(withName.description());
assertNull(withName.dnsName());
- ManagedZoneInfo withId = ManagedZoneInfo.builder(ID).build();
+ ZoneInfo withId = ZoneInfo.builder(ID).build();
assertTrue(withId.nameServers().isEmpty());
assertEquals(ID, withId.id());
assertNull(withId.name());
@@ -68,7 +68,7 @@ public void testDefaultBuilders() {
assertNull(withId.nameServerSet());
assertNull(withId.description());
assertNull(withId.dnsName());
- ManagedZoneInfo withBoth = ManagedZoneInfo.builder(NAME, ID).build();
+ ZoneInfo withBoth = ZoneInfo.builder(NAME, ID).build();
assertTrue(withBoth.nameServers().isEmpty());
assertEquals(ID, withBoth.id());
assertEquals(NAME, withBoth.name());
@@ -94,7 +94,7 @@ public void testBuilder() {
@Test
public void testEqualsAndNotEquals() {
- ManagedZoneInfo clone = INFO.toBuilder().build();
+ ZoneInfo clone = INFO.toBuilder().build();
assertEquals(INFO, clone);
List moreServers = Lists.newLinkedList(NAME_SERVERS);
moreServers.add(NS1);
@@ -118,55 +118,55 @@ public void testEqualsAndNotEquals() {
@Test
public void testSameHashCodeOnEquals() {
int hash = INFO.hashCode();
- ManagedZoneInfo clone = INFO.toBuilder().build();
+ ZoneInfo clone = INFO.toBuilder().build();
assertEquals(clone.hashCode(), hash);
}
@Test
public void testToBuilder() {
assertEquals(INFO, INFO.toBuilder().build());
- ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build();
+ ZoneInfo partial = ZoneInfo.builder(NAME).build();
assertEquals(partial, partial.toBuilder().build());
- partial = ManagedZoneInfo.builder(ID).build();
+ partial = ZoneInfo.builder(ID).build();
assertEquals(partial, partial.toBuilder().build());
- partial = ManagedZoneInfo.builder(NAME).description(DESCRIPTION).build();
+ partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build();
assertEquals(partial, partial.toBuilder().build());
- partial = ManagedZoneInfo.builder(NAME).dnsName(DNS_NAME).build();
+ partial = ZoneInfo.builder(NAME).dnsName(DNS_NAME).build();
assertEquals(partial, partial.toBuilder().build());
- partial = ManagedZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build();
+ partial = ZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build();
assertEquals(partial, partial.toBuilder().build());
List nameServers = new LinkedList<>();
nameServers.add(NS1);
- partial = ManagedZoneInfo.builder(NAME).nameServers(nameServers).build();
+ partial = ZoneInfo.builder(NAME).nameServers(nameServers).build();
assertEquals(partial, partial.toBuilder().build());
- partial = ManagedZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build();
+ partial = ZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build();
assertEquals(partial, partial.toBuilder().build());
}
@Test
public void testToAndFromPb() {
- assertEquals(INFO, ManagedZoneInfo.fromPb(INFO.toPb()));
- ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
- partial = ManagedZoneInfo.builder(ID).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
- partial = ManagedZoneInfo.builder(NAME).description(DESCRIPTION).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
- partial = ManagedZoneInfo.builder(NAME).dnsName(DNS_NAME).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
- partial = ManagedZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
+ assertEquals(INFO, ZoneInfo.fromPb(INFO.toPb()));
+ ZoneInfo partial = ZoneInfo.builder(NAME).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
+ partial = ZoneInfo.builder(ID).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
+ partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
+ partial = ZoneInfo.builder(NAME).dnsName(DNS_NAME).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
+ partial = ZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
List nameServers = new LinkedList<>();
nameServers.add(NS1);
- partial = ManagedZoneInfo.builder(NAME).nameServers(nameServers).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
- partial = ManagedZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build();
- assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb()));
+ partial = ZoneInfo.builder(NAME).nameServers(nameServers).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
+ partial = ZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build();
+ assertEquals(partial, ZoneInfo.fromPb(partial.toPb()));
}
@Test
public void testEmptyNameServers() {
- ManagedZoneInfo clone = INFO.toBuilder().nameServers(new LinkedList()).build();
+ ZoneInfo clone = INFO.toBuilder().nameServers(new LinkedList()).build();
assertTrue(clone.nameServers().isEmpty());
clone.toPb(); // test that this is allowed
}
@@ -175,7 +175,7 @@ public void testEmptyNameServers() {
public void testDateParsing() {
com.google.api.services.dns.model.ManagedZone pb = INFO.toPb();
pb.setCreationTime("2016-01-19T18:00:12.854Z"); // a real value obtained from Google Cloud DNS
- ManagedZoneInfo mz = ManagedZoneInfo.fromPb(pb); // parses the string timestamp to millis
+ ZoneInfo mz = ZoneInfo.fromPb(pb); // parses the string timestamp to millis
com.google.api.services.dns.model.ManagedZone pbClone = mz.toPb(); // converts it back to string
assertEquals(pb, pbClone);
assertEquals(pb.getCreationTime(), pbClone.getCreationTime());