private ShouldBeInstanceOfAny(Throwable throwable, Class<?>[] types) { super("%nExpecting:%n <%s>%nto be an instance of any of:%n <%s>%nbut was:%n <%s>", throwable, types, getStackTrace(throwable)); } }
private ShouldNotHaveThrown(Throwable throwable) { super("%nExpecting code not to raise a throwable but caught%n <%s>", getStackTrace(throwable)); } }
private ShouldBeInstance(Throwable throwable, Class<?> type) { super("%n" + "Expecting:%n" + " <%s>%n" + "to be an instance of:%n" + " <%s>%n" + "but was:%n" + " <%s>", throwable, type, getStackTrace(throwable)); }
private ShouldBeExactlyInstanceOf(Throwable throwable, Class<?> type) { super("%nExpecting:%n <%s>%nto be exactly an instance of:%n <%s>%nbut was:%n <%s>", throwable, type, getStackTrace(throwable)); } }
private ShouldNotBeInstanceOfAny(Throwable throwable, Class<?>[] types) { super("%nExpecting:%n <%s>%nnot to be an instance of any of these types:%n <%s>", getStackTrace(throwable), types); } }
private ShouldNotBeInstance(Throwable throwable, Class<?> type) { super("%nExpecting:%n <%s>%nnot to be an instance of:<%s>", getStackTrace(throwable), type); } }
private ShouldNotBeExactlyInstanceOf(Throwable throwable, Class<?> type) { super("%nExpecting%n <%s>%nnot to be of exact type:%n <%s>", getStackTrace(throwable), type); } }
private ShouldBeInstanceOfAny(Throwable throwable, Class<?>[] types) { super("%nExpecting:%n <%s>%nto be an instance of any of:%n <%s>%nbut was:%n <%s>", throwable, types, getStackTrace(throwable)); } }
private ShouldBeExactlyInstanceOf(Throwable throwable, Class<?> type) { super("%nExpecting:%n <%s>%nto be exactly an instance of:%n <%s>%nbut was:%n <%s>", throwable, type, getStackTrace(throwable)); } }
private ShouldNotHaveThrown(Throwable throwable) { super("%nExpecting code not to raise a throwable but caught%n <%s>", getStackTrace(throwable)); } }
private ShouldNotBeInstance(Throwable throwable, Class<?> type) { super("%nExpecting:%n <%s>%nnot to be an instance of:<%s>", getStackTrace(throwable), type); } }
private ShouldNotBeInstanceOfAny(Throwable throwable, Class<?>[] types) { super("%nExpecting:%n <%s>%nnot to be an instance of any of these types:%n <%s>", getStackTrace(throwable), types); } }
private ShouldBeInstance(Throwable throwable, Class<?> type) { super("%n" + "Expecting:%n" + " <%s>%n" + "to be an instance of:%n" + " <%s>%n" + "but was:%n" + " <%s>", throwable, type, getStackTrace(throwable)); }
private ShouldNotBeExactlyInstanceOf(Throwable throwable, Class<?> type) { super("%nExpecting%n <%s>%nnot to be of exact type:%n <%s>", getStackTrace(throwable), type); } }
/** * {@inheritDoc} */ @Override public void describeTo(Description description) { if (firstError != null) { description.appendText("AssertionError with message: "); description.appendText(firstError.getMessage()); description.appendText(String.format("%n%nStacktrace was: ")); description.appendText(Throwables.getStackTrace(firstError)); } } }
/** * {@inheritDoc} */ @Override public void describeTo(Description description) { if (firstError != null) { description.appendText("AssertionError with message: "); description.appendText(firstError.getMessage()); description.appendText(String.format("%n%nStacktrace was: ")); description.appendText(Throwables.getStackTrace(firstError)); } } }
/** * Asserts that the stack trace of the actual {@code Throwable} contains with the given description. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param description the description expected to be contained in the actual {@code Throwable}'s stack trace. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the stack trace of the actual {@code Throwable} does not contain the given description. */ public void assertHasStackTraceContaining(AssertionInfo info, Throwable actual, String description) { assertNotNull(info, actual); String stackTrace = org.assertj.core.util.Throwables.getStackTrace(actual); if (stackTrace != null && stackTrace.contains(description)) return; throw failures.failure(info, shouldContain(stackTrace, description)); }
protected String toStringOf(CompletableFuture<?> future) { String className = future.getClass().getSimpleName(); if (!future.isDone()) return concat(className, "[Incomplete]"); try { Object joinResult = future.join(); // avoid stack overflow error if future join on itself or another future that cycles back to the first Object joinResultRepresentation = joinResult instanceof CompletableFuture ? joinResult : toStringOf(joinResult); return concat(className, "[Completed: ", joinResultRepresentation, "]"); } catch (CompletionException e) { return concat(className, "[Failed: ", toStringOf(e.getCause()), "]", String.format("%n%s", getStackTrace(e))); } catch (CancellationException e) { return concat(className, "[Cancelled]"); } }
/** * Asserts that the stack trace of the actual {@code Throwable} contains with the given description. * * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param description the description expected to be contained in the actual {@code Throwable}'s stack trace. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the stack trace of the actual {@code Throwable} does not contain the given description. */ public void assertHasStackTraceContaining(AssertionInfo info, Throwable actual, String description) { assertNotNull(info, actual); String stackTrace = org.assertj.core.util.Throwables.getStackTrace(actual); if (stackTrace != null && stackTrace.contains(description)) return; throw failures.failure(info, shouldContain(stackTrace, description)); }
protected String toStringOf(CompletableFuture<?> future) { String className = future.getClass().getSimpleName(); if (!future.isDone()) return concat(className, "[Incomplete]"); try { Object joinResult = future.join(); // avoid stack overflow error if future join on itself or another future that cycles back to the first Object joinResultRepresentation = joinResult instanceof CompletableFuture ? joinResult : toStringOf(joinResult); return concat(className, "[Completed: ", joinResultRepresentation, "]"); } catch (CompletionException e) { return concat(className, "[Failed: ", toStringOf(e.getCause()), "]", String.format("%n%s", getStackTrace(e))); } catch (CancellationException e) { return concat(className, "[Cancelled]"); } }