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

io.restassured.internal.util.MatcherErrorMessageBuilder Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
package io.restassured.internal.util;

import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;

public class MatcherErrorMessageBuilder> {

    private final String name;

    public MatcherErrorMessageBuilder(String name) {
        this.name = name;
    }

    public String buildError(T actual, M matcher) {
        final StringDescription descriptionBuilder = new StringDescription();
        descriptionBuilder.appendText("Expected ").appendText(name).appendText(" ");
        matcher.describeTo(descriptionBuilder);
        descriptionBuilder.appendText(" but ");
        matcher.describeMismatch(actual, descriptionBuilder);

        final String description = descriptionBuilder.toString().replaceAll("[.\\n]+$", "");
        return description + ".\n";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy