| 1 | package fr.sii.ogham.testing.assertion.hamcrest; | |
| 2 | ||
| 3 | import java.util.function.Consumer; | |
| 4 | ||
| 5 | import org.custommonkey.xmlunit.DetailedDiff; | |
| 6 | import org.junit.ComparisonFailure; | |
| 7 | import org.slf4j.Logger; | |
| 8 | import org.slf4j.LoggerFactory; | |
| 9 | import org.w3c.dom.Document; | |
| 10 | ||
| 11 | import fr.sii.ogham.testing.assertion.OghamAssertions; | |
| 12 | import fr.sii.ogham.testing.assertion.util.HtmlUtils; | |
| 13 | ||
| 14 | /** | |
| 15 | * Check if the HTML is identical to the expected. The HTML strings are parsed | |
| 16 | * into {@link Document}s. Two documents are considered to be "identical" if | |
| 17 | * they contain the same elements and attributes in the same order. | |
| 18 | * | |
| 19 | * <p> | |
| 20 | * This matcher is a {@link ExpectedValueProvider} for knowing the original expected | |
| 21 | * value. Thanks to this information, {@link OghamAssertions} will generate a | |
| 22 | * {@link ComparisonFailure} with the expected string and actual string in order | |
| 23 | * to be able to visualize the differences on sources directly in the IDE. | |
| 24 | * | |
| 25 | * <p> | |
| 26 | * See {@link HtmlUtils} for more information about "identical" HTML. | |
| 27 | * | |
| 28 | * @author Aurélien Baudet | |
| 29 | * | |
| 30 | */ | |
| 31 | public class IdenticalHtmlMatcher extends AbstractHtmlDiffMatcher { | |
| 32 | private static final Logger LOG = LoggerFactory.getLogger(IdenticalHtmlMatcher.class); | |
| 33 | | |
| 34 | public IdenticalHtmlMatcher(String expected) { | |
| 35 | this(expected, LOG::warn); | |
| 36 | } | |
| 37 | ||
| 38 | public IdenticalHtmlMatcher(String expected, Consumer<String> printer) { | |
| 39 | super(expected, printer, "identical"); | |
| 40 | } | |
| 41 | ||
| 42 | @Override | |
| 43 | protected boolean matches(DetailedDiff diff) { | |
| 44 |
8
1. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → NO_COVERAGE 2. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → NO_COVERAGE 3. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → SURVIVED 4. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → TIMED_OUT 5. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → TIMED_OUT 6. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → KILLED 7. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → KILLED 8. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::matches → KILLED |
return diff.identical(); |
| 45 | } | |
| 46 | ||
| 47 | @Override | |
| 48 | public String toString() { | |
| 49 |
2
1. toString : replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::toString → SURVIVED 2. toString : replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/IdenticalHtmlMatcher::toString → NO_COVERAGE |
return "isIdenticalHtml('"+expected+"')"; |
| 50 | } | |
| 51 | } | |
Mutations | ||
| 44 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 49 |
1.1 2.2 |