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

io.github.olib963.javatest.matchers.internal.MessageMatcher 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 MessageMatcher implements Matcher {
    private final Matcher messageMatcher;

    public MessageMatcher(Matcher messageMatcher) {
        this.messageMatcher = messageMatcher;
    }

    @Override
    public MatchResult matches(Throwable value) {
        var message = value.getMessage();
        return messageMatcher.matches(message)
                .mapMismatch(mismatch -> "message {" + message + "} " + mismatch);
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy