From d9572151ae76121e241505079dce5a0e2bab2f75 Mon Sep 17 00:00:00 2001 From: adriancole Date: Sun, 24 Mar 2013 16:01:01 -0700 Subject: [PATCH 1/4] update pool record support in ultradns --- .../ws/binders/UpdatePoolRecordToXML.java | 62 +++++ .../ultradns/ws/domain/UpdatePoolRecord.java | 232 ++++++++++++++++++ .../ws/features/TrafficControllerPoolApi.java | 17 +- .../TrafficControllerPoolAsyncApi.java | 12 + .../TrafficControllerPoolApiExpectTest.java | 29 +++ .../TrafficControllerPoolApiLiveTest.java | 25 ++ .../src/test/resources/poolrecord_updated.xml | 1 + .../src/test/resources/update_poolrecord.xml | 1 + 8 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/binders/UpdatePoolRecordToXML.java create mode 100644 providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java create mode 100644 providers/ultradns-ws/src/test/resources/poolrecord_updated.xml create mode 100644 providers/ultradns-ws/src/test/resources/update_poolrecord.xml diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/binders/UpdatePoolRecordToXML.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/binders/UpdatePoolRecordToXML.java new file mode 100644 index 0000000000..670a9ca06c --- /dev/null +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/binders/UpdatePoolRecordToXML.java @@ -0,0 +1,62 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.ultradns.ws.binders; + +import static java.lang.String.format; + +import java.util.Map; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; +import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; + +/** + * + * @author Adrian Cole + */ +public class UpdatePoolRecordToXML implements MapBinder { + private static final String HEADER = "%s"; + private static final String FOOTER = ""; + + @SuppressWarnings("unchecked") + @Override + public R bindToRequest(R request, Map postParams) { + + StringBuilder xml = new StringBuilder(); + xml.append(format(HEADER, postParams.get("poolRecordID"))); + + UpdatePoolRecord update = UpdatePoolRecord.class.cast(postParams.get("update")); + + xml.append("").append(update.getPointsTo()).append(""); + xml.append("").append(update.getPriority()).append(""); + xml.append("").append(update.getFailOverDelay()).append(""); + xml.append("").append(update.getTTL()).append(""); + xml.append("").append(update.getWeight()).append(""); + xml.append("").append(update.getMode()).append(""); + xml.append("").append(update.getThreshold()).append(""); + + xml.append(FOOTER); + return (R) request.toBuilder().payload(xml.toString()).build(); + } + + @Override + public R bindToRequest(R request, Object input) { + throw new UnsupportedOperationException("use map form"); + } +} diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java new file mode 100644 index 0000000000..a7883b4e30 --- /dev/null +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java @@ -0,0 +1,232 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.ultradns.ws.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Objects; + +/** + * holds updates for a record + * + * @author Adrian Cole + */ +public final class UpdatePoolRecord { + + /** + * @param spec what to prime updates from + * @param pointsTo new value to point to. + */ + public static UpdatePoolRecord pointingTo(PoolRecordSpec spec, String pointsTo) { + return new Builder().from(spec).pointsTo(pointsTo).build(); + } + + private final String pointsTo; + private final String mode; + private final int priority; + private final int weight; + private final int failOverDelay; + private final int threshold; + private final int ttl; + + private UpdatePoolRecord(String pointsTo, String mode, int priority, int weight, int failOverDelay, int threshold, + int ttl) { + this.pointsTo = checkNotNull(pointsTo, "pointsTo"); + this.mode = checkNotNull(mode, "mode for %s", pointsTo); + this.priority = priority; + this.weight = weight; + checkArgument(weight >= 0, "weight of %s must be unsigned", pointsTo); + this.failOverDelay = failOverDelay; + checkArgument(failOverDelay >= 0, "failOverDelay of %s must be unsigned", pointsTo); + this.threshold = threshold; + checkArgument(threshold >= 0, "threshold of %s must be unsigned", pointsTo); + this.ttl = ttl; + checkArgument(ttl >= 0, "ttl of %s must be unsigned", pointsTo); + } + + /** + * correlates to {@link TrafficControllerPoolRecord#getPointsTo()} + */ + public String getPointsTo() { + return pointsTo; + } + + /** + * correlates to {@link PoolRecordSpec#getState()} + */ + public String getMode() { + return mode; + } + + /** + * correlates to {@link PoolRecordSpec#getPriority()} + */ + public int getPriority() { + return priority; + } + + /** + * correlates to {@link PoolRecordSpec#getWeight()} + */ + public int getWeight() { + return weight; + } + + /** + * correlates to {@link PoolRecordSpec#getFailOverDelay()} + */ + public int getFailOverDelay() { + return failOverDelay; + } + + /** + * correlates to {@link PoolRecordSpec#getThreshold()} + */ + public int getThreshold() { + return threshold; + } + + /** + * correlates to {@link PoolRecordSpec#getTTL()} + */ + public int getTTL() { + return ttl; + } + + @Override + public int hashCode() { + return Objects.hashCode(pointsTo, mode, priority, weight, failOverDelay, threshold, ttl); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UpdatePoolRecord that = UpdatePoolRecord.class.cast(obj); + return equal(this.pointsTo, that.pointsTo) && equal(this.mode, that.mode) && equal(this.priority, that.priority) + && equal(this.weight, that.weight) && equal(this.failOverDelay, that.failOverDelay) + && equal(this.threshold, that.threshold) && equal(this.ttl, that.ttl); + } + + @Override + public String toString() { + return toStringHelper(this).add("pointsTo", pointsTo).add("mode", mode).add("priority", priority) + .add("weight", weight).add("failOverDelay", failOverDelay).add("threshold", threshold).add("ttl", ttl) + .toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().from(this); + } + + public final static class Builder { + private String pointsTo; + private String mode; + private int priority; + private int weight; + private int failOverDelay; + private int threshold; + private int ttl; + + /** + * @see UpdatePoolRecord#getPointsTo() + */ + public Builder pointsTo(String pointsTo) { + this.pointsTo = pointsTo; + return this; + } + + /** + * @see UpdatePoolRecord#getMode() + */ + public Builder mode(String mode) { + this.mode = mode; + return this; + } + + /** + * @see UpdatePoolRecord#getPriority() + */ + public Builder priority(int priority) { + this.priority = priority; + return this; + } + + /** + * @see UpdatePoolRecord#getWeight() + */ + public Builder weight(int weight) { + this.weight = weight; + return this; + } + + /** + * @see UpdatePoolRecord#getFailOverDelay() + */ + public Builder failOverDelay(int failOverDelay) { + this.failOverDelay = failOverDelay; + return this; + } + + /** + * @see UpdatePoolRecord#getThreshold() + */ + public Builder threshold(int threshold) { + this.threshold = threshold; + return this; + } + + /** + * @see UpdatePoolRecord#getTTL() + */ + public Builder ttl(int ttl) { + this.ttl = ttl; + return this; + } + + public UpdatePoolRecord build() { + return new UpdatePoolRecord(pointsTo, mode, priority, weight, failOverDelay, threshold, ttl); + } + + public Builder from(PoolRecordSpec in) { + return this.mode(in.getState()).weight(in.getWeight()).failOverDelay(in.getFailOverDelay()) + .threshold(in.getThreshold()).ttl(in.getTTL()); + } + + public Builder from(TrafficControllerPoolRecord in) { + return this.weight(in.getWeight()).pointsTo(in.getPointsTo()).priority(in.getPriority()); + } + + public Builder from(UpdatePoolRecord in) { + return this.pointsTo(in.pointsTo).mode(in.mode).priority(in.priority).weight(in.weight) + .failOverDelay(in.failOverDelay).threshold(in.threshold).ttl(in.ttl); + } + } +} diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java index da0c80f14e..1509528eea 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java @@ -25,6 +25,7 @@ import org.jclouds.ultradns.ws.domain.PoolRecordSpec; import org.jclouds.ultradns.ws.domain.ResourceRecord; import org.jclouds.ultradns.ws.domain.TrafficControllerPool; import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord; +import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; import com.google.common.collect.FluentIterable; @@ -102,12 +103,26 @@ public interface TrafficControllerPoolApi { * Retrieves information about the specified pool record * * @param poolRecordID - * {@see TrafficControllerPoolRecord#getId()} + * {@link TrafficControllerPoolRecord#getId()} * @return null if not found */ @Nullable PoolRecordSpec getRecordSpec(String poolRecordID); + /** + * This request updates an existing pool record. + * + * @param poolRecordID + * {@link TrafficControllerPoolRecord#getId()} + * @param update + * what to update, usually primed via + * {@link UpdatePoolRecord#pointingTo(PoolRecordSpec, String)} or + * {@link org.jclouds.ultradns.ws.domain.UpdatePoolRecord.Builder#from(PoolRecordSpec)} + * @throws ResourceNotFoundException + * if the record doesn't exist + */ + void updateRecord(String poolRecordID, UpdatePoolRecord update) throws ResourceNotFoundException; + /** * deletes a specific pooled resource record * diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java index 6127b3495c..c20cc7f72f 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java @@ -25,15 +25,18 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException; +import org.jclouds.ultradns.ws.binders.UpdatePoolRecordToXML; import org.jclouds.ultradns.ws.domain.PoolRecordSpec; import org.jclouds.ultradns.ws.domain.TrafficControllerPool; import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord; +import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth; import org.jclouds.ultradns.ws.xml.AttributeHandler; import org.jclouds.ultradns.ws.xml.PoolRecordSpecHandler; @@ -122,6 +125,15 @@ public interface TrafficControllerPoolAsyncApi { @Fallback(NullOnNotFoundOr404.class) ListenableFuture getRecordSpec(@PayloadParam("poolRecordId") String poolRecordID); + /** + * @see TrafficControllerPoolApi#getRecordSpec(String) + */ + @Named("updatePoolRecord>") + @POST + @MapBinder(UpdatePoolRecordToXML.class) + ListenableFuture updateRecord(@PayloadParam("poolRecordID") String poolRecordID, + @PayloadParam("update") UpdatePoolRecord update) throws ResourceNotFoundException; + /** * @see TrafficControllerPoolApi#deleteRecord(String) */ diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java index fc8833bbc8..583a562739 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java @@ -23,8 +23,10 @@ import static org.testng.Assert.assertNull; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; +import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.ultradns.ws.UltraDNSWSApi; import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException; +import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest; import org.jclouds.ultradns.ws.parse.GetPoolRecordSpecResponseTest; import org.jclouds.ultradns.ws.parse.GetTCLoadBalancingPoolsByZoneResponseTest; @@ -172,6 +174,33 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT assertNull(notFound.getTrafficControllerPoolApiForZone("jclouds.org.").getRecordSpec("04053D8E57C7931F")); } + UpdatePoolRecord update = UpdatePoolRecord.builder() + .pointsTo("www.baz.com.") + .mode("Normal") + .weight(98) + .failOverDelay(0) + .threshold(1) + .ttl(200).build(); + + HttpRequest updateRecord = HttpRequest.builder().method("POST") + .endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01") + .addHeader("Host", "ultra-api.ultradns.com:8443") + .payload(payloadFromResourceWithContentType("/update_poolrecord.xml", "application/xml")).build(); + + HttpResponse updateRecordResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResourceWithContentType("/poolrecord_updated.xml", "application/xml")).build(); + + public void testUpdateRecordWhenResponseIs2xx() { + UltraDNSWSApi success = requestSendsResponse(updateRecord, updateRecordResponse); + success.getTrafficControllerPoolApiForZone("jclouds.org.").updateRecord("04053D8E57C7931F", update); + } + + @Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Pool Record does not exist.") + public void testUpdateRecordWhenResponseNotFound() { + UltraDNSWSApi notFound = requestSendsResponse(updateRecord, recordDoesntExist); + notFound.getTrafficControllerPoolApiForZone("jclouds.org.").updateRecord("04053D8E57C7931F", update); + } + HttpRequest deleteRecord = HttpRequest.builder().method("POST") .endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01") .addHeader("Host", "ultra-api.ultradns.com:8443") diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java index 11d1fb1cd2..c173d4c4a3 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java @@ -35,6 +35,7 @@ import org.jclouds.ultradns.ws.domain.PoolRecordSpec; import org.jclouds.ultradns.ws.domain.TrafficControllerPool; import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord; import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord.Status; +import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; import org.jclouds.ultradns.ws.domain.Zone; import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest; import org.testng.annotations.AfterClass; @@ -152,6 +153,12 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest assertNull(api(zoneName).getRecordSpec("06063D9C54C5AE09")); } + @Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Pool Record does not exist.") + public void testUpdateRecordWhenNotFound() { + api(zoneName).updateRecord("06063D9C54C5AE09", + UpdatePoolRecord.builder().pointsTo("www.foo.com.").mode("Normal").build()); + } + String hostname = "www.tcpool." + zoneName; String poolId; @@ -223,6 +230,24 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest } @Test(dependsOnMethods = "addCNAMERecordsToPool") + public void testUpdateRecord() { + PoolRecordSpec spec = api(zoneName).getRecordSpec(cname2); + UpdatePoolRecord update = UpdatePoolRecord.builder().from(spec) + .pointsTo("www.baz.com.") + .weight(98) + .ttl(200).build(); + + api(zoneName).updateRecord(cname2, update); + + TrafficControllerPoolRecord record = getRecordById(cname2).get(); + assertEquals(record.getPointsTo(), "www.baz.com."); + + spec = api(zoneName).getRecordSpec(cname2); + assertEquals(spec.getWeight(), 98); + assertEquals(spec.getTTL(), 200); + } + + @Test(dependsOnMethods = "testUpdateRecord") public void testDeleteRecord() { api(zoneName).deleteRecord(cname1); assertFalse(getRecordById(cname1).isPresent()); diff --git a/providers/ultradns-ws/src/test/resources/poolrecord_updated.xml b/providers/ultradns-ws/src/test/resources/poolrecord_updated.xml new file mode 100644 index 0000000000..64d564f58e --- /dev/null +++ b/providers/ultradns-ws/src/test/resources/poolrecord_updated.xml @@ -0,0 +1 @@ +Successful \ No newline at end of file diff --git a/providers/ultradns-ws/src/test/resources/update_poolrecord.xml b/providers/ultradns-ws/src/test/resources/update_poolrecord.xml new file mode 100644 index 0000000000..3b33d73e1d --- /dev/null +++ b/providers/ultradns-ws/src/test/resources/update_poolrecord.xml @@ -0,0 +1 @@ +identitycredential04053D8E57C7931Fwww.baz.com.0020098Normal1 \ No newline at end of file From d7221dc9fc3f7ae49713b539d6af177547825876 Mon Sep 17 00:00:00 2001 From: adriancole Date: Sun, 24 Mar 2013 16:20:57 -0700 Subject: [PATCH 2/4] specify weight when adding pool record support in ultradns --- .../ws/features/TrafficControllerPoolApi.java | 24 ++++++++++++++++--- .../TrafficControllerPoolAsyncApi.java | 11 +++++++++ .../TrafficControllerPoolApiExpectTest.java | 12 ++++++++++ .../TrafficControllerPoolApiLiveTest.java | 19 ++++++++++----- .../test/resources/create_tcrecord_weight.xml | 1 + 5 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 providers/ultradns-ws/src/test/resources/create_tcrecord_weight.xml diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java index 1509528eea..4ad9b5eb08 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java @@ -22,7 +22,6 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException; import org.jclouds.ultradns.ws.domain.PoolRecordSpec; -import org.jclouds.ultradns.ws.domain.ResourceRecord; import org.jclouds.ultradns.ws.domain.TrafficControllerPool; import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord; import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; @@ -84,14 +83,14 @@ public interface TrafficControllerPoolApi { FluentIterable listRecords(String poolId) throws ResourceNotFoundException; /** - * adds a new record to the pool + * adds a new record to the pool with default weight. * * @param pointsTo * the ipv4 address or hostname * @param lbPoolID * the pool to add the record to. * @param ttl - * the {@link ResourceRecord#getTTL ttl} of the record + * the {@link PoolRecordSpec#getTTL ttl} of the record * @return the {@link TrafficControllerPoolRecord#getId() id} of the new * record * @throws ResourceAlreadyExistsException @@ -99,6 +98,25 @@ public interface TrafficControllerPoolApi { */ String addRecordToPoolWithTTL(String pointsTo, String lbPoolID, int ttl) throws ResourceAlreadyExistsException; + /** + * adds a new record to the pool with a specified weight. + * + * @param pointsTo + * the ipv4 address or hostname + * @param lbPoolID + * the pool to add the record to. + * @param ttl + * the {@link PoolRecordSpec#getTTL ttl} of the record + * @param weight + * the {@link PoolRecordSpec#getWeight() weight} of the record + * @return the {@link TrafficControllerPoolRecord#getId() id} of the new + * record + * @throws ResourceAlreadyExistsException + * if a record already exists with the same attrs + */ + String addRecordToPoolWithTTLAndWeight(String pointsTo, String lbPoolID, int ttl, int weight) + throws ResourceAlreadyExistsException; + /** * Retrieves information about the specified pool record * diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java index c20cc7f72f..75e1f39c6a 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java @@ -115,6 +115,17 @@ public interface TrafficControllerPoolAsyncApi { ListenableFuture addRecordToPoolWithTTL(@PayloadParam("pointsTo") String pointsTo, @PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl) throws ResourceAlreadyExistsException; + /** + * @see TrafficControllerPoolApi#addRecordToPoolWithTTLAndWeight + */ + @Named("addPoolRecord") + @POST + @XMLResponseParser(TextHandler.PoolRecordID.class) + @Payload("{poolID}{pointsTo}{ttl}{weight}") + ListenableFuture addRecordToPoolWithTTLAndWeight(@PayloadParam("pointsTo") String pointsTo, + @PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl, @PayloadParam("weight") int weight) + throws ResourceAlreadyExistsException; + /** * @see TrafficControllerPoolApi#getRecordSpec(String) */ diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java index 583a562739..82c212efd2 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiExpectTest.java @@ -142,6 +142,18 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT UltraDNSWSApi success = requestSendsResponse(createRecord, createRecordResponse); assertEquals(success.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTL("1.2.3.4", "04053D8E57C7931F", 300), "06063DAC54F8D3D9"); } + + HttpRequest createRecordWithWeight = HttpRequest.builder().method("POST") + .endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01") + .addHeader("Host", "ultra-api.ultradns.com:8443") + .payload(payloadFromResourceWithContentType("/create_tcrecord_weight.xml", "application/xml")).build(); + + public void testCreateRecordWithWeightWhenResponseIs2xx() { + UltraDNSWSApi success = requestSendsResponse(createRecordWithWeight, createRecordResponse); + assertEquals( + success.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTLAndWeight("1.2.3.4", + "04053D8E57C7931F", 300, 0), "06063DAC54F8D3D9"); + } HttpResponse recordAlreadyCreated = HttpResponse.builder().statusCode(500) .payload(payloadFromResourceWithContentType("/tcrecord_already_exists.xml", "application/xml")).build(); diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java index c173d4c4a3..4b5a613fbe 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java @@ -189,25 +189,32 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest @DataProvider(name = "records") public Object[][] createRecords() { - Object[][] records = new Object[2][3]; + Object[][] records = new Object[2][4]; records[0][0] = "1.2.3.4"; records[0][1] = "A"; records[0][2] = 60; + records[0][3] = Optional.of(98); records[1][0] = "5.6.7.8"; records[1][1] = "A"; records[1][2] = 60; + records[1][3] = Optional.of(2); return records; } @Test(dependsOnMethods = "testCreatePool", dataProvider = "records") - public TrafficControllerPoolRecord addRecordToPool(final String pointsTo, final String type, final int ttl) { - String recordId = api(zoneName).addRecordToPoolWithTTL(pointsTo, poolId, ttl); + public TrafficControllerPoolRecord addRecordToPool(String pointsTo, String type, int ttl, Optional weight) { + String recordId; + if (weight.isPresent()) { + recordId = api(zoneName).addRecordToPoolWithTTLAndWeight(pointsTo, poolId, ttl, weight.get()); + } else { + recordId = api(zoneName).addRecordToPoolWithTTL(pointsTo, poolId, ttl); + } getAnonymousLogger().info("created " + type + " record: " + recordId); TrafficControllerPoolRecord record = checkPoolRecordConsistent(zoneName, getRecordById(recordId).get()); PoolRecordSpec recordSpec = checkPoolRecordSpec(api(zoneName).getRecordSpec(recordId)); assertEquals(record.getPointsTo(), pointsTo); assertEquals(record.getType(), type); - assertEquals(record.getWeight(), 2); + assertEquals(record.getWeight(), weight.or(2).intValue()); assertEquals(recordSpec.getTTL(), ttl); return record; } @@ -217,7 +224,7 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest @Test(dependsOnMethods = "testCreatePool") public void addCNAMERecordsToPool() { - cname1 = addRecordToPool("www.foo.com.", "CNAME", 30).getId(); + cname1 = addRecordToPool("www.foo.com.", "CNAME", 30, Optional. absent()).getId(); try { api(zoneName).addRecordToPoolWithTTL("www.foo.com.", poolId, 30); @@ -226,7 +233,7 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest } - cname2 = addRecordToPool("www.bar.com.", "CNAME", 30).getId(); + cname2 = addRecordToPool("www.bar.com.", "CNAME", 30, Optional. absent()).getId(); } @Test(dependsOnMethods = "addCNAMERecordsToPool") diff --git a/providers/ultradns-ws/src/test/resources/create_tcrecord_weight.xml b/providers/ultradns-ws/src/test/resources/create_tcrecord_weight.xml new file mode 100644 index 0000000000..bfca560899 --- /dev/null +++ b/providers/ultradns-ws/src/test/resources/create_tcrecord_weight.xml @@ -0,0 +1 @@ +identitycredential04053D8E57C7931F1.2.3.43000 \ No newline at end of file From 6ab744d674f0ac00495df99b489a5414065216ea Mon Sep 17 00:00:00 2001 From: adriancole Date: Sun, 24 Mar 2013 22:05:52 -0700 Subject: [PATCH 3/4] addressed nits from issue #1453 --- .../ultradns/ws/domain/PoolRecordSpec.java | 12 +++---- .../ultradns/ws/domain/ResourceRecord.java | 4 +-- .../domain/TrafficControllerPoolRecord.java | 4 +-- .../ultradns/ws/domain/UpdatePoolRecord.java | 8 ++--- .../org/jclouds/ultradns/ws/domain/Zone.java | 2 +- .../ultradns/ws/domain/ZoneProperties.java | 2 +- .../ws/features/ResourceRecordAsyncApi.java | 4 +-- .../ws/features/RoundRobinPoolAsyncApi.java | 10 +++--- .../jclouds/ultradns/ws/features/TaskApi.java | 2 -- .../ultradns/ws/features/TaskAsyncApi.java | 4 +-- .../ws/features/TrafficControllerPoolApi.java | 2 -- .../TrafficControllerPoolAsyncApi.java | 8 ++--- .../jclouds/ultradns/ws/features/ZoneApi.java | 2 -- .../TrafficControllerPoolPredicates.java | 34 ++++--------------- .../ws/predicates/ZonePredicates.java | 33 ++++++++++-------- .../ultradns/ws/xml/AttributeHandler.java | 8 ++--- ...xtHandler.java => ElementTextHandler.java} | 20 +++++------ .../ultradns/ws/UltraDNSWSApiLiveTest.java | 6 ++-- .../features/ResourceRecordApiLiveTest.java | 29 ++++++++-------- .../features/RoundRobinPoolApiLiveTest.java | 10 +++--- .../ultradns/ws/features/TaskApiLiveTest.java | 10 +++--- .../TrafficControllerPoolApiLiveTest.java | 26 +++++++------- .../ultradns/ws/features/ZoneApiLiveTest.java | 29 ++++++++-------- .../ws/parse/RunTestResponseTest.java | 4 +-- .../TrafficControllerPoolPredicatesTest.java | 10 +++--- .../ws/predicates/ZonePredicatesTest.java | 8 +++-- 26 files changed, 130 insertions(+), 161 deletions(-) rename providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/{TextHandler.java => ElementTextHandler.java} (78%) diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/PoolRecordSpec.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/PoolRecordSpec.java index f9d3b8a385..02f14d608c 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/PoolRecordSpec.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/PoolRecordSpec.java @@ -47,13 +47,13 @@ public final class PoolRecordSpec { this.probingEnabled = probingEnabled; this.allFailEnabled = allFailEnabled; this.weight = weight; - checkArgument(weight >= 0, "weight of %s must be unsigned", description); + checkArgument(weight >= 0, "weight of %s must be >= 0", description); this.failOverDelay = failOverDelay; - checkArgument(failOverDelay >= 0, "failOverDelay of %s must be unsigned", description); + checkArgument(failOverDelay >= 0, "failOverDelay of %s must be >= 0", description); this.threshold = threshold; - checkArgument(threshold >= 0, "threshold of %s must be unsigned", description); + checkArgument(threshold >= 0, "threshold of %s must be >= 0", description); this.ttl = ttl; - checkArgument(ttl >= 0, "ttl of %s must be unsigned", description); + checkArgument(ttl >= 0, "ttl of %s must be >= 0", description); } /** @@ -114,8 +114,8 @@ public final class PoolRecordSpec { @Override public int hashCode() { - return Objects - .hashCode(description, state, probingEnabled, allFailEnabled, weight, failOverDelay, threshold, ttl); + return Objects.hashCode(description, state, probingEnabled, allFailEnabled, weight, failOverDelay, threshold, + ttl); } @Override 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..2689eb75a1 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 @@ -42,9 +42,9 @@ public class ResourceRecord { private ResourceRecord(String dName, int type, int ttl, List infoValues) { this.dName = checkNotNull(dName, "dName"); - checkArgument(type >= 0, "type of %s must be unsigned", dName); + checkArgument(type >= 0, "type of %s must be >= 0", dName); this.type = type; - checkArgument(ttl >= 0, "ttl of %s must be unsigned", dName); + checkArgument(ttl >= 0, "ttl of %s must be >= 0", dName); this.ttl = ttl; this.infoValues = checkNotNull(infoValues, "infoValues of %s", dName); } diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/TrafficControllerPoolRecord.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/TrafficControllerPoolRecord.java index 061aaf6ab7..1a05fced1d 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/TrafficControllerPoolRecord.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/TrafficControllerPoolRecord.java @@ -46,9 +46,9 @@ public final class TrafficControllerPoolRecord { this.id = checkNotNull(id, "id"); this.poolId = checkNotNull(poolId, "poolId for %s", id); this.pointsTo = checkNotNull(pointsTo, "pointsTo for %s", poolId); - checkArgument(weight >= 0, "weight of %s must be unsigned", id); + checkArgument(weight >= 0, "weight of %s must be >= 0", id); this.weight = weight; - checkArgument(priority >= 0, "priority of %s must be unsigned", id); + checkArgument(priority >= 0, "priority of %s must be >= 0", id); this.priority = priority; this.type = checkNotNull(type, "type for %s", poolId); this.forceAnswer = checkNotNull(forceAnswer, "forceAnswer for %s", poolId); diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java index a7883b4e30..b8117cd9be 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/UpdatePoolRecord.java @@ -54,13 +54,13 @@ public final class UpdatePoolRecord { this.mode = checkNotNull(mode, "mode for %s", pointsTo); this.priority = priority; this.weight = weight; - checkArgument(weight >= 0, "weight of %s must be unsigned", pointsTo); + checkArgument(weight >= 0, "weight of %s must be >= 0", pointsTo); this.failOverDelay = failOverDelay; - checkArgument(failOverDelay >= 0, "failOverDelay of %s must be unsigned", pointsTo); + checkArgument(failOverDelay >= 0, "failOverDelay of %s must be >= 0", pointsTo); this.threshold = threshold; - checkArgument(threshold >= 0, "threshold of %s must be unsigned", pointsTo); + checkArgument(threshold >= 0, "threshold of %s must be >= 0", pointsTo); this.ttl = ttl; - checkArgument(ttl >= 0, "ttl of %s must be unsigned", pointsTo); + checkArgument(ttl >= 0, "ttl of %s must be >= 0", pointsTo); } /** diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/Zone.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/Zone.java index 45b6e83686..60370f6625 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/Zone.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/Zone.java @@ -43,7 +43,7 @@ public final class Zone { DNSSECStatus dnssecStatus, Optional primarySrc) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name for %s", id); - checkArgument(typeCode >= 0, "typeCode of %s must be unsigned", id); + checkArgument(typeCode >= 0, "typeCode of %s must be >= 0", id); this.typeCode = typeCode; this.type = checkNotNull(type, "type for %s", name); this.accountId = checkNotNull(accountId, "accountId for %s", name); diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ZoneProperties.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ZoneProperties.java index 014a7f801b..e2cd0472d4 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ZoneProperties.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/domain/ZoneProperties.java @@ -41,7 +41,7 @@ public final class ZoneProperties { private ZoneProperties(String name, Type type, int typeCode, Date modified, int resourceRecordCount) { this.name = checkNotNull(name, "name"); - checkArgument(typeCode >= 0, "typeCode of %s must be unsigned", name); + checkArgument(typeCode >= 0, "typeCode of %s must be >= 0", name); this.typeCode = typeCode; this.type = checkNotNull(type, "type for %s", name); this.modified = checkNotNull(modified, "modified for %s", name); diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ResourceRecordAsyncApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ResourceRecordAsyncApi.java index d8fab3688e..bf720f96ba 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ResourceRecordAsyncApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ResourceRecordAsyncApi.java @@ -35,7 +35,7 @@ import org.jclouds.ultradns.ws.binders.ZoneAndResourceRecordToXML; import org.jclouds.ultradns.ws.domain.ResourceRecord; import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata; import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth; -import org.jclouds.ultradns.ws.xml.TextHandler; +import org.jclouds.ultradns.ws.xml.ElementTextHandler; import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler; import com.google.common.collect.FluentIterable; @@ -56,7 +56,7 @@ public interface ResourceRecordAsyncApi { */ @Named("createResourceRecord") @POST - @XMLResponseParser(TextHandler.Guid.class) + @XMLResponseParser(ElementTextHandler.Guid.class) @MapBinder(ZoneAndResourceRecordToXML.class) ListenableFuture create(@PayloadParam("resourceRecord") ResourceRecord toCreate) throws ResourceAlreadyExistsException; diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/RoundRobinPoolAsyncApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/RoundRobinPoolAsyncApi.java index ab27999f81..c1981c4306 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/RoundRobinPoolAsyncApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/RoundRobinPoolAsyncApi.java @@ -33,7 +33,7 @@ import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsExcepti import org.jclouds.ultradns.ws.domain.ResourceRecord; import org.jclouds.ultradns.ws.domain.RoundRobinPool; import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth; -import org.jclouds.ultradns.ws.xml.TextHandler; +import org.jclouds.ultradns.ws.xml.ElementTextHandler; import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler; import org.jclouds.ultradns.ws.xml.RoundRobinPoolListHandler; @@ -74,7 +74,7 @@ public interface RoundRobinPoolAsyncApi { */ @Named("addRRLBPool") @POST - @XMLResponseParser(TextHandler.RRPoolID.class) + @XMLResponseParser(ElementTextHandler.RRPoolID.class) @Payload("{zoneName}{hostName}{description}1") ListenableFuture createAPoolForHostname(@PayloadParam("description") String name, @PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException; @@ -84,7 +84,7 @@ public interface RoundRobinPoolAsyncApi { */ @Named("addRecordToRRPool") @POST - @XMLResponseParser(TextHandler.Guid.class) + @XMLResponseParser(ElementTextHandler.Guid.class) @Payload("") ListenableFuture addARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID, @PayloadParam("address") String ipv4Address, @PayloadParam("ttl") int ttl) @@ -114,7 +114,7 @@ public interface RoundRobinPoolAsyncApi { */ @Named("addRRLBPool") @POST - @XMLResponseParser(TextHandler.RRPoolID.class) + @XMLResponseParser(ElementTextHandler.RRPoolID.class) @Payload("{zoneName}{hostName}{description}28") ListenableFuture createAAAAPoolForHostname(@PayloadParam("description") String name, @PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException; @@ -124,7 +124,7 @@ public interface RoundRobinPoolAsyncApi { */ @Named("addRecordToRRPool") @POST - @XMLResponseParser(TextHandler.Guid.class) + @XMLResponseParser(ElementTextHandler.Guid.class) @Payload("") ListenableFuture addAAAARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID, @PayloadParam("address") String ipv6Address, @PayloadParam("ttl") int ttl) diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskApi.java index 5e35e6a03c..910718818f 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskApi.java @@ -36,8 +36,6 @@ public interface TaskApi { String runTest(String value); /** - * Retrieves information about the specified task - * * @param guid * guid of the task to get information about. * @return null if not found diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskAsyncApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskAsyncApi.java index 919c37e472..6b35392fe1 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskAsyncApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TaskAsyncApi.java @@ -31,7 +31,7 @@ import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.ultradns.ws.domain.Task; import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth; -import org.jclouds.ultradns.ws.xml.TextHandler; +import org.jclouds.ultradns.ws.xml.ElementTextHandler; import org.jclouds.ultradns.ws.xml.TaskHandler; import org.jclouds.ultradns.ws.xml.TaskListHandler; @@ -52,7 +52,7 @@ public interface TaskAsyncApi { */ @Named("runTest") @POST - @XMLResponseParser(TextHandler.Guid.class) + @XMLResponseParser(ElementTextHandler.Guid.class) @Payload("{value}") ListenableFuture runTest(@PayloadParam("value") String value); diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java index 4ad9b5eb08..dbca7f0627 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApi.java @@ -118,8 +118,6 @@ public interface TrafficControllerPoolApi { throws ResourceAlreadyExistsException; /** - * Retrieves information about the specified pool record - * * @param poolRecordID * {@link TrafficControllerPoolRecord#getId()} * @return null if not found diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java index 75e1f39c6a..9c9a4a61ad 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolAsyncApi.java @@ -40,7 +40,7 @@ import org.jclouds.ultradns.ws.domain.UpdatePoolRecord; import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth; import org.jclouds.ultradns.ws.xml.AttributeHandler; import org.jclouds.ultradns.ws.xml.PoolRecordSpecHandler; -import org.jclouds.ultradns.ws.xml.TextHandler; +import org.jclouds.ultradns.ws.xml.ElementTextHandler; import org.jclouds.ultradns.ws.xml.TrafficControllerPoolListHandler; import org.jclouds.ultradns.ws.xml.TrafficControllerPoolRecordListHandler; @@ -62,7 +62,7 @@ public interface TrafficControllerPoolAsyncApi { */ @Named("addTCLBPool") @POST - @XMLResponseParser(TextHandler.TCPoolID.class) + @XMLResponseParser(ElementTextHandler.TCPoolID.class) @Payload("{zoneName}{hostName}{description}1EnabledEnabled0") ListenableFuture createPoolForHostname(@PayloadParam("description") String name, @PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException; @@ -110,7 +110,7 @@ public interface TrafficControllerPoolAsyncApi { */ @Named("addPoolRecord") @POST - @XMLResponseParser(TextHandler.PoolRecordID.class) + @XMLResponseParser(ElementTextHandler.PoolRecordID.class) @Payload("{poolID}{pointsTo}{ttl}") ListenableFuture addRecordToPoolWithTTL(@PayloadParam("pointsTo") String pointsTo, @PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl) throws ResourceAlreadyExistsException; @@ -120,7 +120,7 @@ public interface TrafficControllerPoolAsyncApi { */ @Named("addPoolRecord") @POST - @XMLResponseParser(TextHandler.PoolRecordID.class) + @XMLResponseParser(ElementTextHandler.PoolRecordID.class) @Payload("{poolID}{pointsTo}{ttl}{weight}") ListenableFuture addRecordToPoolWithTTLAndWeight(@PayloadParam("pointsTo") String pointsTo, @PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl, @PayloadParam("weight") int weight) diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ZoneApi.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ZoneApi.java index ad631f6cd4..f2f9b36291 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ZoneApi.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/features/ZoneApi.java @@ -45,8 +45,6 @@ public interface ZoneApi { void createInAccount(String name, String accountId) throws ResourceAlreadyExistsException; /** - * Retrieves information about the specified zone - * * @param name * the fully-qualified name, including the trailing dot, of the * zone to get information about. diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicates.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicates.java index 89067ab839..3a358beab0 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicates.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicates.java @@ -32,15 +32,6 @@ import com.google.common.base.Predicate; */ public class TrafficControllerPoolPredicates { - /** - * evaluates to true if the input {@link TrafficControllerPool} exists - * with {@link TrafficControllerPool#getId() id} corresponding to the - * {@code id} parameter. - * - * @param id - * the {@link TrafficControllerPool#getId() id} of the - * desired pool record - */ public static Predicate idEqualTo(String id) { return new IdEqualToPredicate(id); } @@ -54,9 +45,7 @@ public class TrafficControllerPoolPredicates { @Override public boolean apply(TrafficControllerPool input) { - if (input == null) - return false; - return id.equals(input.getId()); + return input != null && id.equals(input.getId()); } @Override @@ -65,36 +54,25 @@ public class TrafficControllerPoolPredicates { } } - /** - * evaluates to true if the input {@link TrafficControllerPoolRecord} exists - * with {@link TrafficControllerPoolRecord#getId() id} corresponding to the - * {@code recordId} parameter. - * - * @param recordId - * the {@link TrafficControllerPoolRecord#getId() id} of the - * desired pool record - */ public static Predicate recordIdEqualTo(String recordId) { return new RecordIdEqualToPredicate(recordId); } private static final class RecordIdEqualToPredicate implements Predicate { - private final String id; + private final String recordId; - public RecordIdEqualToPredicate(String id) { - this.id = checkNotNull(id, "recordId"); + public RecordIdEqualToPredicate(String recordId) { + this.recordId = checkNotNull(recordId, "recordId"); } @Override public boolean apply(TrafficControllerPoolRecord input) { - if (input == null) - return false; - return id.equals(input.getId()); + return input != null && recordId.equals(input.getId()); } @Override public String toString() { - return "RecordIdEqualTo(" + id + ")"; + return "RecordIdEqualTo(" + recordId + ")"; } } } diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/ZonePredicates.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/ZonePredicates.java index 72e6b84b31..21d8a68433 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/ZonePredicates.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/predicates/ZonePredicates.java @@ -32,22 +32,25 @@ import com.google.common.base.Predicate; */ public class ZonePredicates { - /** - * matches zones of the given type - */ - public static Predicate typeEquals(final Type type) { - checkNotNull(type, "type must be defined"); + public static Predicate typeEqualTo(Type type) { + return new TypeEqualToPredicate(type); + } - return new Predicate() { - @Override - public boolean apply(Zone zone) { - return type.equals(zone.getType()); - } + private static final class TypeEqualToPredicate implements Predicate { + private final Type type; - @Override - public String toString() { - return "typeEquals(" + type + ")"; - } - }; + public TypeEqualToPredicate(Type type) { + this.type = checkNotNull(type, "type"); + } + + @Override + public boolean apply(Zone input) { + return input != null && type.equals(input.getType()); + } + + @Override + public String toString() { + return "TypeEqualTo(" + type + ")"; + } } } diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/AttributeHandler.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/AttributeHandler.java index 5dc9b32d86..117364562d 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/AttributeHandler.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/AttributeHandler.java @@ -37,7 +37,7 @@ public abstract class AttributeHandler extends ParseSax.HandlerForGeneratedReque } } - private String attributeName; + private final String attributeName; private String attribute = null; private AttributeHandler(String attributeName) { @@ -46,11 +46,7 @@ public abstract class AttributeHandler extends ParseSax.HandlerForGeneratedReque @Override public String getResult() { - try { - return checkNotNull(attribute, "%s not present in the response", attributeName); - } finally { - attribute = null; - } + return checkNotNull(attribute, "%s not present in the response", attributeName); } @Override diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/TextHandler.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/ElementTextHandler.java similarity index 78% rename from providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/TextHandler.java rename to providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/ElementTextHandler.java index ce59512213..3fa4fa939d 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/TextHandler.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/ElementTextHandler.java @@ -28,48 +28,44 @@ import org.jclouds.http.functions.ParseSax; * * @author Adrian Cole */ -public abstract class TextHandler extends ParseSax.HandlerForGeneratedRequestWithResult { +public abstract class ElementTextHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - public static class Guid extends TextHandler { + public static class Guid extends ElementTextHandler { public Guid() { super("guid"); } } - public static class RRPoolID extends TextHandler { + public static class RRPoolID extends ElementTextHandler { public RRPoolID() { super("RRPoolID"); } } - public static class TCPoolID extends TextHandler { + public static class TCPoolID extends ElementTextHandler { public TCPoolID() { super("TCPoolID"); } } - public static class PoolRecordID extends TextHandler { + public static class PoolRecordID extends ElementTextHandler { public PoolRecordID() { super("poolRecordID"); } } - private String textElement; + private final String textElement; private StringBuilder currentText = new StringBuilder(); private String text = null; - private TextHandler(String textElement) { + private ElementTextHandler(String textElement) { this.textElement = checkNotNull(textElement, "textElement"); } @Override public String getResult() { - try { - return checkNotNull(text, "%s not present in the response", textElement); - } finally { - text = null; - } + return checkNotNull(text, "%s not present in the response", textElement); } @Override diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/UltraDNSWSApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/UltraDNSWSApiLiveTest.java index dbce57f4cb..9225c689c5 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/UltraDNSWSApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/UltraDNSWSApiLiveTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.ultradns.ws; -import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertNotNull; import org.jclouds.ultradns.ws.domain.Account; import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest; @@ -37,8 +37,8 @@ public class UltraDNSWSApiLiveTest extends BaseUltraDNSWSApiLiveTest { } private void checkAccount(Account account) { - checkNotNull(account.getId(), "Id cannot be null for an Account."); - checkNotNull(account.getName(), "Name cannot be null for Account %s", account); + assertNotNull(account.getId(), "Id cannot be null for " + account); + assertNotNull(account.getName(), "Name cannot be null for " + account); } protected UltraDNSWSApi api() { 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..1c9acd09af 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 @@ -17,12 +17,12 @@ * under the License. */ package org.jclouds.ultradns.ws.features; - -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.equalTo; +import static java.lang.String.format; import static java.util.logging.Logger.getAnonymousLogger; import static org.jclouds.ultradns.ws.domain.ResourceRecord.rrBuilder; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -72,20 +72,20 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest { } static void checkResourceRecord(ResourceRecord rr) { - checkNotNull(rr.getName(), "DName cannot be null for a ResourceRecord %s", rr); - checkNotNull(rr.getType(), "Type cannot be null for a ResourceRecord %s", rr); - assertTrue(rr.getType() > 0, "Type must be unsigned for a ResourceRecord " + rr); - checkNotNull(rr.getType(), "Type cannot be null for a ResourceRecord %s", rr); - checkNotNull(rr.getTTL(), "TTL cannot be null for a ResourceRecord %s", rr); - checkNotNull(rr.getRData(), "InfoValues cannot be null for a ResourceRecord %s", rr); + assertNotNull(rr.getName(), "DName cannot be null for " + rr); + assertNotNull(rr.getType(), "Type cannot be null for " + rr); + assertTrue(rr.getType() > 0, "Type must be unsigned for " + rr); + assertNotNull(rr.getType(), "Type cannot be null for " + rr); + assertNotNull(rr.getTTL(), "TTL cannot be null for " + rr); + assertNotNull(rr.getRData(), "InfoValues cannot be null for " + rr); } static void checkResourceRecordMetadata(ResourceRecordMetadata rr) { - checkNotNull(rr.getZoneId(), "ZoneId cannot be null for a ResourceRecordMetadata %s", rr); - checkNotNull(rr.getGuid(), "Guid cannot be null for a ResourceRecordMetadata %s", rr); - checkNotNull(rr.getZoneName(), "ZoneName cannot be null for a ResourceRecordMetadata %s", rr); - checkNotNull(rr.getCreated(), "Created cannot be null for a ResourceRecordMetadata %s", rr); - checkNotNull(rr.getModified(), "Modified cannot be null for a ResourceRecordMetadata %s", rr); + assertNotNull(rr.getZoneId(), "ZoneId cannot be null for " + rr); + assertNotNull(rr.getGuid(), "Guid cannot be null for " + rr); + assertNotNull(rr.getZoneName(), "ZoneName cannot be null for " + rr); + assertNotNull(rr.getCreated(), "Created cannot be null for " + rr); + assertNotNull(rr.getModified(), "Modified cannot be null for " + rr); checkResourceRecord(rr.getRecord()); } @@ -113,8 +113,7 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest { void logSummary() { getAnonymousLogger().info("zoneCount: " + zones); for (Entry entry : recordTypeCounts.asMap().entrySet()) - getAnonymousLogger().info( - String.format("type: %s, count: %s", entry.getKey(), entry.getValue())); + getAnonymousLogger().info(format("type: %s, count: %s", entry.getKey(), entry.getValue())); } @Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Zone does not exist in the system.") 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..dceb28470b 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 @@ -18,12 +18,12 @@ */ package org.jclouds.ultradns.ws.features; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.equalTo; import static java.util.logging.Logger.getAnonymousLogger; import static org.jclouds.ultradns.ws.domain.ResourceRecord.rrBuilder; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -62,10 +62,10 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest { } private void checkRRPool(RoundRobinPool pool) { - checkNotNull(pool.getZoneId(), "ZoneId cannot be null for a RoundRobinPool %s", pool); - checkNotNull(pool.getId(), "Id cannot be null for a RoundRobinPool %s", pool); - checkNotNull(pool.getName(), "Name cannot be null for a RoundRobinPool %s", pool); - checkNotNull(pool.getDName(), "DName cannot be null for a RoundRobinPool %s", pool); + assertNotNull(pool.getZoneId(), "ZoneId cannot be null for " + pool); + assertNotNull(pool.getId(), "Id cannot be null for " + pool); + assertNotNull(pool.getName(), "Name cannot be null for " + pool); + assertNotNull(pool.getDName(), "DName cannot be null for " + pool); } @Test diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java index 7cb28c7eb6..33da93c9d5 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.ultradns.ws.features; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import org.jclouds.ultradns.ws.domain.Task; @@ -33,10 +33,10 @@ import org.testng.annotations.Test; public class TaskApiLiveTest extends BaseUltraDNSWSApiLiveTest { private void checkTask(Task task) { - checkNotNull(task.getGuid(), "Guid cannot be null for a Task %s", task); - checkNotNull(task.getStatusCode(), "StatusCode cannot be null for a Task %s", task); - checkNotNull(task.getMessage(), "While Message can be null for a Task, its Optional wrapper cannot %s", task); - checkNotNull(task.getResultUrl(), "While ResultUrl can be null for a Task, its Optional wrapper cannot %s", task); + assertNotNull(task.getGuid(), "Guid cannot be null for " + task); + assertNotNull(task.getStatusCode(), "StatusCode cannot be null for " + task); + assertNotNull(task.getMessage(), "While Message can be null, its Optional wrapper cannot " + task); + assertNotNull(task.getResultUrl(), "While ResultUrl can be null, its Optional wrapper cannot " + task); } @Test diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java index 4b5a613fbe..eebb0cb2b3 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TrafficControllerPoolApiLiveTest.java @@ -18,12 +18,12 @@ */ package org.jclouds.ultradns.ws.features; -import static com.google.common.base.Preconditions.checkNotNull; import static java.util.logging.Logger.getAnonymousLogger; import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.idEqualTo; import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.recordIdEqualTo; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -65,10 +65,10 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest } private void checkTCPool(TrafficControllerPool pool) { - checkNotNull(pool.getZoneId(), "ZoneId cannot be null for %s", pool); - checkNotNull(pool.getId(), "Id cannot be null for %s", pool); - checkNotNull(pool.getName(), "Name cannot be null for %s", pool); - checkNotNull(pool.getDName(), "DName cannot be null for %s", pool); + assertNotNull(pool.getZoneId(), "ZoneId cannot be null " + pool); + assertNotNull(pool.getId(), "Id cannot be null " + pool); + assertNotNull(pool.getName(), "Name cannot be null " + pool); + assertNotNull(pool.getDName(), "DName cannot be null " + pool); assertEquals(api(zoneName).getNameByDName(pool.getDName()), pool.getName()); } @@ -104,21 +104,21 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest } static TrafficControllerPoolRecord checkTrafficControllerPoolRecord(TrafficControllerPoolRecord record) { - checkNotNull(record.getId(), "Id cannot be null for %s", record); - checkNotNull(record.getPoolId(), "PoolId cannot be null for %s", record); - checkNotNull(record.getPointsTo(), "PointsTo cannot be null for %s", record); + assertNotNull(record.getId(), "Id cannot be null for " + record); + assertNotNull(record.getPoolId(), "PoolId cannot be null for " + record); + assertNotNull(record.getPointsTo(), "PointsTo cannot be null for " + record); assertTrue(record.getWeight() >= 0, "Weight must be unsigned for " + record); assertTrue(record.getPriority() >= 0, "Priority must be unsigned for " + record); - checkNotNull(record.getType(), "Type cannot be null for %s", record); - checkNotNull(record.getStatus(), "Status cannot be null for %s", record); + assertNotNull(record.getType(), "Type cannot be null for " + record); + assertNotNull(record.getStatus(), "Status cannot be null for " + record); assertTrue(record.getStatus() != Status.UNRECOGNIZED, "unrecognized status for " + record); - checkNotNull(record.getDescription(), "Description cannot be null for %s", record); + assertNotNull(record.getDescription(), "Description cannot be null for " + record); return record; } static PoolRecordSpec checkPoolRecordSpec(PoolRecordSpec record) { - checkNotNull(record.getDescription(), "Description cannot be null for %s", record); - checkNotNull(record.getState(), "State cannot be null for %s", record); + assertNotNull(record.getDescription(), "Description cannot be null for " + record); + assertNotNull(record.getState(), "State cannot be null for " + record); // TODO: collect all possible states then consider enum assertTrue(ImmutableSet.of("Normal", "Normal-NoTest").contains(record.getState()), "Unknown State for " + record); assertTrue(record.getWeight() >= 0, "Weight must be unsigned for " + record); diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ZoneApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ZoneApiLiveTest.java index e30acf7c7a..cc07630995 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ZoneApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/ZoneApiLiveTest.java @@ -18,11 +18,11 @@ */ package org.jclouds.ultradns.ws.features; -import static com.google.common.base.Preconditions.checkNotNull; import static java.util.logging.Logger.getAnonymousLogger; import static org.jclouds.ultradns.ws.domain.Zone.Type.PRIMARY; -import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEquals; +import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEqualTo; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -55,17 +55,16 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest { } private void checkZone(Zone zone) { - checkNotNull(zone.getId(), "Id cannot be null for a Zone %s", zone); - checkNotNull(zone.getName(), "Name cannot be null for a Zone %s", zone); - checkNotNull(zone.getType(), "Type cannot be null for a Zone %s", zone); - checkNotNull(zone.getTypeCode(), "TypeCode cannot be null for a Zone %s", zone); + assertNotNull(zone.getId(), "Id cannot be null for " + zone); + assertNotNull(zone.getName(), "Name cannot be null for " + zone); + assertNotNull(zone.getType(), "Type cannot be null for " + zone); + assertNotNull(zone.getTypeCode(), "TypeCode cannot be null for " + zone); assertEquals(zone.getTypeCode(), zone.getType().getCode()); - checkNotNull(zone.getAccountId(), "AccountId cannot be null for a Zone %s", zone); + assertNotNull(zone.getAccountId(), "AccountId cannot be null for " + zone); assertEquals(zone.getAccountId(), account.getId()); - checkNotNull(zone.getOwnerId(), "OwnerId cannot be null for a Zone %s", zone); - checkNotNull(zone.getDNSSECStatus(), "DNSSECStatus cannot be null for a Zone %s", zone); - checkNotNull(zone.getPrimarySrc(), "While PrimarySrc can be null for a Zone, its Optional wrapper cannot %s", - zone); + assertNotNull(zone.getOwnerId(), "OwnerId cannot be null for " + zone); + assertNotNull(zone.getDNSSECStatus(), "DNSSECStatus cannot be null for " + zone); + assertNotNull(zone.getPrimarySrc(), "While PrimarySrc can be null, its Optional wrapper cannot " + zone); } @Test @@ -76,9 +75,9 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest { checkZone(zone); } - if (response.anyMatch(typeEquals(PRIMARY))) { + if (response.anyMatch(typeEqualTo(PRIMARY))) { assertEquals(api().listByAccountAndType(account.getId(), PRIMARY).toSet(), response - .filter(typeEquals(PRIMARY)).toSet()); + .filter(typeEqualTo(PRIMARY)).toSet()); } } @@ -94,7 +93,7 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest { assertEquals(zoneProperties.getName(), zone.getName()); assertEquals(zoneProperties.getType(), zone.getType()); assertEquals(zoneProperties.getTypeCode(), zone.getTypeCode()); - checkNotNull(zoneProperties.getModified(), "Modified cannot be null for a Zone %s", zone); + assertNotNull(zoneProperties.getModified(), "Modified cannot be null for " + zone); assertTrue(zoneProperties.getResourceRecordCount() >= 0, "ResourceRecordCount must be positive or zero for a Zone " + zone); } @@ -134,7 +133,7 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest { assertEquals(newZone.getName(), name); assertEquals(newZone.getType(), Type.PRIMARY); assertEquals(newZone.getTypeCode(), Type.PRIMARY.getCode()); - checkNotNull(newZone.getModified(), "Modified cannot be null for a Zone %s", newZone); + assertNotNull(newZone.getModified(), "Modified cannot be null for " + newZone); assertEquals(newZone.getResourceRecordCount(), 5); } finally { api().delete(name); diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/RunTestResponseTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/RunTestResponseTest.java index 70b6edbee0..28452378f3 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/RunTestResponseTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/RunTestResponseTest.java @@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.ultradns.ws.xml.TextHandler; +import org.jclouds.ultradns.ws.xml.ElementTextHandler; import org.testng.annotations.Test; /** @@ -35,7 +35,7 @@ public class RunTestResponseTest extends BaseHandlerTest { public void test() { InputStream is = getClass().getResourceAsStream("/taskid.xml"); - TextHandler.Guid handler = injector.getInstance(TextHandler.Guid.class); + ElementTextHandler.Guid handler = injector.getInstance(ElementTextHandler.Guid.class); assertEquals(factory.create(handler).parse(is), "8d7a1725-4f4a-4b70-affa-f01dcce1526e"); } } diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicatesTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicatesTest.java index 0ffadd663a..528ae26998 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicatesTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/TrafficControllerPoolPredicatesTest.java @@ -20,6 +20,8 @@ package org.jclouds.ultradns.ws.predicates; import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.idEqualTo; import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.recordIdEqualTo; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; import org.jclouds.ultradns.ws.domain.TrafficControllerPool; import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord; @@ -43,12 +45,12 @@ public class TrafficControllerPoolPredicatesTest { @Test public void testIdEqualToWhenEqual() { - assert idEqualTo("000000000000002").apply(pool); + assertTrue(idEqualTo("000000000000002").apply(pool)); } @Test public void testIdEqualToWhenNotEqual() { - assert !idEqualTo("000000000000003").apply(pool); + assertFalse(idEqualTo("000000000000003").apply(pool)); } TrafficControllerPoolRecord record = TrafficControllerPoolRecord.builder() @@ -66,11 +68,11 @@ public class TrafficControllerPoolPredicatesTest { @Test public void testRecordIdEqualToWhenEqual() { - assert recordIdEqualTo("0000000000000001").apply(record); + assertTrue(recordIdEqualTo("0000000000000001").apply(record)); } @Test public void testRecordIdEqualToWhenNotEqual() { - assert !recordIdEqualTo("0000000000000002").apply(record); + assertFalse(recordIdEqualTo("0000000000000002").apply(record)); } } diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/ZonePredicatesTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/ZonePredicatesTest.java index 88d3883cba..1466044799 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/ZonePredicatesTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/predicates/ZonePredicatesTest.java @@ -18,7 +18,9 @@ */ package org.jclouds.ultradns.ws.predicates; -import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEquals; +import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEqualTo; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; import org.jclouds.ultradns.ws.domain.Zone; import org.jclouds.ultradns.ws.domain.Zone.DNSSECStatus; @@ -41,11 +43,11 @@ public class ZonePredicatesTest { @Test public void testTypeEqualsWhenEqual() { - assert typeEquals(Type.PRIMARY).apply(zone); + assertTrue(typeEqualTo(Type.PRIMARY).apply(zone)); } @Test public void testTypeEqualsWhenNotEqual() { - assert !typeEquals(Type.SECONDARY).apply(zone); + assertFalse(typeEqualTo(Type.SECONDARY).apply(zone)); } } From 16b43b08db7adb4711654819c69cbcd71aec3690 Mon Sep 17 00:00:00 2001 From: adriancole Date: Sun, 24 Mar 2013 22:35:28 -0700 Subject: [PATCH 4/4] it is possible for an ultradns error to not include a message --- .../jclouds/ultradns/ws/UltraDNSWSError.java | 13 ++++--- .../ws/handlers/UltraDNSWSErrorHandler.java | 16 ++++---- .../ws/xml/UltraWSExceptionHandler.java | 9 ++--- .../ultradns/ws/features/TaskApiLiveTest.java | 2 +- .../handlers/UltraDNSWSErrorHandlerTest.java | 39 ++++++++++++++----- .../ultradns/ws/parse/TaskNotFoundTest.java | 4 +- .../ws/parse/UltraWSExceptionTest.java | 4 +- .../src/test/resources/server_fault.xml | 17 ++++++++ 8 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 providers/ultradns-ws/src/test/resources/server_fault.xml diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSError.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSError.java index aabb289e27..f8e3b26116 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSError.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSError.java @@ -17,24 +17,25 @@ * under the License. */ package org.jclouds.ultradns.ws; - import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; import com.google.common.base.Objects; +import com.google.common.base.Optional; /** * @author Adrian Cole */ public final class UltraDNSWSError { - public static UltraDNSWSError fromCodeAndDescription(int code, String description) { + public static UltraDNSWSError fromCodeAndDescription(int code, Optional description) { return new UltraDNSWSError(code, description); } private final int code; - private final String description; + private final Optional description; - private UltraDNSWSError(int code, String description) { + private UltraDNSWSError(int code, Optional description) { this.code = code; this.description = checkNotNull(description, "description for code %s", code); } @@ -49,7 +50,7 @@ public final class UltraDNSWSError { /** * The description of the error. ex {@code Zone does not exist in the system.} */ - public String getDescription() { + public Optional getDescription() { return description; } @@ -70,6 +71,6 @@ public final class UltraDNSWSError { @Override public String toString() { - return String.format("Error %s: %s", code, description); + return description.isPresent() ? format("Error %s: %s", code, description.get()) : format("Error %s", code); } } diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandler.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandler.java index 47f5cb0f36..3a598084c8 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandler.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandler.java @@ -78,10 +78,7 @@ public class UltraDNSWSErrorHandler implements HttpErrorHandler { * there are 51002 potential codes. This defines the ones we are handling. */ static final class ErrorCodes { - /** - * Cannot find task with guid. - */ - static final int TASK_NOT_FOUND = 0; + static final int UNKNOWN = 0; /** * Zone does not exist in the system. */ @@ -117,18 +114,23 @@ public class UltraDNSWSErrorHandler implements HttpErrorHandler { } private Exception refineException(UltraDNSWSResponseException exception) { + String message = exception.getError().getDescription().or(exception.getMessage()); switch (exception.getError().getCode()) { - case TASK_NOT_FOUND: + case UNKNOWN: + if (!exception.getError().getDescription().isPresent()) + return exception; + if (exception.getError().getDescription().get().indexOf("Cannot find") == -1) + return exception; case ZONE_NOT_FOUND: case RESOURCE_RECORD_NOT_FOUND: case ACCOUNT_NOT_FOUND: case POOL_NOT_FOUND: case POOL_RECORD_NOT_FOUND: - return new ResourceNotFoundException(exception.getError().getDescription(), exception); + return new ResourceNotFoundException(message, exception); case ZONE_ALREADY_EXISTS: case RESOURCE_RECORD_ALREADY_EXISTS: case POOL_ALREADY_EXISTS: - return new ResourceAlreadyExistsException(exception.getError().getDescription(), exception); + return new ResourceAlreadyExistsException(message, exception); } return exception; } diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/UltraWSExceptionHandler.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/UltraWSExceptionHandler.java index 64f5a587d1..cc7dc5fabc 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/UltraWSExceptionHandler.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/xml/UltraWSExceptionHandler.java @@ -24,6 +24,8 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix; import org.jclouds.http.functions.ParseSax; import org.jclouds.ultradns.ws.UltraDNSWSError; +import com.google.common.base.Optional; + /** * * @author Adrian Cole @@ -36,12 +38,7 @@ public class UltraWSExceptionHandler extends ParseSax.HandlerForGeneratedRequest @Override public UltraDNSWSError getResult() { - try { - return code != -1 ? UltraDNSWSError.fromCodeAndDescription(code, description) : null; - } finally { - code = -1; - description = null; - } + return code != -1 ? UltraDNSWSError.fromCodeAndDescription(code, Optional.fromNullable(description)) : null; } @Override diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java index 33da93c9d5..341d55086c 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/features/TaskApiLiveTest.java @@ -53,7 +53,7 @@ public class TaskApiLiveTest extends BaseUltraDNSWSApiLiveTest { assertEquals(got.getGuid(), task.getGuid()); assertEquals(got.getStatusCode(), task.getStatusCode()); assertEquals(got.getMessage(), task.getMessage()); - assertEquals(got.getResultUrl(), task.getMessage()); + assertEquals(got.getResultUrl(), task.getResultUrl()); } } diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandlerTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandlerTest.java index 720566e622..32597188ce 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandlerTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/handlers/UltraDNSWSErrorHandlerTest.java @@ -47,7 +47,26 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSErrorHandler.class); @Test - public void testCode0SetsResourceNotFoundException() throws IOException { + public void testCode0SetsUltraDNSWSResponseException() throws IOException { + HttpRequest request = HttpRequest.builder().method("POST") + .endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01") + .addHeader("Host", "ultra-api.ultradns.com:8443").payload(payloadFromResource("/list_tasks.xml")).build(); + HttpCommand command = new HttpCommand(request); + HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500) + .payload(payloadFromResource("/server_fault.xml")).build(); + + function.handleError(command, response); + + assertEquals(command.getException().getClass(), UltraDNSWSResponseException.class); + assertEquals(command.getException().getMessage(), "Error 0"); + + UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException()); + + assertEquals(exception.getError().getCode(), 0); + } + + @Test + public void testCode0ForDescriptionMatchingCannotFindSetsResourceNotFoundException() throws IOException { HttpRequest request = HttpRequest.builder().method("POST") .endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01") .addHeader("Host", "ultra-api.ultradns.com:8443").payload(payloadFromResource("/list_tasks.xml")).build(); @@ -63,7 +82,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 0: Cannot find task with guid AAAAAAAAAAAAAAAA"); - assertEquals(exception.getError().getDescription(), "Cannot find task with guid AAAAAAAAAAAAAAAA"); + assertEquals(exception.getError().getDescription().get(), "Cannot find task with guid AAAAAAAAAAAAAAAA"); assertEquals(exception.getError().getCode(), 0); } @@ -85,7 +104,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 2401: Account not found in the system. ID: AAAAAAAAAAAAAAAA"); - assertEquals(exception.getError().getDescription(), "Account not found in the system. ID: AAAAAAAAAAAAAAAA"); + assertEquals(exception.getError().getDescription().get(), "Account not found in the system. ID: AAAAAAAAAAAAAAAA"); assertEquals(exception.getError().getCode(), 2401); } @@ -106,7 +125,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 1801: Zone does not exist in the system."); - assertEquals(exception.getError().getDescription(), "Zone does not exist in the system."); + assertEquals(exception.getError().getDescription().get(), "Zone does not exist in the system."); assertEquals(exception.getError().getCode(), 1801); } @@ -127,7 +146,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 2103: No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA"); - assertEquals(exception.getError().getDescription(), "No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA"); + assertEquals(exception.getError().getDescription().get(), "No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA"); assertEquals(exception.getError().getCode(), 2103); } @@ -148,7 +167,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 1802: Zone already exists in the system."); - assertEquals(exception.getError().getDescription(), "Zone already exists in the system."); + assertEquals(exception.getError().getDescription().get(), "Zone already exists in the system."); assertEquals(exception.getError().getCode(), 1802); } @@ -171,7 +190,7 @@ public class UltraDNSWSErrorHandlerTest { assertEquals(exception.getMessage(), "Error 2111: Resource Record of type 15 with these attributes already exists in the system."); - assertEquals(exception.getError().getDescription(), + assertEquals(exception.getError().getDescription().get(), "Resource Record of type 15 with these attributes already exists in the system."); assertEquals(exception.getError().getCode(), 2111); } @@ -193,7 +212,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 2911: Pool does not exist in the system"); - assertEquals(exception.getError().getDescription(), "Pool does not exist in the system"); + assertEquals(exception.getError().getDescription().get(), "Pool does not exist in the system"); assertEquals(exception.getError().getCode(), 2911); } @@ -216,7 +235,7 @@ public class UltraDNSWSErrorHandlerTest { assertEquals(exception.getMessage(), "Error 2912: Pool already created for this host name : www.rrpool.adrianc.rrpool.ultradnstest.jclouds.org."); - assertEquals(exception.getError().getDescription(), + assertEquals(exception.getError().getDescription().get(), "Pool already created for this host name : www.rrpool.adrianc.rrpool.ultradnstest.jclouds.org."); assertEquals(exception.getError().getCode(), 2912); } @@ -238,7 +257,7 @@ public class UltraDNSWSErrorHandlerTest { UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause()); assertEquals(exception.getMessage(), "Error 3101: Pool Record does not exist."); - assertEquals(exception.getError().getDescription(), "Pool Record does not exist."); + assertEquals(exception.getError().getDescription().get(), "Pool Record does not exist."); assertEquals(exception.getError().getCode(), 3101); } diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/TaskNotFoundTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/TaskNotFoundTest.java index fe764bd269..69261edd0a 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/TaskNotFoundTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/TaskNotFoundTest.java @@ -27,6 +27,8 @@ import org.jclouds.ultradns.ws.UltraDNSWSError; import org.jclouds.ultradns.ws.xml.UltraWSExceptionHandler; import org.testng.annotations.Test; +import com.google.common.base.Optional; + /** * @author Adrian Cole */ @@ -45,6 +47,6 @@ public class TaskNotFoundTest extends BaseHandlerTest { } public UltraDNSWSError expected() { - return UltraDNSWSError.fromCodeAndDescription(0, "Cannot find task with guid AAAAAAAAAAAAAAAA"); + return UltraDNSWSError.fromCodeAndDescription(0, Optional.of("Cannot find task with guid AAAAAAAAAAAAAAAA")); } } diff --git a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/UltraWSExceptionTest.java b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/UltraWSExceptionTest.java index 3cb99f311e..33a2d4c84a 100644 --- a/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/UltraWSExceptionTest.java +++ b/providers/ultradns-ws/src/test/java/org/jclouds/ultradns/ws/parse/UltraWSExceptionTest.java @@ -27,6 +27,8 @@ import org.jclouds.ultradns.ws.UltraDNSWSError; import org.jclouds.ultradns.ws.xml.UltraWSExceptionHandler; import org.testng.annotations.Test; +import com.google.common.base.Optional; + /** * @author Adrian Cole */ @@ -45,7 +47,7 @@ public class UltraWSExceptionTest extends BaseHandlerTest { } public UltraDNSWSError expected() { - return UltraDNSWSError.fromCodeAndDescription(1801, "Zone does not exist in the system."); + return UltraDNSWSError.fromCodeAndDescription(1801, Optional.of("Zone does not exist in the system.")); } } diff --git a/providers/ultradns-ws/src/test/resources/server_fault.xml b/providers/ultradns-ws/src/test/resources/server_fault.xml new file mode 100644 index 0000000000..1f296320ce --- /dev/null +++ b/providers/ultradns-ws/src/test/resources/server_fault.xml @@ -0,0 +1,17 @@ + + + + soap:Server + Fault occurred while processing. + + + 0 + + + + + + \ No newline at end of file