List of utility methods to do Assert
void | assertFails(Class extends Throwable> expectedThrowable, String pattern, int... values) assert Fails try { getData(pattern, values); StringBuilder sb = new StringBuilder(); sb.append("getData() with pattern ").append(coalesce(pattern)).append(" and values {"); for (int i = 0; i < values.length; i++) { sb.append(" ").append(values[i]); if (i < values.length - 1) { sb.append(","); ... |
void | assertFalse(boolean test, String message) Throws an AssertionError if test is true. if (test) throw new AssertionError(message); |
void | assertFalse(final boolean result, final String message) assert False if (result) throw new IllegalArgumentException(message); |
void | assertFalse(String string, boolean b) assert False if (b) throw new IllegalStateException(string); |
void | assertFieldPositive(int fieldValue, String fieldName) Throws an IllegalArgumentException if the specified field is <=0 .
if (fieldValue <= 0) throw new IllegalArgumentException("Field '" + fieldName + "' must be a positive integer."); |
void | assertGreater(long first, long second) Assert that the first argument is greater than the second if (first <= second) { throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second)); |
void | assertGreaterOrEqualsThan(final long value, final long limit, final String name) Asserts that the parameter's value is equals or greater than a specific limit. if (value < limit) { throw new IllegalArgumentException(PREFIX + name + " is less than limit."); |
void | assertGreaterThanOrEquals(String name, double comparedTo, double number) assert Greater Than Or Equals if (lessThan(comparedTo, number)) { throw new AssertionError( name + ": " + number + " is not greater than or equal to " + comparedTo + " !"); |
void | assertHasInterface(Class> interfaceClass, Class> objectClass) assert Has Interface Class<?>[] interfaces = objectClass.getInterfaces(); for (Class<?> singleInterface : interfaces) { if (singleInterface.equals(interfaceClass)) { return; throw new AssertionError("Class " + objectClass.getName() + " did not implement interface: " + "" + interfaceClass.getName()); ... |
void | assertHasLength(String... params) Check that string is not null if (params != null) { for (int idx = 0; idx < params.length; idx++) { String currentparam = params[idx]; if (null == currentparam || currentparam.isEmpty()) { throw new IllegalArgumentException( "[Assertion failed] - Parameter #" + idx + "(string) must not be null nor empty"); |