com.codeborne.pdftest.matchers.ContainsText Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdf-test Show documentation
Show all versions of pdf-test Show documentation
PDF Test: PDF testing library
package com.codeborne.pdftest.matchers;
import com.codeborne.pdftest.PDF;
import org.hamcrest.Description;
public class ContainsText extends PDFMatcher {
private final String substring;
public ContainsText(String substring) {
this.substring = substring;
}
@Override
protected boolean matchesSafely(PDF item) {
return reduceSpaces(item.text).contains(reduceSpaces(substring));
}
@Override
protected void describeMismatchSafely(PDF item, Description mismatchDescription) {
mismatchDescription.appendText("was \"").appendText(reduceSpaces(item.text)).appendText("\"");
}
@Override
public void describeTo(Description description) {
description.appendText("a PDF containing ").appendValue(reduceSpaces(substring));
}
}