From d9fce149e3e1b218c13b63fdc6ca425d5d19d8f4 Mon Sep 17 00:00:00 2001 From: adriancole Date: Mon, 25 Mar 2013 17:19:58 -0700 Subject: [PATCH] made it possible to replace a value in the ultradns record builder --- .../ultradns/ws/domain/ResourceRecord.java | 18 ++++++++++++++++-- .../ZoneAndResourceRecordToXMLTest.java | 17 +++++++++++------ .../features/ResourceRecordApiExpectTest.java | 7 +++++-- .../ws/features/ResourceRecordApiLiveTest.java | 10 ++++++---- .../ws/features/RoundRobinPoolApiLiveTest.java | 14 ++++++++++---- ...sourceRecordsOfDNameByTypeResponseTest.java | 18 ++++++++++-------- 6 files changed, 58 insertions(+), 26 deletions(-) diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ResourceRecord.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ResourceRecord.java index ea4d97c3f8..3ade4b95b7 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ResourceRecord.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ResourceRecord.java @@ -135,18 +135,32 @@ public class ResourceRecord { } /** + * adds to current values + * * @see ResourceRecord#getRData() */ - public Builder rdata(Object infoValue) { + public Builder infoValue(Object infoValue) { this.infoValues.add(infoValue.toString()); return this; } /** + * replaces current values + * + * @see ResourceRecord#getRData() + */ + public Builder rdata(Object infoValue) { + this.infoValues = ImmutableList. builder().add(infoValue.toString()); + return this; + } + + /** + * replaces current values + * * @see ResourceRecord#getRData() */ public Builder rdata(Iterable infoValues) { - this.infoValues.addAll(transform(infoValues, toStringFunction())); + this.infoValues = ImmutableList. builder().addAll(transform(infoValues, toStringFunction())); return this; } diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/binders/ZoneAndResourceRecordToXMLTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/binders/ZoneAndResourceRecordToXMLTest.java index bc1f2271bf..24b7b4be57 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/binders/ZoneAndResourceRecordToXMLTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/binders/ZoneAndResourceRecordToXMLTest.java @@ -33,17 +33,22 @@ public class ZoneAndResourceRecordToXMLTest { String A = ""; public void testA() { - assertEquals( - ZoneAndResourceRecordToXML.toXML("jclouds.org.", ResourceRecord.rrBuilder().name("www.jclouds.org.") - .type(1).ttl(3600).rdata("1.1.1.1").build()), A); + assertEquals(ZoneAndResourceRecordToXML.toXML("jclouds.org.", ResourceRecord.rrBuilder() + .name("www.jclouds.org.") + .type(1) + .ttl(3600) + .rdata("1.1.1.1").build()), A); } String MX = ""; public void testMX() { - assertEquals( - ZoneAndResourceRecordToXML.toXML("jclouds.org.", ResourceRecord.rrBuilder().name("mail.jclouds.org.") - .type(15).ttl(1800).rdata(10).rdata("maileast.jclouds.org.").build()), MX); + assertEquals(ZoneAndResourceRecordToXML.toXML("jclouds.org.", ResourceRecord.rrBuilder() + .name("mail.jclouds.org.") + .type(15) + .ttl(1800) + .infoValue(10) + .infoValue("maileast.jclouds.org.").build()), MX); } String A_UPDATE = ""; diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiExpectTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiExpectTest.java index 8bc1a96554..7423114b5a 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiExpectTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiExpectTest.java @@ -45,8 +45,11 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest { HttpResponse createResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResourceWithContentType("/rr_created.xml", "application/xml")).build(); - ResourceRecord record = rrBuilder().name("mail.jclouds.org.").type(15).ttl(1800).rdata(10) - .rdata("maileast.jclouds.org.").build(); + ResourceRecord record = rrBuilder().name("mail.jclouds.org.") + .type(15) + .ttl(1800) + .infoValue(10) + .infoValue("maileast.jclouds.org.").build(); public void testCreateWhenResponseIs2xx() { UltraDNSWSApi success = requestSendsResponse(create, createResponse); diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiLiveTest.java index 18920a2d63..c4e0c01d8e 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ResourceRecordApiLiveTest.java @@ -124,8 +124,7 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest { @Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "No Resource Record with GUID found in the system") public void testUpdateWhenNotFound() { - api(zoneName).update("AAAAAAAAAAAAAAAA", - rrBuilder().name("mail." + zoneName).type(15).ttl(1800).rdata(10).rdata("maileast.jclouds.org.").build()); + api(zoneName).update("AAAAAAAAAAAAAAAA", mx); } @Test @@ -134,8 +133,11 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest { } String guid; - ResourceRecord mx = rrBuilder().name("mail." + zoneName).type(15).ttl(1800).rdata(10) - .rdata("maileast.jclouds.org.").build(); + ResourceRecord mx = rrBuilder().name("mail." + zoneName) + .type(15) + .ttl(1800) + .infoValue(10) + .infoValue("maileast.jclouds.org.").build(); @Test public void testCreateRecord() { diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/RoundRobinPoolApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/RoundRobinPoolApiLiveTest.java index 651b86aff3..8423ed9a96 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/RoundRobinPoolApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/RoundRobinPoolApiLiveTest.java @@ -195,15 +195,21 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest { getAnonymousLogger().info("created AAAA record: " + aaaaRecord1); assertTrue(listRRs(aaaaPoolId).anyMatch( - equalTo(rrBuilder().name(hostname).type(28).ttl(1).rdata("2001:0DB8:85A3:0000:0000:8A2E:0370:7334") - .build()))); + equalTo(rrBuilder().name(hostname) + .type(28) + .ttl(1) + .rdata("2001:0DB8:85A3:0000:0000:8A2E:0370:7334") + .build()))); aaaaRecord2 = api(zoneName).addAAAARecordWithAddressAndTTL(aaaaPoolId, "2002:0DB8:85A3:0000:0000:8A2E:0370:7334", 1); assertTrue(listRRs(aaaaPoolId).anyMatch( - equalTo(rrBuilder().name(hostname).type(28).ttl(1).rdata("2002:0DB8:85A3:0000:0000:8A2E:0370:7334") - .build()))); + equalTo(rrBuilder().name(hostname) + .type(28) + .ttl(1) + .rdata("2002:0DB8:85A3:0000:0000:8A2E:0370:7334") + .build()))); getAnonymousLogger().info("created AAAA record: " + aaaaRecord1); try { diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/GetResourceRecordsOfDNameByTypeResponseTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/GetResourceRecordsOfDNameByTypeResponseTest.java index 7a04f66188..64483a177b 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/GetResourceRecordsOfDNameByTypeResponseTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/GetResourceRecordsOfDNameByTypeResponseTest.java @@ -58,14 +58,16 @@ public class GetResourceRecordsOfDNameByTypeResponseTest extends BaseHandlerTest .zoneName("adrianc.rr.ultradnstest.jclouds.org.") .created(dateService.iso8601DateParse("2013-02-22T08:22:48.000Z")) .modified(dateService.iso8601DateParse("2013-02-22T08:22:49.000Z")) - .record(rrBuilder().type(6).name("adrianc.rr.ultradnstest.jclouds.org.").ttl(86400) - .rdata("pdns75.ultradns.com.") - .rdata("adrianc.netflix.com.") - .rdata("2013022200") - .rdata("86400") - .rdata("86400") - .rdata("86400") - .rdata("86400").build()).build(); + .record(rrBuilder().name("adrianc.rr.ultradnstest.jclouds.org.") + .type(6) + .ttl(86400) + .infoValue("pdns75.ultradns.com.") + .infoValue("adrianc.netflix.com.") + .infoValue("2013022200") + .infoValue("86400") + .infoValue("86400") + .infoValue("86400") + .infoValue("86400").build()).build(); return FluentIterable.from(ImmutableList.of(record)); } }