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 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)); } }
Throwables.removeAssertJRelatedElementsFromStackTrace(assertionError);
private static List<StackTraceElement> stackTraceInCurrentThread(String methodToStartFrom) { List<StackTraceElement> filtered = stackTraceInCurrentThread(); List<StackTraceElement> toRemove = new ArrayList<>(); for (StackTraceElement e : filtered) { if (methodToStartFrom.equals(e.getMethodName())) { break; } toRemove.add(e); } filtered.removeAll(toRemove); return filtered; }
protected static void throwsBestMultipleAssertionsError(List<Throwable> errors) { tryThrowingMultipleFailuresError(errors); throw new SoftAssertionError(describeErrors(errors)); }
/** * Wraps, with a {@link org.assertj.swing.exception.UnexpectedException}, and re-throws any caught exception in the given action. * * @param action the given action that may have a caught exception during its execution. * @throws org.assertj.swing.exception.UnexpectedException wrapping any <b>checked</b> exception thrown when executing the given query in the * event dispatch thread (EDT). Unchecked exceptions are re-thrown without any wrapping. */ private static void rethrowCaughtExceptionIn(@Nonnull GuiAction action) { Throwable caughtException = action.catchedException(); action.clearCaughtException(); if (caughtException == null) { return; } if (caughtException instanceof RuntimeException) { appendStackTraceInCurrentThreadToThrowable(caughtException, "execute"); throw (RuntimeException) caughtException; } if (caughtException instanceof Error) { caughtException.fillInStackTrace(); throw (Error) caughtException; } throw unexpected(caughtException); } }
/** * Appends the stack trace of the current thread to the one in the given <code>{@link Throwable}</code>. * * @param t the given {@code Throwable}. * @param methodToStartFrom the name of the method used as the starting point of the current thread's stack trace. */ public static void appendStackTraceInCurrentThreadToThrowable(Throwable t, String methodToStartFrom) { List<StackTraceElement> stackTrace = newArrayList(t.getStackTrace()); stackTrace.addAll(stackTraceInCurrentThread(methodToStartFrom)); t.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); }
public AssertionError multipleSoftAssertionsError(List<? extends Throwable> errors) { Optional<AssertionError> multipleFailuresError = tryBuildingMultipleFailuresError(errors); return multipleFailuresError.orElse(new SoftAssertionError(describeErrors(errors))); }
private ShouldNotHaveThrown(Throwable throwable) { super("%nExpecting code not to raise a throwable but caught%n <%s>", getStackTrace(throwable)); } }
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 static List<StackTraceElement> stackTraceInCurrentThread(String methodToStartFrom) { List<StackTraceElement> filtered = stackTraceInCurrentThread(); List<StackTraceElement> toRemove = new ArrayList<>(); for (StackTraceElement e : filtered) { if (methodToStartFrom.equals(e.getMethodName())) { break; } toRemove.add(e); } filtered.removeAll(toRemove); return filtered; }
Throwables.removeAssertJRelatedElementsFromStackTrace(assertionError);
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 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)); }
/** * Appends the stack trace of the current thread to the one in the given <code>{@link Throwable}</code>. * * @param t the given {@code Throwable}. * @param methodToStartFrom the name of the method used as the starting point of the current thread's stack trace. */ public static void appendStackTraceInCurrentThreadToThrowable(Throwable t, String methodToStartFrom) { List<StackTraceElement> stackTrace = newArrayList(t.getStackTrace()); stackTrace.addAll(stackTraceInCurrentThread(methodToStartFrom)); t.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); }
Throwables.removeAssertJRelatedElementsFromStackTrace(assertionError);
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 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 static List<StackTraceElement> stackTraceInCurrentThread(String methodToStartFrom) { List<StackTraceElement> filtered = stackTraceInCurrentThread(); List<StackTraceElement> toRemove = new ArrayList<StackTraceElement>(); for (StackTraceElement e : filtered) { if (methodToStartFrom.equals(e.getMethodName())) { break; } toRemove.add(e); } filtered.removeAll(toRemove); return filtered; }
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); } }