List of utility methods to do Assert
void | assertNotTrue(boolean conditionThatMustNotBeTrue, String msgWhenTrue) assert Not True if (conditionThatMustNotBeTrue) { throw new IllegalArgumentException(msgWhenTrue); |
void | assertNotTrue(boolean value, String message) Throws exception if value is true. if (value == true) { throw new IllegalArgumentException(message); |
boolean | assertObjectEmpty(Object value) assert Object Empty return value != null;
|
void | assertObjEquals(Object expected, Object actual) assert Obj Equals assertWithMessage(null, expected, actual); |
void | assertOffsetLengthValid(int offset, int length, int arrayLength) assert Offset Length Valid if (offset < 0) { throw new IllegalArgumentException("The array offset was negative"); if (length < 0) { throw new IllegalArgumentException("The array length was negative"); if (offset + length > arrayLength) { throw new ArrayIndexOutOfBoundsException("The array offset+length would access past end of array"); ... |
void | assertOid(final String s) assert Oid if ((s != null) && !isOid(s)) { throw new RuntimeException("Expected an OID but found " + s); |
void | assertOneBitMask(long mask) assert One Bit Mask assert (mask & (mask - 1)) == 0 : "Mask must have only one bit set, but got: " + Long.toBinaryString(mask); |
Object | assertParameter(Class expectedClass, Object[] params, int index) Utility method to provide more descriptive unchecked exceptions for unmarshalling object from Tapestry service Parameters. if (params == null || params.length < index) { throw new IllegalArgumentException("Missing parameter at position " + index); if (params[index] != null) { Class actualClass = params[index].getClass(); if (!expectedClass.isAssignableFrom(actualClass)) { throw new IllegalArgumentException("Object of class type " + expectedClass.getName() + " was expected at position " + index + " but class type was " + actualClass.getName()); ... |
void | assertParameterInRange(long param, long lower, long upper) assert Parameter In Range if (!checkParamRange(param, lower, true, upper, true)) { throw new IllegalArgumentException( String.format("%d not in valid range [%d, %d]", param, lower, upper)); |
void | assertParameterWithinBounds(String name, long lower, long upper, long parameter) Throw an IllegalArgumentException when a number is not within the supplied range. if (parameter < lower || parameter > upper) { throw new IllegalArgumentException( String.format("Invalid %s: %d (expected: %d <= n < %d)", name, parameter, lower, upper + 1)); |