Skip to content

Commit

Permalink
Cleanup usage of deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
scordio committed May 12, 2024
1 parent ded8fd8 commit 30230bb
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 91 deletions.
51 changes: 25 additions & 26 deletions assertj-core/src/main/java/org/assertj/core/api/Assertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1496,13 +1496,13 @@ public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(Class
* // fails as the thrown instance is not an Exception
* catchException(() -&gt; {throw new Throwable("boom!");});</code></pre>
*
* @param shouldRaiseException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static Exception catchException(ThrowingCallable shouldRaiseException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseException, Exception.class);
public static Exception catchException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(Exception.class, throwingCallable);
}

/**
Expand All @@ -1523,13 +1523,13 @@ public static Exception catchException(ThrowingCallable shouldRaiseException) {
* // fails as the thrown instance is not a RuntimeException
* catchRuntimeException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseRuntimeException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static RuntimeException catchRuntimeException(ThrowingCallable shouldRaiseRuntimeException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseRuntimeException, RuntimeException.class);
public static RuntimeException catchRuntimeException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(RuntimeException.class, throwingCallable);
}

/**
Expand All @@ -1550,13 +1550,13 @@ public static RuntimeException catchRuntimeException(ThrowingCallable shouldRais
* // fails as the thrown instance is not a NullPointerException
* catchNullPointerException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseNullPointerException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static NullPointerException catchNullPointerException(ThrowingCallable shouldRaiseNullPointerException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseNullPointerException, NullPointerException.class);
public static NullPointerException catchNullPointerException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(NullPointerException.class, throwingCallable);
}

/**
Expand All @@ -1577,13 +1577,13 @@ public static NullPointerException catchNullPointerException(ThrowingCallable sh
* // fails as the thrown instance is not an IllegalArgumentException
* catchIllegalArgumentException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIllegalArgumentException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IllegalArgumentException catchIllegalArgumentException(ThrowingCallable shouldRaiseIllegalArgumentException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIllegalArgumentException, IllegalArgumentException.class);
public static IllegalArgumentException catchIllegalArgumentException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IllegalArgumentException.class, throwingCallable);
}

/**
Expand All @@ -1604,13 +1604,13 @@ public static IllegalArgumentException catchIllegalArgumentException(ThrowingCal
* // fails as the thrown instance is not an IOException
* catchIOException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIOException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IOException catchIOException(ThrowingCallable shouldRaiseIOException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIOException, IOException.class);
public static IOException catchIOException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IOException.class, throwingCallable);
}

/**
Expand All @@ -1631,14 +1631,13 @@ public static IOException catchIOException(ThrowingCallable shouldRaiseIOExcepti
* // fails as the thrown instance is not an IOException
* catchReflectiveOperationException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseReflectiveOperationException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static ReflectiveOperationException catchReflectiveOperationException(ThrowingCallable shouldRaiseReflectiveOperationException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseReflectiveOperationException,
ReflectiveOperationException.class);
public static ReflectiveOperationException catchReflectiveOperationException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(ReflectiveOperationException.class, throwingCallable);
}

/**
Expand All @@ -1659,13 +1658,13 @@ public static ReflectiveOperationException catchReflectiveOperationException(Thr
* // fails as the thrown instance is not an IOException
* catchIllegalStateException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIllegalStateException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IllegalStateException catchIllegalStateException(ThrowingCallable shouldRaiseIllegalStateException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIllegalStateException, IllegalStateException.class);
public static IllegalStateException catchIllegalStateException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IllegalStateException.class, throwingCallable);
}

/**
Expand All @@ -1686,18 +1685,18 @@ public static IllegalStateException catchIllegalStateException(ThrowingCallable
* // fails as the thrown instance is not an IOException
* catchIndexOutOfBoundsException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIndexOutOfBoundException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IndexOutOfBoundsException catchIndexOutOfBoundsException(ThrowingCallable shouldRaiseIndexOutOfBoundException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIndexOutOfBoundException, IndexOutOfBoundsException.class);
public static IndexOutOfBoundsException catchIndexOutOfBoundsException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IndexOutOfBoundsException.class, throwingCallable);
}

/**
* Entry point to check that an exception of type T is thrown by a given {@code throwingCallable}
* which allows to chain assertions on the thrown exception.
* which allows chaining assertions on the thrown exception.
* <p>
* Example:
* <pre><code class='java'> assertThatExceptionOfType(IOException.class)
Expand Down
67 changes: 33 additions & 34 deletions assertj-core/src/main/java/org/assertj/core/api/BDDAssertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1883,14 +1883,14 @@ public static <ELEMENT> SpliteratorAssert<ELEMENT> then(Spliterator<ELEMENT> act
* .hasMessageContaining("boom");
* } </code></pre>
*
* @param shouldRaiseThrowable The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowableOfType(Class, ThrowingCallable)
*
* @since 3.20.0
*/
public static Throwable catchThrowable(ThrowingCallable shouldRaiseThrowable) {
return AssertionsForClassTypes.catchThrowable(shouldRaiseThrowable);
public static Throwable catchThrowable(ThrowingCallable throwingCallable) {
return AssertionsForClassTypes.catchThrowable(throwingCallable);
}

/**
Expand Down Expand Up @@ -1925,17 +1925,17 @@ public static Throwable catchThrowable(ThrowingCallable shouldRaiseThrowable) {
* catchThrowableOfType(() -&gt; { throw new TextException("boom!", 1, 5); }, RuntimeException.class);</code></pre>
*
* @param <THROWABLE> the {@link Throwable} type.
* @param shouldRaiseThrowable The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @param type The type of exception that the code is expected to raise.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.20.0
* @deprecated use {@link #catchThrowableOfType(Class, ThrowingCallable)} instead.
*/
@Deprecated
public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(ThrowingCallable shouldRaiseThrowable,
public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(ThrowingCallable throwingCallable,
Class<THROWABLE> type) {
return catchThrowableOfType(type, shouldRaiseThrowable);
return catchThrowableOfType(type, throwingCallable);
}

/**
Expand Down Expand Up @@ -1970,15 +1970,15 @@ public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(Throw
* catchThrowableOfType(RuntimeException.class, () -&gt; { throw new TextException("boom!", 1, 5); });</code></pre>
*
* @param <THROWABLE> the {@link Throwable} type.
* @param shouldRaiseThrowable The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @param type The type of exception that the code is expected to raise.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.26.0
*/
public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(Class<THROWABLE> type,
ThrowingCallable shouldRaiseThrowable) {
return ThrowableAssert.catchThrowableOfType(type, shouldRaiseThrowable);
ThrowingCallable throwingCallable) {
return ThrowableAssert.catchThrowableOfType(type, throwingCallable);
}

/**
Expand All @@ -1999,13 +1999,13 @@ public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(Class
* // fails as the thrown instance is not an Exception
* catchException(() -&gt; {throw new Throwable("boom!");});</code></pre>
*
* @param shouldRaiseException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static Exception catchException(ThrowingCallable shouldRaiseException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseException, Exception.class);
public static Exception catchException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(Exception.class, throwingCallable);
}

/**
Expand All @@ -2026,13 +2026,13 @@ public static Exception catchException(ThrowingCallable shouldRaiseException) {
* // fails as the thrown instance is not a RuntimeException
* catchRuntimeException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseRuntimeException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static RuntimeException catchRuntimeException(ThrowingCallable shouldRaiseRuntimeException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseRuntimeException, RuntimeException.class);
public static RuntimeException catchRuntimeException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(RuntimeException.class, throwingCallable);
}

/**
Expand All @@ -2053,13 +2053,13 @@ public static RuntimeException catchRuntimeException(ThrowingCallable shouldRais
* // fails as the thrown instance is not a NullPointerException
* catchNullPointerException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseNullPointerException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static NullPointerException catchNullPointerException(ThrowingCallable shouldRaiseNullPointerException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseNullPointerException, NullPointerException.class);
public static NullPointerException catchNullPointerException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(NullPointerException.class, throwingCallable);
}

/**
Expand All @@ -2080,13 +2080,13 @@ public static NullPointerException catchNullPointerException(ThrowingCallable sh
* // fails as the thrown instance is not an IllegalArgumentException
* catchIllegalArgumentException(() -&gt; {throw new Exception("boom!");});
*
* @param shouldRaiseIllegalArgumentException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IllegalArgumentException catchIllegalArgumentException(ThrowingCallable shouldRaiseIllegalArgumentException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIllegalArgumentException, IllegalArgumentException.class);
public static IllegalArgumentException catchIllegalArgumentException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IllegalArgumentException.class, throwingCallable);
}

/**
Expand All @@ -2107,13 +2107,13 @@ public static IllegalArgumentException catchIllegalArgumentException(ThrowingCal
* // fails as the thrown instance is not an IOException
* catchIOException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIOException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IOException catchIOException(ThrowingCallable shouldRaiseIOException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIOException, IOException.class);
public static IOException catchIOException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IOException.class, throwingCallable);
}

/**
Expand All @@ -2134,14 +2134,13 @@ public static IOException catchIOException(ThrowingCallable shouldRaiseIOExcepti
* // fails as the thrown instance is not an IOException
* catchReflectiveOperationException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseReflectiveOperationException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static ReflectiveOperationException catchReflectiveOperationException(ThrowingCallable shouldRaiseReflectiveOperationException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseReflectiveOperationException,
ReflectiveOperationException.class);
public static ReflectiveOperationException catchReflectiveOperationException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(ReflectiveOperationException.class, throwingCallable);
}

/**
Expand All @@ -2162,13 +2161,13 @@ public static ReflectiveOperationException catchReflectiveOperationException(Thr
* // fails as the thrown instance is not an IOException
* catchIllegalStateException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIllegalStateException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IllegalStateException catchIllegalStateException(ThrowingCallable shouldRaiseIllegalStateException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIllegalStateException, IllegalStateException.class);
public static IllegalStateException catchIllegalStateException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IllegalStateException.class, throwingCallable);
}

/**
Expand All @@ -2189,13 +2188,13 @@ public static IllegalStateException catchIllegalStateException(ThrowingCallable
* // fails as the thrown instance is not an IOException
* catchIndexOutOfBoundsException(() -&gt; {throw new Exception("boom!");});</code></pre>
*
* @param shouldRaiseIndexOutOfBoundException The lambda with the code that should raise the exception.
* @param throwingCallable The lambda with the code that should raise the exception.
* @return The captured exception or <code>null</code> if none was raised by the callable.
* @see #catchThrowable(ThrowingCallable)
* @since 3.22.0
*/
public static IndexOutOfBoundsException catchIndexOutOfBoundsException(ThrowingCallable shouldRaiseIndexOutOfBoundException) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseIndexOutOfBoundException, IndexOutOfBoundsException.class);
public static IndexOutOfBoundsException catchIndexOutOfBoundsException(ThrowingCallable throwingCallable) {
return catchThrowableOfType(IndexOutOfBoundsException.class, throwingCallable);
}

/**
Expand Down

0 comments on commit 30230bb

Please sign in to comment.