From 6ecde35c355ca8e38e726044e9a0012f5a3935ab Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 1 Feb 2016 16:07:24 -0800 Subject: [PATCH] Comments by @aozarov second round. --- .../main/java/com/google/gcloud/dns/Dns.java | 15 ++++++----- .../google/gcloud/dns/AbstractOptionTest.java | 26 +++++++------------ 2 files changed, 18 insertions(+), 23 deletions(-) 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 352c7791e18d..28e79104cf58 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 @@ -24,6 +24,8 @@ import java.io.Serializable; import java.util.Set; +import static com.google.gcloud.dns.Dns.ZoneField.selector; + /** * An interface for the Google Cloud DNS service. * @@ -31,8 +33,6 @@ */ public interface Dns extends Service { - - /** * The fields of a project. * @@ -284,7 +284,9 @@ class ZoneListOption extends AbstractOption implements Serializable { * specified. {@link ZoneField} provides a list of fields that can be used. */ public static ZoneListOption fields(ZoneField... fields) { - return new ZoneListOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); + StringBuilder builder = new StringBuilder(); + builder.append("managedZones(").append(selector(fields)).append(')'); + return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString()); } /** @@ -381,10 +383,9 @@ class ChangeRequestListOption extends AbstractOption implements Serializable { * a list of fields that can be used. */ public static ChangeRequestListOption fields(ChangeRequestField... fields) { - return new ChangeRequestListOption( - DnsRpc.Option.FIELDS, - ChangeRequestField.selector(fields) - ); + StringBuilder builder = new StringBuilder(); + builder.append("changes(").append(ChangeRequestField.selector(fields)).append(')'); + return new ChangeRequestListOption(DnsRpc.Option.FIELDS, builder.toString()); } /** diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java index 3c578c53d0d1..e3f2896bd10b 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java @@ -16,30 +16,26 @@ package com.google.gcloud.dns; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; - import com.google.gcloud.spi.DnsRpc; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; + public class AbstractOptionTest { private static final DnsRpc.Option RPC_OPTION = DnsRpc.Option.DNS_TYPE; private static final DnsRpc.Option ANOTHER_RPC_OPTION = DnsRpc.Option.DNS_NAME; private static final String VALUE = "some value"; private static final String OTHER_VALUE = "another value"; - private static final AbstractOption OPTION = new AbstractOption(RPC_OPTION, VALUE) { - }; - private static final AbstractOption OPTION_EQUALS = new AbstractOption(RPC_OPTION, VALUE) { - }; + private static final AbstractOption OPTION = new AbstractOption(RPC_OPTION, VALUE) {}; + private static final AbstractOption OPTION_EQUALS = new AbstractOption(RPC_OPTION, VALUE) {}; private static final AbstractOption OPTION_NOT_EQUALS1 = - new AbstractOption(RPC_OPTION, OTHER_VALUE) { - }; + new AbstractOption(RPC_OPTION, OTHER_VALUE) {}; private static final AbstractOption OPTION_NOT_EQUALS2 = - new AbstractOption(ANOTHER_RPC_OPTION, VALUE) { - }; + new AbstractOption(ANOTHER_RPC_OPTION, VALUE) {}; @Test public void testEquals() { @@ -58,13 +54,11 @@ public void testConstructor() { assertEquals(RPC_OPTION, OPTION.rpcOption()); assertEquals(VALUE, OPTION.value()); try { - new AbstractOption(null, VALUE) { - }; + new AbstractOption(null, VALUE) {}; fail("Cannot build with empty option."); } catch (NullPointerException e) { // expected } - new AbstractOption(RPC_OPTION, null) { - }; // null value is ok + new AbstractOption(RPC_OPTION, null) {}; // null value is ok } }