Skip to content

Commit

Permalink
Fixed some other minor issues:
Browse files Browse the repository at this point in the history
- added joda formatter to example
- style in ZoneTest
- visibility in LocalDnsHelper
- added private constructor to OptionParsers
- adjusted pom.xml
  • Loading branch information
mderka committed Apr 4, 2016
1 parent 5be34a9 commit b236529
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
1 change: 0 additions & 1 deletion gcloud-java-dns/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.gcloud</groupId>
<artifactId>gcloud-java-dns</artifactId>
<packaging>jar</packaging>
<name>GCloud Java DNS</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class LocalDnsHelper {
}
}

private long delayChange;
private final long delayChange;
private final HttpServer server;
private final int port;

Expand All @@ -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;
Expand Down Expand Up @@ -382,7 +382,7 @@ ConcurrentSkipListMap<String, ProjectContainer> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
*/
class OptionParsers {

private OptionParsers() {
}

static Map<String, Object> parseListZonesOptions(String query) {
Map<String, Object> options = new HashMap<>();
if (query != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private static void waitForChangeToComplete(String zoneName, String changeId) {
while (true) {
ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS));
if (ChangeRequest.Status.DONE.equals(changeRequest.status())) {
if (ChangeRequest.Status.DONE == changeRequest.status()) {
return;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +67,8 @@
public class DnsExample {

private static final Map<String, DnsAction> ACTIONS = new HashMap<>();
private static final DateTimeFormatter FORMATTER =
DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss");

private interface DnsAction {
void run(Dns dns, String... args);
Expand Down Expand Up @@ -331,12 +333,11 @@ public void run(Dns dns, String... args) {
}
if (iterator.hasNext()) {
System.out.printf("Change requests for zone %s:%n", zoneName);
DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
while (iterator.hasNext()) {
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()));
}
Expand Down Expand Up @@ -441,8 +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());
DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
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()));
}

Expand Down

0 comments on commit b236529

Please sign in to comment.