diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 5aa8be24f..a97452f58 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -106,6 +106,7 @@ The type attribute can be add,update,fix,remove. Reuse own code in Functions.java #493. MethodUtils.getAnnotation() with searchSupers = true does not work if super is generic #494. Avoid unnecessary allocation in StringUtils.wrapIfMissing. #496. + Internally use Validate.notNull(foo, ...) instead of Validate.isTrue(foo != null, ...). diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java index be656d2a5..0504bedaa 100644 --- a/src/main/java/org/apache/commons/lang3/CharRange.java +++ b/src/main/java/org/apache/commons/lang3/CharRange.java @@ -179,7 +179,7 @@ final class CharRange implements Iterable, Serializable { * @throws IllegalArgumentException if {@code null} input */ public boolean contains(final CharRange range) { - Validate.isTrue(range != null, "The Range must not be null"); + Validate.notNull(range, "The Range must not be null"); if (negated) { if (range.negated) { return start >= range.start && end <= range.end; diff --git a/src/main/java/org/apache/commons/lang3/CharUtils.java b/src/main/java/org/apache/commons/lang3/CharUtils.java index be0aea442..b872ac0f8 100644 --- a/src/main/java/org/apache/commons/lang3/CharUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharUtils.java @@ -134,7 +134,7 @@ public class CharUtils { * @throws IllegalArgumentException if the Character is null */ public static char toChar(final Character ch) { - Validate.isTrue(ch != null, "The Character must not be null"); + Validate.notNull(ch, "The Character must not be null"); return ch.charValue(); } @@ -175,7 +175,7 @@ public class CharUtils { * @throws IllegalArgumentException if the String is empty */ public static char toChar(final String str) { - Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty"); + Validate.notEmpty(str, "The String must not be empty"); return str.charAt(0); } @@ -263,7 +263,7 @@ public class CharUtils { * @throws IllegalArgumentException if the Character is not ASCII numeric or is null */ public static int toIntValue(final Character ch) { - Validate.isTrue(ch != null, "The character must not be null"); + Validate.notNull(ch, "The character must not be null"); return toIntValue(ch.charValue()); } diff --git a/src/main/java/org/apache/commons/lang3/EnumUtils.java b/src/main/java/org/apache/commons/lang3/EnumUtils.java index 75b052a9f..1df43013a 100644 --- a/src/main/java/org/apache/commons/lang3/EnumUtils.java +++ b/src/main/java/org/apache/commons/lang3/EnumUtils.java @@ -116,7 +116,7 @@ public class EnumUtils { Validate.notNull(values); long total = 0; for (final E constant : values) { - Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED); + Validate.notNull(constant, NULL_ELEMENTS_NOT_PERMITTED); total |= 1L << constant.ordinal(); } return total; @@ -173,7 +173,7 @@ public class EnumUtils { Validate.notNull(values); final EnumSet condensed = EnumSet.noneOf(enumClass); for (final E constant : values) { - Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED); + Validate.notNull(constant, NULL_ELEMENTS_NOT_PERMITTED); condensed.add(constant); } final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1]; diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index 28f8d76ea..14bfc1dc7 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -133,7 +133,7 @@ public class SerializationUtils { * @throws SerializationException (runtime) if the serialization fails */ public static void serialize(final Serializable obj, final OutputStream outputStream) { - Validate.isTrue(outputStream != null, "The OutputStream must not be null"); + Validate.notNull(outputStream, "The OutputStream must not be null"); try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) { out.writeObject(obj); } catch (final IOException ex) { @@ -188,7 +188,7 @@ public class SerializationUtils { * (runtime) if the serialization fails */ public static T deserialize(final InputStream inputStream) { - Validate.isTrue(inputStream != null, "The InputStream must not be null"); + Validate.notNull(inputStream, "The InputStream must not be null"); try (ObjectInputStream in = new ObjectInputStream(inputStream)) { @SuppressWarnings("unchecked") final T obj = (T) in.readObject(); @@ -219,7 +219,7 @@ public class SerializationUtils { * (runtime) if the serialization fails */ public static T deserialize(final byte[] objectData) { - Validate.isTrue(objectData != null, "The byte[] must not be null"); + Validate.notNull(objectData, "The byte[] must not be null"); return deserialize(new ByteArrayInputStream(objectData)); } diff --git a/src/main/java/org/apache/commons/lang3/ThreadUtils.java b/src/main/java/org/apache/commons/lang3/ThreadUtils.java index 5534194fa..fef3dc850 100644 --- a/src/main/java/org/apache/commons/lang3/ThreadUtils.java +++ b/src/main/java/org/apache/commons/lang3/ThreadUtils.java @@ -50,7 +50,7 @@ public class ThreadUtils { * thread groups from this thread's thread group up to the system thread group */ public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) { - Validate.isTrue(threadGroup != null, "The thread group must not be null"); + Validate.notNull(threadGroup, "The thread group must not be null"); final Thread thread = findThreadById(threadId); if (thread != null && threadGroup.equals(thread.getThreadGroup())) { return thread; @@ -73,7 +73,7 @@ public class ThreadUtils { * thread groups from this thread's thread group up to the system thread group */ public static Thread findThreadById(final long threadId, final String threadGroupName) { - Validate.isTrue(threadGroupName != null, "The thread group name must not be null"); + Validate.notNull(threadGroupName, "The thread group name must not be null"); final Thread thread = findThreadById(threadId); if (thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) { return thread; @@ -114,8 +114,8 @@ public class ThreadUtils { * thread groups from this thread's thread group up to the system thread group */ public static Collection findThreadsByName(final String threadName, final String threadGroupName) { - Validate.isTrue(threadName != null, "The thread name must not be null"); - Validate.isTrue(threadGroupName != null, "The thread group name must not be null"); + Validate.notNull(threadName, "The thread name must not be null"); + Validate.notNull(threadGroupName, "The thread group name must not be null"); final Collection threadGroups = findThreadGroups(new NamePredicate(threadGroupName)); @@ -305,7 +305,7 @@ public class ThreadUtils { */ public NamePredicate(final String name) { super(); - Validate.isTrue(name != null, "The name must not be null"); + Validate.notNull(name, "The name must not be null"); this.name = name; } @@ -390,8 +390,8 @@ public class ThreadUtils { * thread groups from this thread's thread group up to the system thread group */ public static Collection findThreads(final ThreadGroup group, final boolean recurse, final ThreadPredicate predicate) { - Validate.isTrue(group != null, "The group must not be null"); - Validate.isTrue(predicate != null, "The predicate must not be null"); + Validate.notNull(group, "The group must not be null"); + Validate.notNull(predicate, "The predicate must not be null"); int count = group.activeCount(); Thread[] threads; @@ -422,8 +422,8 @@ public class ThreadUtils { * thread groups from this thread's thread group up to the system thread group */ public static Collection findThreadGroups(final ThreadGroup group, final boolean recurse, final ThreadGroupPredicate predicate) { - Validate.isTrue(group != null, "The group must not be null"); - Validate.isTrue(predicate != null, "The predicate must not be null"); + Validate.notNull(group, "The group must not be null"); + Validate.notNull(predicate, "The predicate must not be null"); int count = group.activeGroupCount(); ThreadGroup[] threadGroups; diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java index 6beeaf7b6..2ea1f69e6 100644 --- a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java @@ -104,8 +104,8 @@ public class DiffBuilder implements Builder> { public DiffBuilder(final T lhs, final T rhs, final ToStringStyle style, final boolean testTriviallyEqual) { - Validate.isTrue(lhs != null, "lhs cannot be null"); - Validate.isTrue(rhs != null, "rhs cannot be null"); + Validate.notNull(lhs, "lhs cannot be null"); + Validate.notNull(rhs, "rhs cannot be null"); this.diffs = new ArrayList<>(); this.left = lhs; @@ -950,7 +950,7 @@ public class DiffBuilder implements Builder> { public DiffBuilder append(final String fieldName, final DiffResult diffResult) { validateFieldNameNotNull(fieldName); - Validate.isTrue(diffResult != null, "Diff result cannot be null"); + Validate.notNull(diffResult, "Diff result cannot be null"); if (objectsTriviallyEqual) { return this; } @@ -978,7 +978,7 @@ public class DiffBuilder implements Builder> { } private void validateFieldNameNotNull(final String fieldName) { - Validate.isTrue(fieldName != null, "Field name cannot be null"); + Validate.notNull(fieldName, "Field name cannot be null"); } } diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java index 8132dd4f0..b8594ad6b 100644 --- a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java +++ b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java @@ -74,9 +74,9 @@ public class DiffResult implements Iterable> { */ DiffResult(final T lhs, final T rhs, final List> diffs, final ToStringStyle style) { - Validate.isTrue(lhs != null, "Left hand object cannot be null"); - Validate.isTrue(rhs != null, "Right hand object cannot be null"); - Validate.isTrue(diffs != null, "List of differences cannot be null"); + Validate.notNull(lhs, "Left hand object cannot be null"); + Validate.notNull(rhs, "Right hand object cannot be null"); + Validate.notNull(diffs, "List of differences cannot be null"); this.diffs = diffs; this.lhs = lhs; diff --git a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java index c430b4060..7b7bbb015 100644 --- a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java @@ -358,7 +358,7 @@ public class HashCodeBuilder implements Builder { */ public static int reflectionHashCode(final int initialNonZeroOddNumber, final int multiplierNonZeroOddNumber, final T object, final boolean testTransients, final Class reflectUpToClass, final String... excludeFields) { - Validate.isTrue(object != null, "The object to build a hash code for must not be null"); + Validate.notNull(object, "The object to build a hash code for must not be null"); final HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber); Class clazz = object.getClass(); reflectionAppend(object, clazz, builder, testTransients, excludeFields); diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java index 3996a59a3..d19aa13fa 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java @@ -434,8 +434,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { } private static Object checkNotNull(final Object obj) { - Validate.isTrue(obj != null, "The Object passed in should not be null."); - return obj; + return Validate.notNull(obj, "The Object passed in should not be null."); } /** diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java index ace1f8356..3522ec34b 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java @@ -133,8 +133,7 @@ public class ToStringBuilder implements Builder { * @throws IllegalArgumentException if the style is {@code null} */ public static void setDefaultStyle(final ToStringStyle style) { - Validate.isTrue(style != null, "The style must not be null"); - defaultStyle = style; + defaultStyle = Validate.notNull(style, "The style must not be null"); } //---------------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java index c1d07353e..6fca65c8d 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java @@ -120,6 +120,6 @@ public class CallableBackgroundInitializer extends BackgroundInitializer { * @throws IllegalArgumentException if the {@code Callable} is null */ private void checkCallable(final Callable call) { - Validate.isTrue(call != null, "Callable must not be null!"); + Validate.notNull(call, "Callable must not be null!"); } } diff --git a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java index 6a6a9a092..7e36fd9db 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java @@ -133,8 +133,8 @@ public class MultiBackgroundInitializer * @throws IllegalStateException if {@code start()} has already been called */ public void addInitializer(final String name, final BackgroundInitializer init) { - Validate.isTrue(name != null, "Name of child initializer must not be null!"); - Validate.isTrue(init != null, "Child initializer must not be null!"); + Validate.notNull(name, "Name of child initializer must not be null!"); + Validate.notNull(init, "Child initializer must not be null!"); synchronized (this) { if (isStarted()) { diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index 6bfc79ef6..a2a67b4bc 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -632,7 +632,7 @@ public class ExceptionUtils { if (throwable == null) { return; } - Validate.isTrue(stream != null, "The PrintStream must not be null"); + Validate.notNull(stream, "The PrintStream must not be null"); final String trace[] = getRootCauseStackTrace(throwable); for (final String element : trace) { stream.println(element); @@ -663,7 +663,7 @@ public class ExceptionUtils { if (throwable == null) { return; } - Validate.isTrue(writer != null, "The PrintWriter must not be null"); + Validate.notNull(writer, "The PrintWriter must not be null"); final String trace[] = getRootCauseStackTrace(throwable); for (final String element : trace) { writer.println(element); diff --git a/src/main/java/org/apache/commons/lang3/math/Fraction.java b/src/main/java/org/apache/commons/lang3/math/Fraction.java index 7d452c141..7c11f2a2f 100644 --- a/src/main/java/org/apache/commons/lang3/math/Fraction.java +++ b/src/main/java/org/apache/commons/lang3/math/Fraction.java @@ -312,7 +312,7 @@ public final class Fraction extends Number implements Comparable { * @throws NumberFormatException if the number format is invalid */ public static Fraction getFraction(String str) { - Validate.isTrue(str != null, "The string must not be null"); + Validate.notNull(str, "The string must not be null"); // parse double format int pos = str.indexOf('.'); if (pos >= 0) { @@ -730,7 +730,7 @@ public final class Fraction extends Number implements Comparable { * cannot be represented in an {@code int}. */ private Fraction addSub(final Fraction fraction, final boolean isAdd) { - Validate.isTrue(fraction != null, "The fraction must not be null"); + Validate.notNull(fraction, "The fraction must not be null"); // zero is identity for addition. if (numerator == 0) { return isAdd ? fraction : fraction.negate(); @@ -778,7 +778,7 @@ public final class Fraction extends Number implements Comparable { * {@code Integer.MAX_VALUE} */ public Fraction multiplyBy(final Fraction fraction) { - Validate.isTrue(fraction != null, "The fraction must not be null"); + Validate.notNull(fraction, "The fraction must not be null"); if (numerator == 0 || fraction.numerator == 0) { return ZERO; } @@ -801,7 +801,7 @@ public final class Fraction extends Number implements Comparable { * {@code Integer.MAX_VALUE} */ public Fraction divideBy(final Fraction fraction) { - Validate.isTrue(fraction != null, "The fraction must not be null"); + Validate.notNull(fraction, "The fraction must not be null"); if (fraction.numerator == 0) { throw new ArithmeticException("The fraction to divide by must not be zero"); } diff --git a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java index d9fb5fa04..ae737cf60 100644 --- a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java +++ b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java @@ -37,7 +37,7 @@ public class IEEE754rUtils { * @since 3.4 Changed signature from min(double[]) to min(double...) */ public static double min(final double... array) { - Validate.isTrue(array != null, "The Array must not be null"); + Validate.notNull(array, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); // Finds and returns min @@ -59,7 +59,7 @@ public class IEEE754rUtils { * @since 3.4 Changed signature from min(float[]) to min(float...) */ public static float min(final float... array) { - Validate.isTrue(array != null, "The Array must not be null"); + Validate.notNull(array, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); // Finds and returns min @@ -149,7 +149,7 @@ public class IEEE754rUtils { * @since 3.4 Changed signature from max(double[]) to max(double...) */ public static double max(final double... array) { - Validate.isTrue(array != null, "The Array must not be null"); + Validate.notNull(array, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); // Finds and returns max @@ -171,7 +171,7 @@ public class IEEE754rUtils { * @since 3.4 Changed signature from max(float[]) to max(float...) */ public static float max(final float... array) { - Validate.isTrue(array != null, "The Array must not be null"); + Validate.notNull(array, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); // Finds and returns max diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java index 97aee235c..ab7badc19 100644 --- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java +++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java @@ -1312,7 +1312,7 @@ public class NumberUtils { * @throws IllegalArgumentException if {@code array} is either {@code null} or empty */ private static void validateArray(final Object array) { - Validate.isTrue(array != null, "The Array must not be null"); + Validate.notNull(array, "The Array must not be null"); Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty."); } diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java index 07eb8395a..4d2ce164d 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java @@ -86,7 +86,7 @@ public class FieldUtils { * in the inheritance hierarchy */ public static Field getField(final Class cls, final String fieldName, final boolean forceAccess) { - Validate.isTrue(cls != null, "The class must not be null"); + Validate.notNull(cls, "The class must not be null"); Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty"); // FIXME is this workaround still needed? lang requires Java 6 // Sun Java 1.3 has a bugged implementation of getField hence we write the @@ -169,7 +169,7 @@ public class FieldUtils { * if the class is {@code null}, or the field name is blank or empty */ public static Field getDeclaredField(final Class cls, final String fieldName, final boolean forceAccess) { - Validate.isTrue(cls != null, "The class must not be null"); + Validate.notNull(cls, "The class must not be null"); Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty"); try { // only consider the specified class by using getDeclaredField() @@ -214,7 +214,7 @@ public class FieldUtils { * @since 3.2 */ public static List getAllFieldsList(final Class cls) { - Validate.isTrue(cls != null, "The class must not be null"); + Validate.notNull(cls, "The class must not be null"); final List allFields = new ArrayList<>(); Class currentClass = cls; while (currentClass != null) { @@ -253,7 +253,7 @@ public class FieldUtils { * @since 3.4 */ public static List getFieldsListWithAnnotation(final Class cls, final Class annotationCls) { - Validate.isTrue(annotationCls != null, "The annotation class must not be null"); + Validate.notNull(annotationCls, "The annotation class must not be null"); final List allFields = getAllFieldsList(cls); final List annotatedFields = new ArrayList<>(); for (final Field field : allFields) { @@ -294,7 +294,7 @@ public class FieldUtils { * if the field is not made accessible */ public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(field != null, "The field must not be null"); + Validate.notNull(field, "The field must not be null"); Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName()); return readField(field, (Object) null, forceAccess); } @@ -337,7 +337,7 @@ public class FieldUtils { */ public static Object readStaticField(final Class cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException { final Field field = getField(cls, fieldName, forceAccess); - Validate.isTrue(field != null, "Cannot locate field '%s' on %s", fieldName, cls); + Validate.notNull(field, "Cannot locate field '%s' on %s", fieldName, cls); // already forced access above, don't repeat it here: return readStaticField(field, false); } @@ -381,7 +381,7 @@ public class FieldUtils { */ public static Object readDeclaredStaticField(final Class cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException { final Field field = getDeclaredField(cls, fieldName, forceAccess); - Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); + Validate.notNull(field, "Cannot locate declared field %s.%s", cls.getName(), fieldName); // already forced access above, don't repeat it here: return readStaticField(field, false); } @@ -420,7 +420,7 @@ public class FieldUtils { * if the field is not made accessible */ public static Object readField(final Field field, final Object target, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(field != null, "The field must not be null"); + Validate.notNull(field, "The field must not be null"); if (forceAccess && !field.isAccessible()) { field.setAccessible(true); } else { @@ -464,7 +464,7 @@ public class FieldUtils { * if the named field is not made accessible */ public static Object readField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(target != null, "target object must not be null"); + Validate.notNull(target, "target object must not be null"); final Class cls = target.getClass(); final Field field = getField(cls, fieldName, forceAccess); Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls); @@ -507,7 +507,7 @@ public class FieldUtils { * if the field is not made accessible */ public static Object readDeclaredField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(target != null, "target object must not be null"); + Validate.notNull(target, "target object must not be null"); final Class cls = target.getClass(); final Field field = getDeclaredField(cls, fieldName, forceAccess); Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls, fieldName); @@ -548,7 +548,7 @@ public class FieldUtils { * if the field is not made accessible or is {@code final} */ public static void writeStaticField(final Field field, final Object value, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(field != null, "The field must not be null"); + Validate.notNull(field, "The field must not be null"); Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field %s.%s is not static", field.getDeclaringClass().getName(), field.getName()); writeField(field, (Object) null, value, forceAccess); @@ -595,7 +595,7 @@ public class FieldUtils { public static void writeStaticField(final Class cls, final String fieldName, final Object value, final boolean forceAccess) throws IllegalAccessException { final Field field = getField(cls, fieldName, forceAccess); - Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls); + Validate.notNull(field, "Cannot locate field %s on %s", fieldName, cls); // already forced access above, don't repeat it here: writeStaticField(field, value, false); } @@ -640,7 +640,7 @@ public class FieldUtils { public static void writeDeclaredStaticField(final Class cls, final String fieldName, final Object value, final boolean forceAccess) throws IllegalAccessException { final Field field = getDeclaredField(cls, fieldName, forceAccess); - Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); + Validate.notNull(field, "Cannot locate declared field %s.%s", cls.getName(), fieldName); // already forced access above, don't repeat it here: writeField(field, (Object) null, value, false); } @@ -682,7 +682,7 @@ public class FieldUtils { */ public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(field != null, "The field must not be null"); + Validate.notNull(field, "The field must not be null"); if (forceAccess && !field.isAccessible()) { field.setAccessible(true); } else { @@ -722,7 +722,7 @@ public class FieldUtils { */ @Deprecated public static void removeFinalModifier(final Field field, final boolean forceAccess) { - Validate.isTrue(field != null, "The field must not be null"); + Validate.notNull(field, "The field must not be null"); try { if (Modifier.isFinal(field.getModifiers())) { @@ -791,7 +791,7 @@ public class FieldUtils { */ public static void writeField(final Object target, final String fieldName, final Object value, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(target != null, "target object must not be null"); + Validate.notNull(target, "target object must not be null"); final Class cls = target.getClass(); final Field field = getField(cls, fieldName, forceAccess); Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); @@ -839,7 +839,7 @@ public class FieldUtils { */ public static void writeDeclaredField(final Object target, final String fieldName, final Object value, final boolean forceAccess) throws IllegalAccessException { - Validate.isTrue(target != null, "target object must not be null"); + Validate.notNull(target, "target object must not be null"); final Class cls = target.getClass(); final Field field = getDeclaredField(cls, fieldName, forceAccess); Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 98e1b4d10..1d76ce611 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -914,7 +914,7 @@ public class MethodUtils { final Class annotationCls, final boolean searchSupers, final boolean ignoreAccess) { - Validate.isTrue(cls != null, "The class must not be null"); + Validate.notNull(cls, "The class must not be null"); Validate.isTrue(annotationCls != null, "The annotation class must not be null"); final List> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls) : new ArrayList<>()); @@ -957,7 +957,7 @@ public class MethodUtils { public static A getAnnotation(final Method method, final Class annotationCls, final boolean searchSupers, final boolean ignoreAccess) { - Validate.isTrue(method != null, "The method must not be null"); + Validate.notNull(method, "The method must not be null"); Validate.isTrue(annotationCls != null, "The annotation class must not be null"); if (!ignoreAccess && !MemberUtils.isAccessible(method)) { return null; diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java index 9fa254981..300b7ea94 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java @@ -1786,7 +1786,7 @@ public class DateUtils { } private static void validateDateNotNull(final Date date) { - Validate.isTrue(date != null, "The date must not be null"); + Validate.notNull(date, "The date must not be null"); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java index 18e4e90e7..8d59a5522 100644 --- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java +++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java @@ -311,7 +311,7 @@ public class CharRangeTest { @Test public void testContainsNullArg() { final CharRange range = CharRange.is('a'); - final IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> range.contains(null)); + final NullPointerException e = assertThrows(NullPointerException.class, () -> range.contains(null)); assertEquals("The Range must not be null", e.getMessage()); } diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java index ae6be1c97..49b1a9300 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java @@ -200,7 +200,7 @@ public class CharUtilsTest { public void testToChar_Character() { assertEquals('A', CharUtils.toChar(CHARACTER_A)); assertEquals('B', CharUtils.toChar(CHARACTER_B)); - assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar((Character) null)); + assertThrows(NullPointerException.class, () -> CharUtils.toChar((Character) null)); } @Test @@ -214,7 +214,7 @@ public class CharUtilsTest { public void testToChar_String() { assertEquals('A', CharUtils.toChar("A")); assertEquals('B', CharUtils.toChar("BA")); - assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar((String) null)); + assertThrows(NullPointerException.class, () -> CharUtils.toChar((String) null)); assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar("")); } @@ -284,7 +284,7 @@ public class CharUtilsTest { public void testToIntValue_Character() { assertEquals(0, CharUtils.toIntValue(Character.valueOf('0'))); assertEquals(3, CharUtils.toIntValue(Character.valueOf('3'))); - assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(null)); + assertThrows(NullPointerException.class, () -> CharUtils.toIntValue(null)); assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(CHARACTER_A)); } diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java index 90e8f51b9..1e79f4571 100644 --- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java @@ -186,13 +186,13 @@ public class EnumUtilsTest { @Test public void test_generateBitVector_nullElement() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> EnumUtils.generateBitVector(Traffic.class, Arrays.asList(Traffic.RED, null))); } @Test public void test_generateBitVectors_nullElement() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> EnumUtils.generateBitVectors(Traffic.class, Arrays.asList(Traffic.RED, null))); } diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java index 698962f26..a03b4597e 100644 --- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java @@ -141,12 +141,12 @@ public class SerializationUtilsTest { @Test public void testSerializeStreamObjNull() { - assertThrows(IllegalArgumentException.class, () -> SerializationUtils.serialize(iMap, null)); + assertThrows(NullPointerException.class, () -> SerializationUtils.serialize(iMap, null)); } @Test public void testSerializeStreamNullNull() { - assertThrows(IllegalArgumentException.class, () -> SerializationUtils.serialize(null, null)); + assertThrows(NullPointerException.class, () -> SerializationUtils.serialize(null, null)); } @Test @@ -214,7 +214,7 @@ public class SerializationUtilsTest { @Test public void testDeserializeStreamNull() { - assertThrows(IllegalArgumentException.class, () -> SerializationUtils.deserialize((InputStream) null)); + assertThrows(NullPointerException.class, () -> SerializationUtils.deserialize((InputStream) null)); } @Test @@ -317,7 +317,7 @@ public class SerializationUtilsTest { @Test public void testDeserializeBytesNull() { - assertThrows(IllegalArgumentException.class, () -> SerializationUtils.deserialize((byte[]) null)); + assertThrows(NullPointerException.class, () -> SerializationUtils.deserialize((byte[]) null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java index 4e8df276e..3942ff8e7 100644 --- a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java @@ -42,42 +42,42 @@ public class ThreadUtilsTest { @Test public void testNullThreadName() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null)); } @Test public void testNullThreadGroupName() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadGroupsByName(null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroupsByName(null)); } @Test public void testNullThreadThreadGroupName1() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, "tgname")); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, "tgname")); } @Test public void testNullThreadThreadGroupName2() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName("tname", (String) null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName("tname", (String) null)); } @Test public void testNullThreadThreadGroupName3() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, (String) null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, (String) null)); } @Test public void testNullThreadThreadGroup1() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName("tname", (ThreadGroup) null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName("tname", (ThreadGroup) null)); } @Test public void testNullThreadThreadGroup2() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadById(1L, (ThreadGroup) null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadById(1L, (ThreadGroup) null)); } @Test public void testNullThreadThreadGroup3() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, (ThreadGroup) null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, (ThreadGroup) null)); } @Test @@ -87,24 +87,24 @@ public class ThreadUtilsTest { @Test public void testThreadGroupsByIdFail() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadById(Thread.currentThread().getId(), (String) null)); } @Test public void testThreadgroupsNullParent() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroups(null, true, ThreadUtils.ALWAYS_TRUE_PREDICATE)); } @Test public void testThreadgroupsNullPredicate() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadGroups(null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroups(null)); } @Test public void testThreadsNullPredicate() { - assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreads(null)); + assertThrows(NullPointerException.class, () -> ThreadUtils.findThreads(null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java index 263a50bbe..a9e62de23 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java @@ -308,12 +308,12 @@ public class DiffBuilderTest { @Test public void testNullLhs() { - assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE)); + assertThrows(NullPointerException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE)); } @Test public void testNullRhs() { - assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE)); + assertThrows(NullPointerException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java index b92b34fb0..2045f012e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java @@ -117,19 +117,19 @@ public class DiffResultTest { @Test public void testNullLhs() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> new DiffResult(null, SIMPLE_FALSE, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE)); } @Test public void testNullRhs() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> new DiffResult(SIMPLE_TRUE, null, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE)); } @Test public void testNullList() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, null, SHORT_STYLE)); } diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java index 598f8998f..d43ea021b 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java @@ -180,7 +180,7 @@ public class HashCodeBuilderTest { @Test public void testReflectionHashCodeEx3() { - assertThrows(IllegalArgumentException.class, () -> HashCodeBuilder.reflectionHashCode(13, 19, null, true)); + assertThrows(NullPointerException.class, () -> HashCodeBuilder.reflectionHashCode(13, 19, null, true)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java index 39a926b21..b85bd9a75 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java @@ -24,7 +24,7 @@ public class ReflectionToStringBuilderTest { @Test public void testConstructorWithNullObject() { - assertThrows(IllegalArgumentException.class, + assertThrows(NullPointerException.class, () -> new ReflectionToStringBuilder(null, ToStringStyle.DEFAULT_STYLE, new StringBuffer())); } diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java index 647cd2e88..4ca52bd8a 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -81,7 +81,7 @@ public class ToStringBuilderTest { @Test public void testSetDefaultEx() { - assertThrows(IllegalArgumentException.class, () -> ToStringBuilder.setDefaultStyle(null)); + assertThrows(NullPointerException.class, () -> ToStringBuilder.setDefaultStyle(null)); } @Test @@ -1278,7 +1278,7 @@ public class ToStringBuilderTest { @Test public void testReflectionNull() { - assertThrows(IllegalArgumentException.class, () -> ReflectionToStringBuilder.toString(null)); + assertThrows(NullPointerException.class, () -> ReflectionToStringBuilder.toString(null)); } /** diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java index accef5c78..61746cc27 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java @@ -39,7 +39,7 @@ public class CallableBackgroundInitializerTest { */ @Test() public void testInitNullCallable() { - assertThrows(IllegalArgumentException.class, () -> new CallableBackgroundInitializer<>(null)); + assertThrows(NullPointerException.class, () -> new CallableBackgroundInitializer<>(null)); } /** @@ -64,7 +64,7 @@ public class CallableBackgroundInitializerTest { public void testInitExecutorNullCallable() throws InterruptedException { final ExecutorService exec = Executors.newSingleThreadExecutor(); try { - assertThrows(IllegalArgumentException.class, () -> new CallableBackgroundInitializer(null, exec)); + assertThrows(NullPointerException.class, () -> new CallableBackgroundInitializer(null, exec)); } finally { exec.shutdown(); exec.awaitTermination(1, TimeUnit.SECONDS); diff --git a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java index 973f72b6c..e93005b6f 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java @@ -72,7 +72,7 @@ public class MultiBackgroundInitializerTest { */ @Test public void testAddInitializerNullName() { - assertThrows(IllegalArgumentException.class, () -> initializer.addInitializer(null, new ChildBackgroundInitializer())); + assertThrows(NullPointerException.class, () -> initializer.addInitializer(null, new ChildBackgroundInitializer())); } /** @@ -81,7 +81,7 @@ public class MultiBackgroundInitializerTest { */ @Test public void testAddInitializerNullInit() { - assertThrows(IllegalArgumentException.class, () -> initializer.addInitializer(CHILD_INIT, null)); + assertThrows(NullPointerException.class, () -> initializer.addInitializer(CHILD_INIT, null)); } /** diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java index 7a4b338c7..28650568b 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -521,7 +521,7 @@ public class ExceptionUtilsTest { out = new ByteArrayOutputStream(1024); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null)); out = new ByteArrayOutputStream(1024); @@ -545,7 +545,7 @@ public class ExceptionUtilsTest { writer = new StringWriter(1024); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null)); writer = new StringWriter(1024); diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java index 10daae01c..ff953cfba 100644 --- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java +++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java @@ -324,7 +324,7 @@ public class FractionTest { @Test public void testFactory_String() { - assertThrows(IllegalArgumentException.class, () -> Fraction.getFraction(null)); + assertThrows(NullPointerException.class, () -> Fraction.getFraction(null)); } @@ -741,7 +741,7 @@ public class FractionTest { assertEquals(13*13*17*2*2, fr.getDenominator()); assertEquals(-17 - 2*13*2, fr.getNumerator()); - assertThrows(IllegalArgumentException.class, () -> fr.add(null)); + assertThrows(NullPointerException.class, () -> fr.add(null)); // if this fraction is added naively, it will overflow. // check that it doesn't. @@ -836,7 +836,7 @@ public class FractionTest { assertSame(f2, f); final Fraction fr = f; - assertThrows(IllegalArgumentException.class, () -> fr.subtract(null)); + assertThrows(NullPointerException.class, () -> fr.subtract(null)); // if this fraction is subtracted naively, it will overflow. // check that it doesn't. @@ -934,7 +934,7 @@ public class FractionTest { assertEquals(1, f.getDenominator()); final Fraction fr = f; - assertThrows(IllegalArgumentException.class, () -> fr.multiplyBy(null)); + assertThrows(NullPointerException.class, () -> fr.multiplyBy(null)); final Fraction fr1 = Fraction.getFraction(1, Integer.MAX_VALUE); assertThrows(ArithmeticException.class, () -> fr1.multiplyBy(fr1)); @@ -979,7 +979,7 @@ public class FractionTest { assertEquals(Integer.MIN_VALUE, fr.getNumerator()); assertEquals(1, fr.getDenominator()); - assertThrows(IllegalArgumentException.class, () -> fr.divideBy(null)); + assertThrows(NullPointerException.class, () -> fr.divideBy(null)); final Fraction smallest = Fraction.getFraction(1, Integer.MAX_VALUE); assertThrows(ArithmeticException.class, () -> smallest.divideBy(smallest.invert())); // Should overflow diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java index 2caf60be2..39fe5cd6f 100644 --- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java @@ -56,7 +56,7 @@ public class IEEE754rUtilsTest { @Test public void testEnforceExceptions() { assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> IEEE754rUtils.min( (float[]) null), "IllegalArgumentException expected for null input"); @@ -66,7 +66,7 @@ public class IEEE754rUtilsTest { "IllegalArgumentException expected for empty input"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> IEEE754rUtils.max( (float[]) null), "IllegalArgumentException expected for null input"); @@ -76,7 +76,7 @@ public class IEEE754rUtilsTest { "IllegalArgumentException expected for empty input"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> IEEE754rUtils.min( (double[]) null), "IllegalArgumentException expected for null input"); @@ -86,7 +86,7 @@ public class IEEE754rUtilsTest { "IllegalArgumentException expected for empty input"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> IEEE754rUtils.max( (double[]) null), "IllegalArgumentException expected for null input"); diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java index 5e5c554e8..3e32c9051 100644 --- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java @@ -686,7 +686,7 @@ public class NumberUtilsTest { // ---------------------------------------------------------------------- @Test public void testMinLong_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((long[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.min((long[]) null)); } @Test @@ -705,7 +705,7 @@ public class NumberUtilsTest { @Test public void testMinInt_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((int[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.min((int[]) null)); } @Test @@ -724,7 +724,7 @@ public class NumberUtilsTest { @Test public void testMinShort_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((short[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.min((short[]) null)); } @Test @@ -743,7 +743,7 @@ public class NumberUtilsTest { @Test public void testMinByte_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((byte[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.min((byte[]) null)); } @Test @@ -762,7 +762,7 @@ public class NumberUtilsTest { @Test public void testMinDouble_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((double[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.min((double[]) null)); } @Test @@ -781,7 +781,7 @@ public class NumberUtilsTest { @Test public void testMinFloat_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((float[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.min((float[]) null)); } @Test @@ -800,7 +800,7 @@ public class NumberUtilsTest { @Test public void testMaxLong_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((long[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.max((long[]) null)); } @Test @@ -819,7 +819,7 @@ public class NumberUtilsTest { @Test public void testMaxInt_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((int[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.max((int[]) null)); } @Test @@ -838,7 +838,7 @@ public class NumberUtilsTest { @Test public void testMaxShort_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((short[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.max((short[]) null)); } @Test @@ -857,7 +857,7 @@ public class NumberUtilsTest { @Test public void testMaxByte_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((byte[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.max((byte[]) null)); } @Test @@ -876,7 +876,7 @@ public class NumberUtilsTest { @Test public void testMaxDouble_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((double[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.max((double[]) null)); } @Test @@ -888,7 +888,7 @@ public class NumberUtilsTest { public void testMaxDouble() { final double[] d = null; assertThrows( - IllegalArgumentException.class, () -> NumberUtils.max(d), "No exception was thrown for null input."); + NullPointerException.class, () -> NumberUtils.max(d), "No exception was thrown for null input."); assertThrows( IllegalArgumentException.class, @@ -904,7 +904,7 @@ public class NumberUtilsTest { @Test public void testMaxFloat_nullArray() { - assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((float[]) null)); + assertThrows(NullPointerException.class, () -> NumberUtils.max((float[]) null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java index 9db1f8070..20ae2acad 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java @@ -106,7 +106,7 @@ public class FieldUtilsTest { @Test public void testGetFieldIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getField(null, "none")); + assertThrows(NullPointerException.class, () -> FieldUtils.getField(null, "none")); } @Test @@ -145,7 +145,7 @@ public class FieldUtilsTest { @Test public void testGetFieldForceAccessIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getField(null, "none", true)); + assertThrows(NullPointerException.class, () -> FieldUtils.getField(null, "none", true)); } @Test @@ -214,17 +214,17 @@ public class FieldUtilsTest { @Test public void testGetFieldsWithAnnotationIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(FieldUtilsTest.class, null)); + assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(FieldUtilsTest.class, null)); } @Test public void testGetFieldsWithAnnotationIllegalArgumentException2() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(null, Annotated.class)); + assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(null, Annotated.class)); } @Test public void testGetFieldsWithAnnotationIllegalArgumentException3() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(null, null)); + assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(null, null)); } @Test @@ -242,17 +242,17 @@ public class FieldUtilsTest { @Test public void testGetFieldsListWithAnnotationIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, null)); + assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, null)); } @Test public void testGetFieldsListWithAnnotationIllegalArgumentException2() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, Annotated.class)); + assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, Annotated.class)); } @Test public void testGetFieldsListWithAnnotationIllegalArgumentException3() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, null)); + assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, null)); } @Test @@ -276,7 +276,7 @@ public class FieldUtilsTest { @Test public void testGetDeclaredFieldAccessIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getDeclaredField(null, "none")); + assertThrows(NullPointerException.class, () -> FieldUtils.getDeclaredField(null, "none")); } @Test @@ -315,7 +315,7 @@ public class FieldUtilsTest { @Test public void testGetDeclaredFieldForceAccessIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.getDeclaredField(null, "none", true)); + assertThrows(NullPointerException.class, () -> FieldUtils.getDeclaredField(null, "none", true)); } @Test @@ -340,7 +340,7 @@ public class FieldUtilsTest { @Test public void testReadStaticFieldIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.readStaticField(null)); + assertThrows(NullPointerException.class, () -> FieldUtils.readStaticField(null)); } @Test @@ -359,7 +359,7 @@ public class FieldUtilsTest { @Test public void testReadStaticFieldForceAccessIllegalArgumentException1() { - assertThrows(IllegalArgumentException.class, () -> FieldUtils.readStaticField(null, true)); + assertThrows(NullPointerException.class, () -> FieldUtils.readStaticField(null, true)); } @Test @@ -377,7 +377,7 @@ public class FieldUtilsTest { assertEquals(Foo.VALUE, FieldUtils.readStaticField(PublicChild.class, "VALUE")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readStaticField(null, "none"), "null class should cause an IllegalArgumentException"); @@ -397,7 +397,7 @@ public class FieldUtilsTest { "blank field name should cause an IllegalArgumentException"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readStaticField(Foo.class, "does_not_exist"), "a field that doesn't exist should cause an IllegalArgumentException"); @@ -415,7 +415,7 @@ public class FieldUtilsTest { assertEquals("child", FieldUtils.readStaticField(PublicChild.class, "VALUE", true)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readStaticField(null, "none", true), "null class should cause an IllegalArgumentException"); @@ -435,7 +435,7 @@ public class FieldUtilsTest { "blank field name should cause an IllegalArgumentException"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readStaticField(Foo.class, "does_not_exist", true), "a field that doesn't exist should cause an IllegalArgumentException"); @@ -449,12 +449,12 @@ public class FieldUtilsTest { public void testReadDeclaredNamedStaticField() throws Exception { assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE")); assertThrows( - IllegalArgumentException.class, () -> FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE")); + NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE")); } @@ -463,10 +463,10 @@ public class FieldUtilsTest { assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE", true)); assertEquals("child", FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE", true)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE", true)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE", true)); } @@ -490,7 +490,7 @@ public class FieldUtilsTest { assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readField(null, publicChild), "a null field should cause an IllegalArgumentException"); } @@ -519,7 +519,7 @@ public class FieldUtilsTest { assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild, true)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readField(null, publicChild, true), "a null field should cause an IllegalArgumentException"); } @@ -546,7 +546,7 @@ public class FieldUtilsTest { "a blank field name should cause an IllegalArgumentException"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readField((Object) null, "none"), "a null target should cause an IllegalArgumentException"); @@ -593,7 +593,7 @@ public class FieldUtilsTest { "a blank field name should cause an IllegalArgumentException"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readField((Object) null, "none", true), "a null target should cause an IllegalArgumentException"); } @@ -616,7 +616,7 @@ public class FieldUtilsTest { "a blank field name should cause an IllegalArgumentException"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readDeclaredField(null, "none"), "a null target should cause an IllegalArgumentException"); @@ -652,7 +652,7 @@ public class FieldUtilsTest { "a blank field name should cause an IllegalArgumentException"); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.readDeclaredField(null, "none", true), "a null target should cause an IllegalArgumentException"); @@ -731,25 +731,25 @@ public class FieldUtilsTest { FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePublic", "new"); assertEquals("new", StaticContainer.mutablePublic); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutableProtected", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePackage", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePrivate", "new")); assertThrows( IllegalAccessException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new")); } @@ -782,25 +782,25 @@ public class FieldUtilsTest { FieldUtils.writeStaticField(StaticContainer.class, "mutablePublic", "new"); assertEquals("new", StaticContainer.mutablePublic); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutableProtected", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePackage", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePrivate", "new")); assertThrows( IllegalAccessException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new")); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new")); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java index ab40b22df..9966efe21 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java @@ -868,12 +868,12 @@ public class MethodUtilsTest { @Test public void testGetMethodsWithAnnotationIllegalArgumentException2() { - assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsWithAnnotation(null, Annotated.class)); + assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsWithAnnotation(null, Annotated.class)); } @Test public void testGetMethodsWithAnnotationIllegalArgumentException3() { - assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsWithAnnotation(null, null)); + assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsWithAnnotation(null, null)); } @Test @@ -896,12 +896,12 @@ public class MethodUtilsTest { @Test public void testGetMethodsListWithAnnotationIllegalArgumentException2() { - assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, Annotated.class)); + assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, Annotated.class)); } @Test public void testGetMethodsListWithAnnotationIllegalArgumentException3() { - assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, null)); + assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, null)); } @Test @@ -912,12 +912,12 @@ public class MethodUtilsTest { @Test public void testGetAnnotationIllegalArgumentException2() { - assertThrows(IllegalArgumentException.class, () -> MethodUtils.getAnnotation(null, Annotated.class, true, true)); + assertThrows(NullPointerException.class, () -> MethodUtils.getAnnotation(null, Annotated.class, true, true)); } @Test public void testGetAnnotationIllegalArgumentException3() { - assertThrows(IllegalArgumentException.class, () -> MethodUtils.getAnnotation(null, null, true, true)); + assertThrows(NullPointerException.class, () -> MethodUtils.getAnnotation(null, null, true, true)); } private void expectMatchingAccessibleMethodParameterTypes(final Class cls, diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java index 5f65d0e0b..be6f23ba1 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java @@ -49,23 +49,23 @@ public class DateUtilsFragmentTest { @Test public void testNullDate() { assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> DateUtils.getFragmentInMilliseconds((Date) null, Calendar.MILLISECOND)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> DateUtils.getFragmentInSeconds((Date) null, Calendar.MILLISECOND)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> DateUtils.getFragmentInMinutes((Date) null, Calendar.MILLISECOND)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> DateUtils.getFragmentInHours((Date) null, Calendar.MILLISECOND)); assertThrows( - IllegalArgumentException.class, + NullPointerException.class, () -> DateUtils.getFragmentInDays((Date) null, Calendar.MILLISECOND)); } diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java index 64cfde87d..14dbf89c2 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -830,7 +830,7 @@ public class DateUtilsTest { DateUtils.round((Object) dateAmPm4, Calendar.AM_PM), "round ampm-4 failed"); - assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Date) null, Calendar.SECOND)); + assertThrows(NullPointerException.class, () -> DateUtils.round((Date) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Calendar) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Object) null, Calendar.SECOND)); assertThrows(ClassCastException.class, () -> DateUtils.round("", Calendar.SECOND)); @@ -1111,7 +1111,7 @@ public class DateUtilsTest { DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM), "truncate ampm-4 failed"); - assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Date) null, Calendar.SECOND)); + assertThrows(NullPointerException.class, () -> DateUtils.truncate((Date) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Calendar) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Object) null, Calendar.SECOND)); assertThrows(ClassCastException.class, () -> DateUtils.truncate("", Calendar.SECOND)); @@ -1389,7 +1389,7 @@ public class DateUtilsTest { DateUtils.ceiling((Object) calAmPm4, Calendar.AM_PM), "ceiling ampm-4 failed"); - assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Date) null, Calendar.SECOND)); + assertThrows(NullPointerException.class, () -> DateUtils.ceiling((Date) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Calendar) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Object) null, Calendar.SECOND)); assertThrows(ClassCastException.class, () -> DateUtils.ceiling("", Calendar.SECOND)); @@ -1475,7 +1475,7 @@ public class DateUtilsTest { public void testIteratorEx() { assertThrows(IllegalArgumentException.class, () -> DateUtils.iterator(Calendar.getInstance(), -9999)); assertThrows - (IllegalArgumentException.class, () -> DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER)); + (NullPointerException.class, () -> DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER)); assertThrows (IllegalArgumentException.class, () -> DateUtils.iterator((Calendar) null, DateUtils.RANGE_WEEK_CENTER)); assertThrows