io.github.olib963.javatest.matchers.ExceptionMatchers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javatest-matchers Show documentation
Show all versions of javatest-matchers Show documentation
Matchers to create assertions from common conditions
package io.github.olib963.javatest.matchers;
import io.github.olib963.javatest.matchers.internal.CauseMatcher;
import io.github.olib963.javatest.matchers.internal.MessageMatcher;
import io.github.olib963.javatest.matchers.internal.PredicateMatcher;
import io.github.olib963.javatest.matchers.internal.ThrowsExceptionMatcher;
public class ExceptionMatchers {
private ExceptionMatchers() {}
public static Matcher willThrowExceptionThat(Matcher exceptionMatcher) {
return new ThrowsExceptionMatcher(exceptionMatcher);
}
public static Matcher hasMessage(String message) {
return hasMessageThat(PredicateMatcher.isEqualTo(message));
}
public static Matcher hasMessageThat(Matcher messageMatcher) {
return new MessageMatcher(messageMatcher);
}
public static Matcher hasCause(Throwable cause) {
return hasCauseThat(PredicateMatcher.isEqualTo(cause));
}
public static Matcher hasCauseThat(Matcher causeMatcher) {
return new CauseMatcher(causeMatcher);
}
}