Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added integration tests. #674

Merged
merged 3 commits into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 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 @@ -68,7 +68,8 @@ static String selector(ProjectField... fields) {
* The fields of a zone.
*
* <p>These values can be used to specify the fields to include in a partial response when calling
* {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not specified.
* {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not
* specified.
*/
enum ZoneField {
CREATION_TIME("creationTime"),
Expand Down Expand Up @@ -103,8 +104,8 @@ static String selector(ZoneField... fields) {
* The fields of a DNS record.
*
* <p>These values can be used to specify the fields to include in a partial response when calling
* {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if
* not selected.
* {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name and type are always
* returned even if not selected.
*/
enum DnsRecordField {
DNS_RECORDS("rrdatas"),
Expand All @@ -125,6 +126,7 @@ String selector() {
static String selector(DnsRecordField... fields) {
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1);
fieldStrings.add(NAME.selector());
fieldStrings.add(TYPE.selector());
for (DnsRecordField field : fields) {
fieldStrings.add(field.selector());
}
Expand Down Expand Up @@ -198,7 +200,7 @@ class DnsRecordListOption extends AbstractOption implements Serializable {
*/
public static DnsRecordListOption fields(DnsRecordField... fields) {
StringBuilder builder = new StringBuilder();
builder.append("rrsets(").append(DnsRecordField.selector(fields)).append(')');
builder.append("nextPageToken,rrsets(").append(DnsRecordField.selector(fields)).append(')');
return new DnsRecordListOption(DnsRpc.Option.FIELDS, builder.toString());
}

Expand Down Expand Up @@ -234,7 +236,7 @@ public static DnsRecordListOption dnsName(String dnsName) {
* Dns.DnsRecordListOption#dnsName(String)} must also be present.
*/
public static DnsRecordListOption type(DnsRecord.Type type) {
return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type);
return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type.name());
}
}

Expand Down Expand Up @@ -281,7 +283,7 @@ class ZoneListOption extends AbstractOption implements Serializable {
*/
public static ZoneListOption fields(ZoneField... fields) {
StringBuilder builder = new StringBuilder();
builder.append("managedZones(").append(ZoneField.selector(fields)).append(')');
builder.append("nextPageToken,managedZones(").append(ZoneField.selector(fields)).append(')');
return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString());
}

Expand Down Expand Up @@ -388,7 +390,8 @@ class ChangeRequestListOption extends AbstractOption implements Serializable {
*/
public static ChangeRequestListOption fields(ChangeRequestField... fields) {
StringBuilder builder = new StringBuilder();
builder.append("changes(").append(ChangeRequestField.selector(fields)).append(')');
builder.append("nextPageToken,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 @@ -162,7 +162,9 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map<Opti
} catch (IOException ex) {
DnsException serviceException = translate(ex);
if (serviceException.code() == HTTP_NOT_FOUND) {
if (serviceException.location().equals("entity.parameters.changeId")) {
if ("entity.parameters.changeId".equals(serviceException.location())
|| (serviceException.getMessage() != null
&& serviceException.getMessage().contains("parameters.changeId"))) {
// the change id was not found, but the zone exists
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public void testListDnsRecordsWithOptions() {
assertTrue(selector.contains(Dns.DnsRecordField.TTL.selector()));
selector = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[3].rpcOption());
assertEquals(DNS_RECORD_LIST_OPTIONS[3].value(), selector);
DnsRecord.Type type = (DnsRecord.Type) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[4]
String type = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[4]
.rpcOption());
assertEquals(DNS_RECORD_LIST_OPTIONS[4].value(), type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testDnsRecordListOption() {
// record type
DnsRecord.Type recordType = DnsRecord.Type.AAAA;
dnsRecordListOption = Dns.DnsRecordListOption.type(recordType);
assertEquals(recordType, dnsRecordListOption.value());
assertEquals(recordType.name(), dnsRecordListOption.value());
assertEquals(DnsRpc.Option.DNS_TYPE, dnsRecordListOption.rpcOption());
// fields
dnsRecordListOption = Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME,
Expand Down
Loading