private ShouldHaveRootCauseExactlyInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { super( "%nExpecting a throwable with root cause being exactly an instance of:%n <%s>%nbut was an instance of:%n <%s>", expectedCauseType, Throwables.getRootCause(actual)); }
private ShouldHaveRootCauseInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { super("%nExpecting a throwable with root cause being an instance of:%n <%s>%nbut was an instance of:%n <%s>", expectedCauseType, Throwables.getRootCause(actual)); }
private ShouldHaveRootCauseExactlyInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { super( "%nExpecting a throwable with root cause being exactly an instance of:%n <%s>%nbut was an instance of:%n <%s>", expectedCauseType, Throwables.getRootCause(actual)); }
private ShouldHaveRootCauseInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { super("%nExpecting a throwable with root cause being an instance of:%n <%s>%nbut was an instance of:%n <%s>", expectedCauseType, Throwables.getRootCause(actual)); }
/** * Creates a new <code>{@link BasicErrorMessageFactory}</code>. * * @param actual the actual value in the failed assertion. * @param expectedCauseType the expected cause type. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveRootCauseInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { return Throwables.getRootCause(actual) == null ? new ShouldHaveRootCauseInstance(expectedCauseType) : new ShouldHaveRootCauseInstance(actual, expectedCauseType); }
/** * Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>. * * @param actual the actual value in the failed assertion. * @param expectedCauseType the expected cause instance. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveRootCauseExactlyInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { return Throwables.getRootCause(actual) == null ? new ShouldHaveRootCauseExactlyInstance(expectedCauseType) : new ShouldHaveRootCauseExactlyInstance(actual, expectedCauseType); }
/** * Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>. * * @param actual the actual value in the failed assertion. * @param expectedCauseType the expected cause instance. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveRootCauseExactlyInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { return Throwables.getRootCause(actual) == null ? new ShouldHaveRootCauseExactlyInstance(expectedCauseType) : new ShouldHaveRootCauseExactlyInstance(actual, expectedCauseType); }
/** * Creates a new <code>{@link BasicErrorMessageFactory}</code>. * * @param actual the actual value in the failed assertion. * @param expectedCauseType the expected cause type. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveRootCauseInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { return Throwables.getRootCause(actual) == null ? new ShouldHaveRootCauseInstance(expectedCauseType) : new ShouldHaveRootCauseInstance(actual, expectedCauseType); }
/** * Assert that the root cause of actual {@code Throwable} is <b>exactly</b> an instance of the given type. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param type the expected cause type. * @throws NullPointerException if given type is {@code null}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has no cause. * @throws AssertionError if the root cause of the actual {@code Throwable} is not <b>exactly</b> an instance of the * given type. */ public void assertHasRootCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) { assertNotNull(info, actual); checkTypeIsNotNull(type); Throwable rootCause = getRootCause(actual); if (rootCause != null && type.equals(rootCause.getClass())) return; throw failures.failure(info, shouldHaveRootCauseExactlyInstance(actual, type)); }
/** * Assert that the root cause of actual {@code Throwable} is an instance of the given type. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param type the expected cause type. * @throws NullPointerException if given type is {@code null}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has no cause. * @throws AssertionError if the cause of the actual {@code Throwable} is not an instance of the given type. */ public void assertHasRootCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) { assertNotNull(info, actual); checkTypeIsNotNull(type); if (type.isInstance(getRootCause(actual))) return; throw failures.failure(info, shouldHaveRootCauseInstance(actual, type)); }
/** * Assert that the root cause of actual {@code Throwable} is <b>exactly</b> an instance of the given type. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param type the expected cause type. * @throws NullPointerException if given type is {@code null}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has no cause. * @throws AssertionError if the root cause of the actual {@code Throwable} is not <b>exactly</b> an instance of the * given type. */ public void assertHasRootCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) { assertNotNull(info, actual); checkTypeIsNotNull(type); Throwable rootCause = getRootCause(actual); if (rootCause != null && type.equals(rootCause.getClass())) return; throw failures.failure(info, shouldHaveRootCauseExactlyInstance(actual, type)); }
/** * Assert that the root cause of actual {@code Throwable} is an instance of the given type. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param type the expected cause type. * @throws NullPointerException if given type is {@code null}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has no cause. * @throws AssertionError if the cause of the actual {@code Throwable} is not an instance of the given type. */ public void assertHasRootCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) { assertNotNull(info, actual); checkTypeIsNotNull(type); if (type.isInstance(getRootCause(actual))) return; throw failures.failure(info, shouldHaveRootCauseInstance(actual, type)); }
/** * Asserts that the actual {@code Throwable} has a root cause similar to the given one. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param expectedRootCause the expected root cause. */ public void assertHasRootCause(AssertionInfo info, Throwable actual, Throwable expectedRootCause) { assertNotNull(info, actual); Throwable actualRootCause = getRootCause(actual); if (actualRootCause == expectedRootCause) return; if (null == expectedRootCause) { assertHasNoCause(info, actual); return; } if (actualRootCause == null) throw failures.failure(info, shouldHaveRootCause(null, expectedRootCause)); if (!compareThrowable(actualRootCause, expectedRootCause)) throw failures.failure(info, shouldHaveRootCause(actualRootCause, expectedRootCause)); }
private ShouldHaveRootCauseExactlyInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { super( "%nExpecting a throwable with root cause being exactly an instance of:%n <%s>%nbut was an instance of:%n <%s>", expectedCauseType, Throwables.getRootCause(actual)); }
private ShouldHaveRootCauseInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { super("%nExpecting a throwable with root cause being an instance of:%n <%s>%nbut was an instance of:%n <%s>", expectedCauseType, Throwables.getRootCause(actual)); }
/** * Creates a new </code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>. * * @param actual the actual value in the failed assertion. * @param expectedCauseType the expected cause instance. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveRootCauseExactlyInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { return Throwables.getRootCause(actual) == null ? new ShouldHaveRootCauseExactlyInstance(expectedCauseType) : new ShouldHaveRootCauseExactlyInstance(actual, expectedCauseType); }
/** * Creates a new </code>{@link BasicErrorMessageFactory}</code>. * * @param actual the actual value in the failed assertion. * @param expectedCauseType the expected cause type. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveRootCauseInstance(Throwable actual, Class<? extends Throwable> expectedCauseType) { return Throwables.getRootCause(actual) == null ? new ShouldHaveRootCauseInstance(expectedCauseType) : new ShouldHaveRootCauseInstance(actual, expectedCauseType); }
/** * Assert that the root cause of actual {@code Throwable} is <b>exactly</b> an instance of the given type. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param type the expected cause type. * @throws NullPointerException if given type is {@code null}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has no cause. * @throws AssertionError if the root cause of the actual {@code Throwable} is not <b>exactly</b> an instance of the * given type. */ public void assertHasRootCauseExactlyInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) { assertNotNull(info, actual); checkTypeIsNotNull(type); Throwable rootCause = getRootCause(actual); if (rootCause != null && type.equals(rootCause.getClass())) return; throw failures.failure(info, shouldHaveRootCauseExactlyInstance(actual, type)); }
/** * Assert that the root cause of actual {@code Throwable} is an instance of the given type. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param type the expected cause type. * @throws NullPointerException if given type is {@code null}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has no cause. * @throws AssertionError if the cause of the actual {@code Throwable} is not an instance of the given type. */ public void assertHasRootCauseInstanceOf(AssertionInfo info, Throwable actual, Class<? extends Throwable> type) { assertNotNull(info, actual); checkTypeIsNotNull(type); if (type.isInstance(getRootCause(actual))) return; throw failures.failure(info, shouldHaveRootCauseInstance(actual, type)); }