/** * Adds {@code "(expected exception)"} to the log message and lower its logging level to * {@link Level#DEBUG} if the exception occurred from the {@code shouldRaiseThrowable} matches * {@code throwable} and contains {@code message}. */ public static AbstractThrowableAssert<?, ? extends Throwable> assertThatThrownByWithExpectedException( Class<?> throwable, String message, ThrowingCallable shouldRaiseThrowable) throws Exception { requireNonNull(throwable, "throwable"); requireNonNull(message, "message"); requireNonNull(shouldRaiseThrowable, "shouldRaiseThrowable"); exceptionAndMessage.put(throwable.getName(), message); try { return assertThatThrownBy(shouldRaiseThrowable); } finally { exceptionAndMessage.remove(throwable.getName()); } }
/** Asserts that the given elements in the resources directory are transformed as expected. */ public StepHarness testException(String resourceBefore, Consumer<AbstractThrowableAssert<?, ? extends Throwable>> exceptionAssertion) throws Exception { String before = ResourceHarness.getTestResource(resourceBefore); try { formatter.apply(before); Assert.fail(); } catch (Throwable t) { AbstractThrowableAssert<?, ? extends Throwable> abstractAssert = Assertions.assertThat(t); exceptionAssertion.accept(abstractAssert); } return this; }
/** * Delegate call to {@link org.assertj.core.api.Assertions#assertThat(Throwable)} */ default AbstractThrowableAssert<?, ? extends Throwable> then(Throwable actual) { fluentBdd().verification.recordThen(this); return DELEGATE.assertThat(actual); }
/** * Delegate call to {@link org.assertj.core.api.Assertions#assertThat(Throwable)} */ default AbstractThrowableAssert<?, ? extends Throwable> and(Throwable actual) { fluentBdd().verification.recordThen(this); return DELEGATE.assertThat(actual); }
/** * Delegate call to {@link org.assertj.core.api.Assertions#assertThatThrownBy(ThrowingCallable)} */ default AbstractThrowableAssert<?, ? extends Throwable> thenThrownBy(ThrowingCallable shouldRaiseThrowable) { fluentBdd().verification.recordThen(this); return DELEGATE.assertThatThrownBy(shouldRaiseThrowable); }
/** * Delegate call to {@link org.assertj.core.api.Assertions#assertThatThrownBy(ThrowingCallable)} */ default AbstractThrowableAssert<?, ? extends Throwable> andThrownBy(ThrowingCallable shouldRaiseThrowable) { fluentBdd().verification.recordThen(this); return DELEGATE.assertThatThrownBy(shouldRaiseThrowable); }
private AbstractThrowableAssert<?, ?> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) { return org.assertj.core.api.Assertions.assertThatThrownBy(shouldRaiseThrowable) .isInstanceOf(AssertionError.class); }
/** * Delegate call to public static org.assertj.core.api.AbstractThrowableAssert<?, ? extends java.lang.Throwable> org.assertj.core.api.Assertions.assertThat(java.lang.Throwable) * {@link org.assertj.core.api.Assertions#assertThat(java.lang.Throwable)} */ default AbstractThrowableAssert<?, ? extends Throwable> assertThat(Throwable actual) { return Assertions.assertThat(actual); }
/** * Delegate call to public static org.assertj.core.api.AbstractThrowableAssert<?, ? extends java.lang.Throwable> org.assertj.core.api.Assertions.assertThatCode(org.assertj.core.api.ThrowableAssert$ThrowingCallable) * {@link org.assertj.core.api.Assertions#assertThatCode(org.assertj.core.api.ThrowableAssert$ThrowingCallable)} */ default AbstractThrowableAssert<?, ? extends Throwable> assertThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable) { return Assertions.assertThatCode(shouldRaiseOrNotThrowable); }
/** * Delegate call to public static org.assertj.core.api.AbstractThrowableAssert<?, ? extends java.lang.Throwable> org.assertj.core.api.Assertions.assertThatThrownBy(org.assertj.core.api.ThrowableAssert$ThrowingCallable) * {@link org.assertj.core.api.Assertions#assertThatThrownBy(org.assertj.core.api.ThrowableAssert$ThrowingCallable)} */ default AbstractThrowableAssert<?, ? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) { return Assertions.assertThatThrownBy(shouldRaiseThrowable); }
/** * Delegate call to public static org.assertj.core.api.AbstractThrowableAssert<?, ? extends java.lang.Throwable> org.assertj.core.api.Assertions.assertThatThrownBy(org.assertj.core.api.ThrowableAssert$ThrowingCallable,java.lang.String,java.lang.Object...) * {@link org.assertj.core.api.Assertions#assertThatThrownBy(org.assertj.core.api.ThrowableAssert$ThrowingCallable,java.lang.String,java.lang.Object[])} */ default AbstractThrowableAssert<?, ? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable, String description, Object... args) { return Assertions.assertThatThrownBy(shouldRaiseThrowable, description, args); }