use of org.assertj.core.util.diff.Delta in project mapstruct by mapstruct.
the class JavaFileAssert method hasSameMapperContent.
/**
* Verifies that the expected file has the same content as this Java file. The verification ignores
* the license header and the date/comments line from the {@code @Generated} annotation.
*
* @param expected the file that should be matched
*/
public void hasSameMapperContent(File expected) {
Charset charset = Charset.forName("UTF-8");
try {
List<Delta<String>> diffs = new ArrayList<Delta<String>>(this.diff.diff(actual, charset, expected, charset));
Iterator<Delta<String>> iterator = diffs.iterator();
while (iterator.hasNext()) {
Delta<String> delta = iterator.next();
if (ignoreDelta(delta)) {
iterator.remove();
}
}
if (!diffs.isEmpty()) {
throw Failures.instance().failure(info, ShouldHaveSameContent.shouldHaveSameContent(actual, expected, diffs));
}
} catch (IOException e) {
throw new RuntimeIOException(format("Unable to compare contents of files:<%s> and:<%s>", actual, expected), e);
}
}
Aggregations