made it possible to replace a value in the ultradns record builder

This commit is contained in:
adriancole 2013-03-25 17:19:58 -07:00
parent d8b227085c
commit a92cd40806
6 changed files with 58 additions and 26 deletions

View File

@ -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.<String> 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.<String> builder().addAll(transform(infoValues, toStringFunction()));
return this;
}

View File

@ -33,17 +33,22 @@ public class ZoneAndResourceRecordToXMLTest {
String A = "<v01:createResourceRecord><transactionID /><resourceRecord ZoneName=\"jclouds.org.\" Type=\"1\" DName=\"www.jclouds.org.\" TTL=\"3600\"><InfoValues Info1Value=\"1.1.1.1\" /></resourceRecord></v01:createResourceRecord>";
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 = "<v01:createResourceRecord><transactionID /><resourceRecord ZoneName=\"jclouds.org.\" Type=\"15\" DName=\"mail.jclouds.org.\" TTL=\"1800\"><InfoValues Info1Value=\"10\" Info2Value=\"maileast.jclouds.org.\" /></resourceRecord></v01:createResourceRecord>";
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 = "<v01:updateResourceRecord><transactionID /><resourceRecord Guid=\"ABCDEF\" ZoneName=\"jclouds.org.\" Type=\"1\" DName=\"www.jclouds.org.\" TTL=\"3600\"><InfoValues Info1Value=\"1.1.1.1\" /></resourceRecord></v01:updateResourceRecord>";

View File

@ -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);

View File

@ -123,8 +123,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
@ -133,8 +132,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() {

View File

@ -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 {

View File

@ -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));
}
}