addressed nits from issue #1453

This commit is contained in:
adriancole 2013-03-24 22:05:52 -07:00
parent d7221dc9fc
commit 6ab744d674
26 changed files with 130 additions and 161 deletions

View File

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

View File

@ -42,9 +42,9 @@ public class ResourceRecord {
private ResourceRecord(String dName, int type, int ttl, List<String> 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);
}

View File

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

View File

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

View File

@ -43,7 +43,7 @@ public final class Zone {
DNSSECStatus dnssecStatus, Optional<String> 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);

View File

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

View File

@ -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<String> create(@PayloadParam("resourceRecord") ResourceRecord toCreate)
throws ResourceAlreadyExistsException;

View File

@ -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("<v01:addRRLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>1</poolRecordType><rrGUID /></v01:addRRLBPool>")
ListenableFuture<String> 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("<v01:addRecordToRRPool><transactionID /><roundRobinRecord lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" ZoneName=\"{zoneName}\" Type=\"1\" TTL=\"{ttl}\"/></v01:addRecordToRRPool>")
ListenableFuture<String> 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("<v01:addRRLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>28</poolRecordType><rrGUID /></v01:addRRLBPool>")
ListenableFuture<String> 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("<v01:addRecordToRRPool><transactionID /><roundRobinRecord lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" ZoneName=\"{zoneName}\" Type=\"28\" TTL=\"{ttl}\"/></v01:addRecordToRRPool>")
ListenableFuture<String> addAAAARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID,
@PayloadParam("address") String ipv6Address, @PayloadParam("ttl") int ttl)

View File

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

View File

@ -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("<v01:runTest><value>{value}</value></v01:runTest>")
ListenableFuture<String> runTest(@PayloadParam("value") String value);

View File

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

View File

@ -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("<v01:addTCLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>1</poolRecordType><failOver>Enabled</failOver><probing>Enabled</probing><maxActive>0</maxActive><rrGUID /></v01:addTCLBPool>")
ListenableFuture<String> 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("<v01:addPoolRecord><transactionID /><poolID>{poolID}</poolID><pointsTo>{pointsTo}</pointsTo><priority /><failOverDelay /><ttl>{ttl}</ttl><weight /><mode /><threshold /></v01:addPoolRecord>")
ListenableFuture<String> 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("<v01:addPoolRecord><transactionID /><poolID>{poolID}</poolID><pointsTo>{pointsTo}</pointsTo><priority /><failOverDelay /><ttl>{ttl}</ttl><weight>{weight}</weight><mode /><threshold /></v01:addPoolRecord>")
ListenableFuture<String> addRecordToPoolWithTTLAndWeight(@PayloadParam("pointsTo") String pointsTo,
@PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl, @PayloadParam("weight") int weight)

View File

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

View File

@ -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<TrafficControllerPool> 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<TrafficControllerPoolRecord> recordIdEqualTo(String recordId) {
return new RecordIdEqualToPredicate(recordId);
}
private static final class RecordIdEqualToPredicate implements Predicate<TrafficControllerPoolRecord> {
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 + ")";
}
}
}

View File

@ -32,22 +32,25 @@ import com.google.common.base.Predicate;
*/
public class ZonePredicates {
/**
* matches zones of the given type
*/
public static Predicate<Zone> typeEquals(final Type type) {
checkNotNull(type, "type must be defined");
public static Predicate<Zone> typeEqualTo(Type type) {
return new TypeEqualToPredicate(type);
}
return new Predicate<Zone>() {
@Override
public boolean apply(Zone zone) {
return type.equals(zone.getType());
}
private static final class TypeEqualToPredicate implements Predicate<Zone> {
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 + ")";
}
}
}

View File

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

View File

@ -28,48 +28,44 @@ import org.jclouds.http.functions.ParseSax;
*
* @author Adrian Cole
*/
public abstract class TextHandler extends ParseSax.HandlerForGeneratedRequestWithResult<String> {
public abstract class ElementTextHandler extends ParseSax.HandlerForGeneratedRequestWithResult<String> {
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

View File

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

View File

@ -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<Integer, AtomicLong> 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.")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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