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

io.github.olib963.javatest.matchers.internal.CauseMatcher Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package io.github.olib963.javatest.matchers.internal;

import io.github.olib963.javatest.matchers.MatchResult;
import io.github.olib963.javatest.matchers.Matcher;

public class CauseMatcher implements Matcher {
    private final Matcher causeMatcher;

    public CauseMatcher(Matcher causeMatcher) {
        this.causeMatcher = causeMatcher;
    }

    @Override
    public MatchResult matches(Throwable value) {
        var cause = value.getCause();
        return causeMatcher.matches(cause)
                .mapMismatch(mismatch -> "cause {" + cause + "} " + mismatch);
    }

    @Override
    public String describeExpected() {
        return "have a cause that was expected to " + causeMatcher.describeExpected();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy