All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.olib963.javatest.matchers.ExceptionMatchers Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
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);
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy