Skip to content

Commit

Permalink
Comments by @aozarov second round.
Browse files Browse the repository at this point in the history
  • Loading branch information
mderka committed Feb 2, 2016
1 parent a9cc927 commit 6ecde35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
15 changes: 8 additions & 7 deletions gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
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.
*
* @see <a href="https://cloud.google.com/dns/docs">Google Cloud DNS</a>
*/
public interface Dns extends Service<DnsOptions> {



/**
* The fields of a project.
*
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
}

0 comments on commit 6ecde35

Please sign in to comment.