diff --git a/gcloud-java-dns/pom.xml b/gcloud-java-dns/pom.xml
index e7a02452d92f..a4928ccf0397 100644
--- a/gcloud-java-dns/pom.xml
+++ b/gcloud-java-dns/pom.xml
@@ -3,7 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.google.gcloud
gcloud-java-dns
jar
GCloud Java DNS
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java
index 66e841c20a15..b3a2a2170d8b 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java
@@ -221,7 +221,7 @@ static ChangeRequest fromPb(Dns dns, String zoneName, Change pb) {
static Function fromPbFunction(final Dns dns, final String zoneName) {
return new Function() {
@Override
- public ChangeRequest apply(com.google.api.services.dns.model.Change pb) {
+ public ChangeRequest apply(Change pb) {
return ChangeRequest.fromPb(dns, zoneName, pb);
}
};
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
index a78eaef7c4e7..2216733ca779 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
@@ -23,7 +23,6 @@
import com.google.gcloud.Service;
import com.google.gcloud.dns.spi.DnsRpc;
-import java.io.Serializable;
import java.util.List;
/**
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java
index 9f4fa2a9d9d1..3218daa543b2 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java
@@ -17,11 +17,11 @@
package com.google.gcloud.dns;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.gcloud.RetryHelper.RetryHelperException;
import static com.google.gcloud.RetryHelper.runWithRetries;
import com.google.api.services.dns.model.Change;
import com.google.api.services.dns.model.ManagedZone;
+import com.google.api.services.dns.model.Project;
import com.google.api.services.dns.model.ResourceRecordSet;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -121,8 +121,7 @@ private static Page listZones(final DnsOptions serviceOptions,
// this differs from the other list operations since zone is functional and requires dns service
Function pbToZoneFunction = new Function() {
@Override
- public Zone apply(
- com.google.api.services.dns.model.ManagedZone zonePb) {
+ public Zone apply(ManagedZone zonePb) {
return Zone.fromPb(serviceOptions.service(), zonePb);
}
};
@@ -142,7 +141,7 @@ public DnsRpc.ListResult call() {
? ImmutableList.of() : Iterables.transform(result.results(), pbToZoneFunction);
return new PageImpl<>(new ZonePageFetcher(serviceOptions, cursor, optionsMap),
cursor, zones);
- } catch (RetryHelperException e) {
+ } catch (RetryHelper.RetryHelperException e) {
throw DnsException.translateAndThrow(e);
}
}
@@ -169,10 +168,10 @@ public DnsRpc.ListResult call() {
Iterable changes = result.results() == null
? ImmutableList.of()
: Iterables.transform(result.results(),
- ChangeRequest.fromPbFunction(serviceOptions.service(), zoneName));
+ ChangeRequest.fromPbFunction(serviceOptions.service(), zoneName));
return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor,
optionsMap), cursor, changes);
- } catch (RetryHelperException e) {
+ } catch (RetryHelper.RetryHelperException e) {
throw DnsException.translateAndThrow(e);
}
}
@@ -201,7 +200,7 @@ public DnsRpc.ListResult call() {
: Iterables.transform(result.results(), RecordSet.FROM_PB_FUNCTION);
return new PageImpl<>(new DnsRecordPageFetcher(zoneName, serviceOptions, cursor, optionsMap),
cursor, recordSets);
- } catch (RetryHelperException e) {
+ } catch (RetryHelper.RetryHelperException e) {
throw DnsException.translateAndThrow(e);
}
}
@@ -210,10 +209,10 @@ public DnsRpc.ListResult call() {
public Zone create(final ZoneInfo zoneInfo, Dns.ZoneOption... options) {
final Map optionsMap = optionMap(options);
try {
- com.google.api.services.dns.model.ManagedZone answer = runWithRetries(
- new Callable() {
+ ManagedZone answer = runWithRetries(
+ new Callable() {
@Override
- public com.google.api.services.dns.model.ManagedZone call() {
+ public ManagedZone call() {
return dnsRpc.create(zoneInfo.toPb(), optionsMap);
}
}, options().retryParams(), EXCEPTION_HANDLER);
@@ -227,10 +226,10 @@ public com.google.api.services.dns.model.ManagedZone call() {
public Zone getZone(final String zoneName, Dns.ZoneOption... options) {
final Map optionsMap = optionMap(options);
try {
- com.google.api.services.dns.model.ManagedZone answer = runWithRetries(
- new Callable() {
+ ManagedZone answer = runWithRetries(
+ new Callable() {
@Override
- public com.google.api.services.dns.model.ManagedZone call() {
+ public ManagedZone call() {
return dnsRpc.getZone(zoneName, optionsMap);
}
}, options().retryParams(), EXCEPTION_HANDLER);
@@ -258,10 +257,10 @@ public Boolean call() {
public ProjectInfo getProject(Dns.ProjectOption... fields) {
final Map optionsMap = optionMap(fields);
try {
- com.google.api.services.dns.model.Project answer = runWithRetries(
- new Callable() {
+ Project answer = runWithRetries(
+ new Callable() {
@Override
- public com.google.api.services.dns.model.Project call() {
+ public Project call() {
return dnsRpc.getProject(optionsMap);
}
}, options().retryParams(), EXCEPTION_HANDLER);
@@ -276,14 +275,13 @@ public ChangeRequest applyChangeRequest(final String zoneName,
final ChangeRequestInfo changeRequest, ChangeRequestOption... options) {
final Map optionsMap = optionMap(options);
try {
- com.google.api.services.dns.model.Change answer =
- runWithRetries(
- new Callable() {
- @Override
- public com.google.api.services.dns.model.Change call() {
- return dnsRpc.applyChangeRequest(zoneName, changeRequest.toPb(), optionsMap);
- }
- }, options().retryParams(), EXCEPTION_HANDLER);
+ Change answer = runWithRetries(
+ new Callable() {
+ @Override
+ public Change call() {
+ return dnsRpc.applyChangeRequest(zoneName, changeRequest.toPb(), optionsMap);
+ }
+ }, options().retryParams(), EXCEPTION_HANDLER);
return answer == null ? null : ChangeRequest.fromPb(this, zoneName, answer); // not null
} catch (RetryHelper.RetryHelperException ex) {
throw DnsException.translateAndThrow(ex);
@@ -295,14 +293,13 @@ public ChangeRequest getChangeRequest(final String zoneName, final String change
Dns.ChangeRequestOption... options) {
final Map optionsMap = optionMap(options);
try {
- com.google.api.services.dns.model.Change answer =
- runWithRetries(
- new Callable() {
- @Override
- public com.google.api.services.dns.model.Change call() {
- return dnsRpc.getChangeRequest(zoneName, changeRequestId, optionsMap);
- }
- }, options().retryParams(), EXCEPTION_HANDLER);
+ Change answer = runWithRetries(
+ new Callable() {
+ @Override
+ public Change call() {
+ return dnsRpc.getChangeRequest(zoneName, changeRequestId, optionsMap);
+ }
+ }, options().retryParams(), EXCEPTION_HANDLER);
return answer == null ? null : ChangeRequest.fromPb(this, zoneName, answer);
} catch (RetryHelper.RetryHelperException ex) {
throw DnsException.translateAndThrow(ex);
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 319f06ad2444..52edb25ec902 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
@@ -18,6 +18,7 @@
import static com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull;
+import com.google.api.services.dns.model.Project;
import com.google.common.base.MoreObjects;
import java.io.Serializable;
@@ -143,14 +144,13 @@ com.google.api.services.dns.model.Quota toPb() {
}
static Quota fromPb(com.google.api.services.dns.model.Quota pb) {
- Quota quota = new Quota(pb.getManagedZones(),
+ return new Quota(pb.getManagedZones(),
pb.getResourceRecordsPerRrset(),
pb.getRrsetAdditionsPerChange(),
pb.getRrsetDeletionsPerChange(),
pb.getRrsetsPerManagedZone(),
pb.getTotalRrdataSizePerChange()
);
- return quota;
}
@Override
@@ -243,8 +243,8 @@ String id() {
return id;
}
- com.google.api.services.dns.model.Project toPb() {
- com.google.api.services.dns.model.Project pb = new com.google.api.services.dns.model.Project();
+ Project toPb() {
+ Project pb = new Project();
pb.setId(id);
pb.setNumber(number);
if (this.quota != null) {
@@ -253,7 +253,7 @@ com.google.api.services.dns.model.Project toPb() {
return pb;
}
- static ProjectInfo fromPb(com.google.api.services.dns.model.Project pb) {
+ static ProjectInfo fromPb(Project pb) {
Builder builder = builder();
if (pb.getId() != null) {
builder.id(pb.getId());
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java
index dc6d956406c3..90beedba1d89 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java
@@ -285,9 +285,8 @@ public boolean equals(Object obj) {
return obj instanceof RecordSet && Objects.equals(this.toPb(), ((RecordSet) obj).toPb());
}
- com.google.api.services.dns.model.ResourceRecordSet toPb() {
- com.google.api.services.dns.model.ResourceRecordSet pb =
- new com.google.api.services.dns.model.ResourceRecordSet();
+ ResourceRecordSet toPb() {
+ ResourceRecordSet pb = new ResourceRecordSet();
pb.setName(this.name());
pb.setRrdatas(this.records());
pb.setTtl(this.ttl());
@@ -295,7 +294,7 @@ com.google.api.services.dns.model.ResourceRecordSet toPb() {
return pb;
}
- static RecordSet fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) {
+ static RecordSet fromPb(ResourceRecordSet pb) {
Builder builder = builder(pb.getName(), Type.valueOf(pb.getType()));
if (pb.getRrdatas() != null) {
builder.records(pb.getRrdatas());
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java
index 6e22bfc6785a..c4250bd206eb 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.api.services.dns.model.ManagedZone;
import com.google.gcloud.Page;
import java.io.IOException;
@@ -205,12 +206,12 @@ public int hashCode() {
return Objects.hash(super.hashCode(), options);
}
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
this.dns = options.service();
}
- static Zone fromPb(Dns dns, com.google.api.services.dns.model.ManagedZone zone) {
+ static Zone fromPb(Dns dns, ManagedZone zone) {
ZoneInfo info = ZoneInfo.fromPb(zone);
return new Zone(dns, new ZoneInfo.BuilderImpl(info));
}
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java
index a0ee24bc5948..03c23a6ce3d3 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.api.services.dns.model.ManagedZone;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -248,9 +249,9 @@ public Builder toBuilder() {
return new BuilderImpl(this);
}
- com.google.api.services.dns.model.ManagedZone toPb() {
- com.google.api.services.dns.model.ManagedZone pb =
- new com.google.api.services.dns.model.ManagedZone();
+ ManagedZone toPb() {
+ ManagedZone pb =
+ new ManagedZone();
pb.setDescription(this.description());
pb.setDnsName(this.dnsName());
if (this.generatedId() != null) {
@@ -267,7 +268,7 @@ com.google.api.services.dns.model.ManagedZone toPb() {
return pb;
}
- static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) {
+ static ZoneInfo fromPb(ManagedZone pb) {
Builder builder = new BuilderImpl(pb.getName());
if (pb.getDescription() != null) {
builder.description(pb.getDescription());
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java
index 0ae2c37b9b4d..54edcddb5ade 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java
@@ -122,7 +122,7 @@ public class LocalDnsHelper {
}
}
- private long delayChange;
+ private final long delayChange;
private final HttpServer server;
private final int port;
@@ -140,8 +140,8 @@ private enum CallRegex {
PROJECT_GET("GET", CONTEXT + "/[^/]+"),
RECORD_LIST("GET", CONTEXT + "/[^/]+/managedZones/[^/]+/rrsets");
- private String method;
- private String pathRegex;
+ private final String method;
+ private final String pathRegex;
CallRegex(String method, String pathRegex) {
this.pathRegex = pathRegex;
@@ -382,7 +382,7 @@ ConcurrentSkipListMap projects() {
}
/**
- * Creates new {@link LocalDnsHelper} instance that listens to requests on the local machine. This
+ * Creates new {@code LocalDnsHelper} instance that listens to requests on the local machine. This
* instance processes changes in separate thread. The parameter determines how long a thread
* should wait before processing a change. If it is set to 0, the threading is turned off and the
* mock will behave synchronously.
diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java
index 578a0b52db3d..bd773a931ef2 100644
--- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java
+++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java
@@ -29,6 +29,9 @@
*/
class OptionParsers {
+ private OptionParsers() {
+ }
+
static Map parseListZonesOptions(String query) {
Map options = new HashMap<>();
if (query != null) {
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java
index f3ae7a586391..136a6e0d56ec 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.api.services.dns.model.Change;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
@@ -209,7 +210,7 @@ public void testRemoveDeletion() {
@Test
public void testDateParsing() {
String startTime = "2016-01-26T18:33:43.512Z"; // obtained from service
- com.google.api.services.dns.model.Change change = CHANGE.toPb().setStartTime(startTime);
+ Change change = CHANGE.toPb().setStartTime(startTime);
ChangeRequestInfo converted = ChangeRequest.fromPb(change);
assertNotNull(converted.startTimeMillis());
assertEquals(change, converted.toPb());
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java
index d9d657ee03e7..c359871b998c 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java
@@ -21,6 +21,7 @@
import com.google.api.services.dns.model.Change;
import com.google.api.services.dns.model.ManagedZone;
+import com.google.api.services.dns.model.ResourceRecordSet;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
@@ -69,8 +70,7 @@ public class DnsImplTest {
CHANGE_REQUEST_PARTIAL.toPb()));
private static final DnsRpc.ListResult LIST_RESULT_OF_PB_ZONES =
DnsRpc.ListResult.of("cursor", ImmutableList.of(ZONE_INFO.toPb()));
- private static final DnsRpc.ListResult
- LIST_OF_PB_DNS_RECORDS =
+ private static final DnsRpc.ListResult LIST_OF_PB_DNS_RECORDS =
DnsRpc.ListResult.of("cursor", ImmutableList.of(DNS_RECORD1.toPb(), DNS_RECORD2.toPb()));
// Field options
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java
index 369e078a48c7..fc888bf8a697 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java
@@ -16,7 +16,6 @@
package com.google.gcloud.dns;
-import static com.google.gcloud.dns.RecordSet.builder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@@ -33,13 +32,13 @@ 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 = builder(NAME, TYPE)
+ private static final RecordSet recordSet = RecordSet.builder(NAME, TYPE)
.ttl(UNIT_TTL, UNIT)
.build();
@Test
public void testDefaultDnsRecord() {
- RecordSet recordSet = builder(NAME, TYPE).build();
+ RecordSet recordSet = RecordSet.builder(NAME, TYPE).build();
assertEquals(0, recordSet.records().size());
assertEquals(TYPE, recordSet.type());
assertEquals(NAME, recordSet.name());
@@ -66,15 +65,15 @@ public void testBuilder() {
@Test
public void testValidTtl() {
try {
- builder(NAME, TYPE).ttl(-1, TimeUnit.SECONDS);
+ RecordSet.builder(NAME, TYPE).ttl(-1, TimeUnit.SECONDS);
fail("A negative value is not acceptable for ttl.");
} catch (IllegalArgumentException e) {
// expected
}
- builder(NAME, TYPE).ttl(0, TimeUnit.SECONDS);
- builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.SECONDS);
+ RecordSet.builder(NAME, TYPE).ttl(0, TimeUnit.SECONDS);
+ RecordSet.builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.SECONDS);
try {
- builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.HOURS);
+ RecordSet.builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.HOURS);
fail("This value is too large for int.");
} catch (IllegalArgumentException e) {
// expected
@@ -108,22 +107,22 @@ public void testSameHashCodeOnEquals() {
@Test
public void testToAndFromPb() {
assertEquals(recordSet, RecordSet.fromPb(recordSet.toPb()));
- RecordSet partial = builder(NAME, TYPE).build();
+ RecordSet partial = RecordSet.builder(NAME, TYPE).build();
assertEquals(partial, RecordSet.fromPb(partial.toPb()));
- partial = builder(NAME, TYPE).addRecord("test").build();
+ partial = RecordSet.builder(NAME, TYPE).addRecord("test").build();
assertEquals(partial, RecordSet.fromPb(partial.toPb()));
- partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build();
+ partial = RecordSet.builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build();
assertEquals(partial, RecordSet.fromPb(partial.toPb()));
}
@Test
public void testToBuilder() {
assertEquals(recordSet, recordSet.toBuilder().build());
- RecordSet partial = builder(NAME, TYPE).build();
+ RecordSet partial = RecordSet.builder(NAME, TYPE).build();
assertEquals(partial, partial.toBuilder().build());
- partial = builder(NAME, TYPE).addRecord("test").build();
+ partial = RecordSet.builder(NAME, TYPE).addRecord("test").build();
assertEquals(partial, partial.toBuilder().build());
- partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build();
+ partial = RecordSet.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/ZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java
index d0a64a61b816..b537735c3c4e 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java
@@ -21,6 +21,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import com.google.api.services.dns.model.ManagedZone;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -155,10 +156,10 @@ public void testEmptyNameServers() {
@Test
public void testDateParsing() {
- com.google.api.services.dns.model.ManagedZone pb = INFO.toPb();
+ ManagedZone pb = INFO.toPb();
pb.setCreationTime("2016-01-19T18:00:12.854Z"); // a real value obtained from Google Cloud DNS
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
+ ManagedZone pbClone = mz.toPb(); // converts it back to string
assertEquals(pb, pbClone);
assertEquals(pb.getCreationTime(), pbClone.getCreationTime());
}
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java
index f14addfc44b6..5407d4f248b7 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java
@@ -349,7 +349,7 @@ public void getChangedWhichDoesNotExistZoneFound() {
assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId()));
assertNull(zone.getChangeRequest(CHANGE_REQUEST.generatedId()));
assertNull(
- zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(),CHANGE_REQUEST_FIELD_OPTIONS));
+ zoneNoId.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS));
assertNull(zone.getChangeRequest(CHANGE_REQUEST.generatedId(), CHANGE_REQUEST_FIELD_OPTIONS));
}
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java
index f25bd537cd72..e6513451e7f6 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java
@@ -87,6 +87,9 @@ public class ITDnsTest {
.build();
private static final List ZONE_NAMES = ImmutableList.of(ZONE_NAME1,
ZONE_NAME_EMPTY_DESCRIPTION);
+
+ @Rule
+ public Timeout globalTimeout = Timeout.seconds(300);
private static void clear() {
for (String zoneName : ZONE_NAMES) {
@@ -162,9 +165,6 @@ private static void waitForChangeToComplete(ChangeRequest changeRequest) {
}
}
- @Rule
- public Timeout globalTimeout = Timeout.seconds(300);
-
@Test
public void testCreateValidZone() {
try {
@@ -472,7 +472,7 @@ public void testListZones() {
assertNull(zone.dnsName());
assertNull(zone.description());
assertNull(zone.nameServerSet());
- assertTrue(!zone.nameServers().isEmpty());
+ assertFalse(zone.nameServers().isEmpty());
assertNull(zone.generatedId());
assertFalse(zoneIterator.hasNext());
zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()),
diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java
index 44516f47c657..315a47c5bb7c 100644
--- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java
+++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java
@@ -119,13 +119,6 @@ private static void resetProjects() {
}
}
- private static void assertEqChangesIgnoreStatus(Change expected, Change actual) {
- assertEquals(expected.getAdditions(), actual.getAdditions());
- assertEquals(expected.getDeletions(), actual.getDeletions());
- assertEquals(expected.getId(), actual.getId());
- assertEquals(expected.getStartTime(), actual.getStartTime());
- }
-
@Test
public void testCreateZone() {
ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS);
diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java
index e5f0cf01a6c9..d0cda485e9f5 100644
--- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java
+++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java
@@ -27,10 +27,10 @@
import com.google.gcloud.dns.Zone;
import com.google.gcloud.dns.ZoneInfo;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
import java.util.Arrays;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -67,7 +67,8 @@
public class DnsExample {
private static final Map ACTIONS = new HashMap<>();
- private static final DateFormat FORMATTER = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
+ private static final DateTimeFormatter FORMATTER =
+ DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss");
private interface DnsAction {
void run(Dns dns, String... args);
@@ -336,7 +337,7 @@ public void run(Dns dns, String... args) {
ChangeRequest change = iterator.next();
System.out.printf("%nID: %s%n", change.generatedId());
System.out.printf("Status: %s%n", change.status());
- System.out.printf("Started: %s%n", FORMATTER.format(change.startTimeMillis()));
+ System.out.printf("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()));
}
@@ -441,7 +442,7 @@ 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.format(new Date(zone.creationTimeMillis())));
+ System.out.printf("Created: %s%n", FORMATTER.print(zone.creationTimeMillis()));
System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers()));
}