From 6680258b4a27ba735b00a0018cd3f598cd8cb223 Mon Sep 17 00:00:00 2001 From: adriancole Date: Fri, 8 Mar 2013 13:26:48 -0800 Subject: [PATCH] remove exception handling when a record set is not found --- .../org/jclouds/dynect/v3/features/RecordAsyncApi.java | 2 ++ .../jclouds/dynect/v3/features/RecordApiExpectTest.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/labs/dynect/src/main/java/org/jclouds/dynect/v3/features/RecordAsyncApi.java b/labs/dynect/src/main/java/org/jclouds/dynect/v3/features/RecordAsyncApi.java index 6902a818d4..57e763460c 100644 --- a/labs/dynect/src/main/java/org/jclouds/dynect/v3/features/RecordAsyncApi.java +++ b/labs/dynect/src/main/java/org/jclouds/dynect/v3/features/RecordAsyncApi.java @@ -35,6 +35,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException; import org.jclouds.dynect.v3.domain.CreateRecord; @@ -94,6 +95,7 @@ public interface RecordAsyncApi { @GET @Path("/{type}Record/{zone}/{fqdn}") @ResponseParser(ToRecordIds.class) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) ListenableFuture> listByFQDNAndType(@PathParam("fqdn") String fqdn, @PathParam("type") String type) throws JobStillRunningException; diff --git a/labs/dynect/src/test/java/org/jclouds/dynect/v3/features/RecordApiExpectTest.java b/labs/dynect/src/test/java/org/jclouds/dynect/v3/features/RecordApiExpectTest.java index aea0721c6a..41081a2817 100644 --- a/labs/dynect/src/test/java/org/jclouds/dynect/v3/features/RecordApiExpectTest.java +++ b/labs/dynect/src/test/java/org/jclouds/dynect/v3/features/RecordApiExpectTest.java @@ -18,13 +18,14 @@ */ package org.jclouds.dynect.v3.features; -import static com.google.common.net.HttpHeaders.CONTENT_TYPE; import static com.google.common.net.HttpHeaders.ACCEPT; +import static com.google.common.net.HttpHeaders.CONTENT_TYPE; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.jclouds.dynect.v3.domain.RecordId.recordIdBuilder; import static org.jclouds.dynect.v3.domain.rdata.AData.a; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import org.jclouds.dynect.v3.DynECTApi; import org.jclouds.dynect.v3.domain.CreateRecord; @@ -318,6 +319,11 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest { assertEquals(success.getRecordApiForZone("jclouds.org").listByFQDNAndType("www.foo.com", "A").toString(), new ListRecordsResponseTest().expected().toString()); } + + public void testListByFQDNAndTypeWhenResponseIs404() { + DynECTApi fail = requestsSendResponses(createSession, createSessionResponse, listByFQDNAndType, notFound); + assertTrue(fail.getRecordApiForZone("jclouds.org").listByFQDNAndType("www.foo.com", "A").isEmpty()); + } HttpRequest create = HttpRequest.builder().method("POST") .endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org")