remove exception handling when a record set is not found

This commit is contained in:
adriancole 2013-03-08 13:26:48 -08:00
parent d5177507a3
commit 6680258b4a
2 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException; import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException;
import org.jclouds.dynect.v3.domain.CreateRecord; import org.jclouds.dynect.v3.domain.CreateRecord;
@ -94,6 +95,7 @@ public interface RecordAsyncApi {
@GET @GET
@Path("/{type}Record/{zone}/{fqdn}") @Path("/{type}Record/{zone}/{fqdn}")
@ResponseParser(ToRecordIds.class) @ResponseParser(ToRecordIds.class)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<RecordId>> listByFQDNAndType(@PathParam("fqdn") String fqdn, ListenableFuture<FluentIterable<RecordId>> listByFQDNAndType(@PathParam("fqdn") String fqdn,
@PathParam("type") String type) throws JobStillRunningException; @PathParam("type") String type) throws JobStillRunningException;

View File

@ -18,13 +18,14 @@
*/ */
package org.jclouds.dynect.v3.features; 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.ACCEPT;
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; 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.RecordId.recordIdBuilder;
import static org.jclouds.dynect.v3.domain.rdata.AData.a; import static org.jclouds.dynect.v3.domain.rdata.AData.a;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import org.jclouds.dynect.v3.DynECTApi; import org.jclouds.dynect.v3.DynECTApi;
import org.jclouds.dynect.v3.domain.CreateRecord; import org.jclouds.dynect.v3.domain.CreateRecord;
@ -319,6 +320,11 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
new ListRecordsResponseTest().expected().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") HttpRequest create = HttpRequest.builder().method("POST")
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org") .endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org")
.addHeader("API-Version", "3.3.8") .addHeader("API-Version", "3.3.8")