/** * Creates a <code>{@link AssertionError}</code> following this pattern: * <ol> * <li>creates a <code>{@link AssertionError}</code> using <code>{@link AssertionInfo#overridingErrorMessage()}</code> * as the error message if such value is not {@code null}, or</li> * <li>uses the given <code>{@link ErrorMessageFactory}</code> to create the detail message of the * <code>{@link AssertionError}</code>, prepending the value of <code>{@link AssertionInfo#description()}</code> to * the error message</li> * </ol> * * @param info contains information about the failed assertion. * @param messageFactory knows how to create detail messages for {@code AssertionError}s. * @return the created <code>{@link AssertionError}</code>. */ public AssertionError failure(AssertionInfo info, ErrorMessageFactory messageFactory) { AssertionError error = failureIfErrorMessageIsOverridden(info); if (error != null) return error; AssertionError assertionError = new AssertionError(messageFactory.create(info.description(), info.representation())); removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError); printThreadDumpIfNeeded(); return assertionError; }
/** * Creates a <code>{@link AssertionError}</code> following this pattern: * <ol> * <li>creates a <code>{@link AssertionError}</code> using <code>{@link AssertionInfo#overridingErrorMessage()}</code> * as the error message if such value is not {@code null}, or</li> * <li>uses the given <code>{@link AssertionErrorFactory}</code> to create an <code>{@link AssertionError}</code>, * prepending the value of <code>{@link AssertionInfo#description()}</code> to the error message</li> * </ol> * * @param info contains information about the failed assertion. * @param factory knows how to create {@code AssertionError}s. * @return the created <code>{@link AssertionError}</code>. */ public AssertionError failure(AssertionInfo info, AssertionErrorFactory factory) { AssertionError error = failureIfErrorMessageIsOverridden(info); if (error != null) return error; printThreadDumpIfNeeded(); return factory.newAssertionError(info.description(), info.representation()); }
/** * Creates a <code>{@link AssertionError}</code> following this pattern: * <ol> * <li>creates a <code>{@link AssertionError}</code> using <code>{@link AssertionInfo#overridingErrorMessage()}</code> * as the error message if such value is not {@code null}, or</li> * <li>uses the given <code>{@link AssertionErrorFactory}</code> to create an <code>{@link AssertionError}</code>, * prepending the value of <code>{@link AssertionInfo#description()}</code> to the error message</li> * </ol> * * @param info contains information about the failed assertion. * @param factory knows how to create {@code AssertionError}s. * @return the created <code>{@link AssertionError}</code>. */ public AssertionError failure(AssertionInfo info, AssertionErrorFactory factory) { AssertionError error = failureIfErrorMessageIsOverridden(info); if (error != null) return error; printThreadDumpIfNeeded(); return factory.newAssertionError(info.description(), info.representation()); }
/** * Creates a <code>{@link AssertionError}</code> following this pattern: * <ol> * <li>creates a <code>{@link AssertionError}</code> using <code>{@link AssertionInfo#overridingErrorMessage()}</code> * as the error message if such value is not {@code null}, or</li> * <li>uses the given <code>{@link ErrorMessageFactory}</code> to create the detail message of the * <code>{@link AssertionError}</code>, prepending the value of <code>{@link AssertionInfo#description()}</code> to * the error message</li> * </ol> * * @param info contains information about the failed assertion. * @param messageFactory knows how to create detail messages for {@code AssertionError}s. * @return the created <code>{@link AssertionError}</code>. */ public AssertionError failure(AssertionInfo info, ErrorMessageFactory messageFactory) { AssertionError error = failureIfErrorMessageIsOverridden(info); if (error != null) return error; AssertionError assertionError = new AssertionError(messageFactory.create(info.description(), info.representation())); removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError); printThreadDumpIfNeeded(); return assertionError; }
AssertionError assertionError = Failures.instance().failureIfErrorMessageIsOverridden(info); if (assertionError == null) {
AssertionError assertionError = Failures.instance().failureIfErrorMessageIsOverridden(info); if (assertionError == null) {
/** * Copy from AssertJ to prevent errors with percents in error message */ private void failWithMessage(String errorMessage) { AssertionError assertionError = Failures.instance().failureIfErrorMessageIsOverridden(info); if (assertionError == null) { // error message was not overridden, build it. String description = MessageFormatter.instance().format(info.description(), info.representation(), ""); assertionError = new AssertionError(description + errorMessage); } Failures.instance().removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError); throw assertionError; }