Updated Branches: refs/heads/master 5e970e1e1 -> cbc42fdeb
JCLOUDS-78: Fix record pagination problem. Backfill tests. Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/cbc42fde Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/cbc42fde Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/cbc42fde Branch: refs/heads/master Commit: cbc42fdeb2c2a4207c720948f57eb1836e89ff24 Parents: 5e970e1 Author: Everett Toews <[email protected]> Authored: Wed May 22 19:05:41 2013 -0600 Committer: Everett Toews <[email protected]> Committed: Thu May 23 11:46:33 2013 -0600 ---------------------------------------------------------------------- .../v1/functions/RecordsToPagedIterable.java | 2 +- .../clouddns/v1/features/DomainApiExpectTest.java | 58 +++++++++++++++ .../clouddns/v1/features/RecordApiExpectTest.java | 20 +++++ .../src/test/resources/domain-list-page1.json | 47 ++++++++++++ .../src/test/resources/domain-list-page2.json | 47 ++++++++++++ .../src/test/resources/record-list-page1.json | 48 ++++++++++++ .../src/test/resources/record-list-page2.json | 48 ++++++++++++ .../src/test/resources/subdomain-list-page1.json | 39 ++++++++++ .../src/test/resources/subdomain-list-page2.json | 39 ++++++++++ .../src/test/resources/subdomain-list.json | 33 ++++++++ 10 files changed, 380 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/functions/RecordsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/functions/RecordsToPagedIterable.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/functions/RecordsToPagedIterable.java index b3ffada..3bab55c 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/functions/RecordsToPagedIterable.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/functions/RecordsToPagedIterable.java @@ -36,7 +36,7 @@ import com.google.common.base.Optional; * @author Everett Toews */ @Beta -public class RecordsToPagedIterable extends Arg0ToPagedIterable<RecordDetail, RecordsToPagedIterable> { +public class RecordsToPagedIterable extends Arg0ToPagedIterable.FromCaller<RecordDetail, RecordsToPagedIterable> { private final CloudDNSApi api; http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/DomainApiExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/DomainApiExpectTest.java b/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/DomainApiExpectTest.java index 383c182..a2f4d3b 100644 --- a/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/DomainApiExpectTest.java +++ b/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/DomainApiExpectTest.java @@ -39,6 +39,7 @@ import org.jclouds.rackspace.clouddns.v1.domain.Domain; import org.jclouds.rackspace.clouddns.v1.domain.DomainChange; import org.jclouds.rackspace.clouddns.v1.domain.Job; import org.jclouds.rackspace.clouddns.v1.domain.Record; +import org.jclouds.rackspace.clouddns.v1.domain.Subdomain; import org.jclouds.rackspace.clouddns.v1.domain.UpdateDomain; import org.jclouds.rackspace.clouddns.v1.functions.DomainFunctions; import org.jclouds.rackspace.clouddns.v1.internal.BaseCloudDNSApiExpectTest; @@ -143,6 +144,63 @@ public class DomainApiExpectTest extends BaseCloudDNSApiExpectTest<CloudDNSApi> } } + public void testListDomainsPaginated() { + URI endpointPage1 = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains"); + URI endpointPage2 = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains?limit=4&offset=4"); + DomainApi api = requestsSendResponses( + rackspaceAuthWithUsernameAndApiKey, + responseWithAccess, + authenticatedGET().endpoint(endpointPage1).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/domain-list-page1.json")).build(), + authenticatedGET().endpoint(endpointPage2).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/domain-list-page2.json")).build()) + .getDomainApi(); + + ImmutableList<Domain> domains = api.list().concat().toList(); + assertEquals(domains.size(), 8); + + for (Domain domain: domains) { + assertTrue(domain.getName().contains(JCLOUDS_EXAMPLE)); + } + } + + public void testListSubdomains() { + URI endpoint = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/subdomains"); + DomainApi api = requestsSendResponses( + rackspaceAuthWithUsernameAndApiKey, + responseWithAccess, + authenticatedGET().endpoint(endpoint).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/subdomain-list.json")).build()) + .getDomainApi(); + + ImmutableList<Subdomain> subdomains = api.listSubdomains(3650908).concat().toList(); + assertEquals(subdomains.size(), 4); + + for (Subdomain subdomain: subdomains) { + assertTrue(subdomain.getName().contains(JCLOUDS_EXAMPLE)); + } + } + + public void testListSubdomainsPaginated() { + URI endpointPage1 = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/subdomains"); + URI endpointPage2 = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/subdomains?limit=4&offset=4"); + DomainApi api = requestsSendResponses( + rackspaceAuthWithUsernameAndApiKey, + responseWithAccess, + authenticatedGET().endpoint(endpointPage1).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/subdomain-list-page1.json")).build(), + authenticatedGET().endpoint(endpointPage2).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/subdomain-list-page2.json")).build()) + .getDomainApi(); + + ImmutableList<Subdomain> subdomains = api.listSubdomains(3650908).concat().toList(); + assertEquals(subdomains.size(), 8); + + for (Subdomain subdomain: subdomains) { + assertTrue(subdomain.getName().contains(JCLOUDS_EXAMPLE)); + } + } + public void testListWithFilterByNamesMatching() { URI endpoint = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains?name=test.jclouds-example.com"); DomainApi api = requestsSendResponses( http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/RecordApiExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/RecordApiExpectTest.java b/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/RecordApiExpectTest.java index b061331..bfd2b00 100644 --- a/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/RecordApiExpectTest.java +++ b/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/features/RecordApiExpectTest.java @@ -131,6 +131,26 @@ public class RecordApiExpectTest extends BaseCloudDNSApiExpectTest<CloudDNSApi> } } + public void testListRecordsPagination() { + URI endpointPage1 = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/records"); + URI endpointPage2 = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/records?limit=4&offset=4"); + RecordApi api = requestsSendResponses( + rackspaceAuthWithUsernameAndApiKey, + responseWithAccess, + authenticatedGET().endpoint(endpointPage1).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/record-list-page1.json")).build(), + authenticatedGET().endpoint(endpointPage2).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/record-list-page2.json")).build()) + .getRecordApiForDomain(3650908); + + ImmutableList<RecordDetail> records = api.list().concat().toList(); + assertEquals(records.size(), 8); + + for (RecordDetail record: records) { + assertTrue(record.getName().contains(JCLOUDS_EXAMPLE)); + } + } + public void testListByType() { URI endpoint = URI.create("https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/records?type=A"); RecordApi api = requestsSendResponses( http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/domain-list-page1.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/domain-list-page1.json b/apis/rackspace-clouddns/src/test/resources/domain-list-page1.json new file mode 100644 index 0000000..8d28bd1 --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/domain-list-page1.json @@ -0,0 +1,47 @@ +{ + "domains": [ + { + "name": "dev.jclouds-example.com", + "id": 3650907, + "comment": "Hello dev subdomain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:15.000+0000", + "created": "2013-03-22T03:04:15.000+0000" + }, + { + "name": "jclouds-example.com", + "id": 3650906, + "comment": "Hello Domain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:14.000+0000", + "created": "2013-03-22T03:04:12.000+0000" + }, + { + "name": "test.jclouds-example.com", + "id": 3650908, + "comment": "Hello test subdomain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:16.000+0000", + "created": "2013-03-22T03:04:15.000+0000" + }, + { + "name": "xjclouds-example.com", + "id": 3650909, + "comment": "Hello Domain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:16.000+0000", + "created": "2013-03-22T03:04:16.000+0000" + } + ], + "totalEntries": 8, + "links": [ + { + "href":"https://dns.api.rackspacecloud.com/v1.0/123123/domains?limit=4&offset=4", + "rel":"next" + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/domain-list-page2.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/domain-list-page2.json b/apis/rackspace-clouddns/src/test/resources/domain-list-page2.json new file mode 100644 index 0000000..2fe7ff0 --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/domain-list-page2.json @@ -0,0 +1,47 @@ +{ + "domains": [ + { + "name": "dev.jclouds-example.com", + "id": 3650907, + "comment": "Hello dev subdomain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:15.000+0000", + "created": "2013-03-22T03:04:15.000+0000" + }, + { + "name": "jclouds-example.com", + "id": 3650906, + "comment": "Hello Domain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:14.000+0000", + "created": "2013-03-22T03:04:12.000+0000" + }, + { + "name": "test.jclouds-example.com", + "id": 3650908, + "comment": "Hello test subdomain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:16.000+0000", + "created": "2013-03-22T03:04:15.000+0000" + }, + { + "name": "xjclouds-example.com", + "id": 3650909, + "comment": "Hello Domain", + "accountId": 123123, + "emailAddress": "[email protected]", + "updated": "2013-03-22T03:04:16.000+0000", + "created": "2013-03-22T03:04:16.000+0000" + } + ], + "totalEntries": 8, + "links": [ + { + "href":"https://dns.api.rackspacecloud.com/v1.0/123123/domains?limit=4&offset=0", + "rel":"previous" + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/record-list-page1.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/record-list-page1.json b/apis/rackspace-clouddns/src/test/resources/record-list-page1.json new file mode 100644 index 0000000..2b88304 --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/record-list-page1.json @@ -0,0 +1,48 @@ +{ + "records": [ + { + "name": "jclouds-example.com", + "id": "A-9846147", + "type": "A", + "data": "10.0.1.0", + "ttl": 60000, + "updated": "2013-04-06T15:20:29.000+0000", + "created": "2013-04-06T15:20:29.000+0000" + }, + { + "name": "jclouds-example.com", + "id": "NS-8684719", + "type": "NS", + "data": "dns1.stabletransit.com", + "ttl": 60000, + "updated": "2013-04-06T15:19:20.000+0000", + "created": "2013-04-06T15:19:20.000+0000" + }, + { + "name": "jclouds-example.com", + "id": "NS-8684720", + "type": "NS", + "data": "dns2.stabletransit.com", + "ttl": 60000, + "updated": "2013-04-06T15:19:20.000+0000", + "created": "2013-04-06T15:19:20.000+0000" + }, + { + "name": "jclouds-example.com", + "id": "MX-4351045", + "priority": 11235, + "type": "MX", + "data": "mail.jclouds-example.com.com", + "ttl": 60000, + "updated": "2013-04-06T15:20:28.000+0000", + "created": "2013-04-06T15:20:28.000+0000" + } + ], + "totalEntries": 8, + "links": [ + { + "href":"https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/records?limit=4&offset=4", + "rel":"next" + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/record-list-page2.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/record-list-page2.json b/apis/rackspace-clouddns/src/test/resources/record-list-page2.json new file mode 100644 index 0000000..cccc138 --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/record-list-page2.json @@ -0,0 +1,48 @@ +{ + "records": [ + { + "name": "jclouds-example.com", + "id": "A-9846146", + "type": "A", + "data": "10.0.1.0", + "ttl": 60000, + "updated": "2013-04-06T15:20:29.000+0000", + "created": "2013-04-06T15:20:29.000+0000" + }, + { + "name": "jclouds-example.com", + "id": "NS-8684719", + "type": "NS", + "data": "dns1.stabletransit.com", + "ttl": 60000, + "updated": "2013-04-06T15:19:20.000+0000", + "created": "2013-04-06T15:19:20.000+0000" + }, + { + "name": "jclouds-example.com", + "id": "NS-8684720", + "type": "NS", + "data": "dns2.stabletransit.com", + "ttl": 60000, + "updated": "2013-04-06T15:19:20.000+0000", + "created": "2013-04-06T15:19:20.000+0000" + }, + { + "name": "jclouds-example.com", + "id": "MX-4351045", + "priority": 11235, + "type": "MX", + "data": "mail.jclouds-example.com.com", + "ttl": 60000, + "updated": "2013-04-06T15:20:28.000+0000", + "created": "2013-04-06T15:20:28.000+0000" + } + ], + "totalEntries": 8, + "links": [ + { + "href":"https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/records?limit=4&offset=0", + "rel":"previous" + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/subdomain-list-page1.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/subdomain-list-page1.json b/apis/rackspace-clouddns/src/test/resources/subdomain-list-page1.json new file mode 100644 index 0000000..3cfe450 --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/subdomain-list-page1.json @@ -0,0 +1,39 @@ +{ + "domains": [ + { + "name": "1of4.jclouds-example.com", + "id": 3728279, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:21.000+0000", + "created": "2013-05-23T00:32:21.000+0000" + }, + { + "name": "2of4.jclouds-example.com", + "id": 3728280, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:21.000+0000", + "created": "2013-05-23T00:32:21.000+0000" + }, + { + "name": "3of4.jclouds-example.com", + "id": 3728281, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:22.000+0000", + "created": "2013-05-23T00:32:22.000+0000" + }, + { + "name": "4of4.jclouds-example.com", + "id": 3728282, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:22.000+0000", + "created": "2013-05-23T00:32:22.000+0000" + } + ], + "totalEntries": 8, + "links": [ + { + "href":"https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/subdomains?limit=4&offset=4", + "rel":"next" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/subdomain-list-page2.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/subdomain-list-page2.json b/apis/rackspace-clouddns/src/test/resources/subdomain-list-page2.json new file mode 100644 index 0000000..e39acef --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/subdomain-list-page2.json @@ -0,0 +1,39 @@ +{ + "domains": [ + { + "name": "1of4.jclouds-example.com", + "id": 3728279, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:21.000+0000", + "created": "2013-05-23T00:32:21.000+0000" + }, + { + "name": "2of4.jclouds-example.com", + "id": 3728280, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:21.000+0000", + "created": "2013-05-23T00:32:21.000+0000" + }, + { + "name": "3of4.jclouds-example.com", + "id": 3728281, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:22.000+0000", + "created": "2013-05-23T00:32:22.000+0000" + }, + { + "name": "4of4.jclouds-example.com", + "id": 3728282, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:22.000+0000", + "created": "2013-05-23T00:32:22.000+0000" + } + ], + "totalEntries": 8, + "links": [ + { + "href":"https://dns.api.rackspacecloud.com/v1.0/123123/domains/3650908/subdomains?limit=4&offset=0", + "rel":"previous" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/cbc42fde/apis/rackspace-clouddns/src/test/resources/subdomain-list.json ---------------------------------------------------------------------- diff --git a/apis/rackspace-clouddns/src/test/resources/subdomain-list.json b/apis/rackspace-clouddns/src/test/resources/subdomain-list.json new file mode 100644 index 0000000..f6ce905 --- /dev/null +++ b/apis/rackspace-clouddns/src/test/resources/subdomain-list.json @@ -0,0 +1,33 @@ +{ + "domains": [ + { + "name": "1of4.jclouds-example.com", + "id": 3728279, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:21.000+0000", + "created": "2013-05-23T00:32:21.000+0000" + }, + { + "name": "2of4.jclouds-example.com", + "id": 3728280, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:21.000+0000", + "created": "2013-05-23T00:32:21.000+0000" + }, + { + "name": "3of4.jclouds-example.com", + "id": 3728281, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:22.000+0000", + "created": "2013-05-23T00:32:22.000+0000" + }, + { + "name": "4of4.jclouds-example.com", + "id": 3728282, + "emailAddress": "[email protected]", + "updated": "2013-05-23T00:32:22.000+0000", + "created": "2013-05-23T00:32:22.000+0000" + } + ], + "totalEntries": 4 +} \ No newline at end of file
