diff --git a/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.java b/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.java index 65b837f2..a2428e6d 100644 --- a/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.java +++ b/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.java @@ -29,7 +29,7 @@ void testLineNumbers() { ParsingFilesTest.addApprovalTestPath(); var expected = """ - https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L98-L101 + https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L103-L106 """; String verifyAll = getLink(Queryable.as(Approvals.class.getMethods()).orderBy(m -> m.getParameterCount()) .first(m -> m.getName().equals("verifyAll") && m.getParameterTypes()[0].equals(Object[].class))); @@ -72,4 +72,4 @@ private Queryable getAllVerifyFunctionsWithOptions(List> approv } return methods; } -} +} \ No newline at end of file diff --git a/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.listAllVerifyFunctions.approved.md b/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.listAllVerifyFunctions.approved.md index b9f5e6f7..41018521 100644 --- a/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.listAllVerifyFunctions.approved.md +++ b/approvaltests-tests/src/test/java/org/approvaltests/DocumentHelpersTest.listAllVerifyFunctions.approved.md @@ -1,28 +1,29 @@ - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L214-L230) (ApprovalApprover, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L189-L192) (ApprovalWriter, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L181-L184) (ApprovalWriter, ApprovalNamer, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L235-L238) (ExecutableCommand, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L165-L168) (File, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L243-L246) (Map, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L56-L60) (Object, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L251-L254) (ResultSet, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L259-L262) (SqlLoader, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L48-L51) (String, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L65-L69) (Verifiable, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L106-L109) (Iterable, Function1, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L110-L114) (Object[], Function1, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L140-L143) (String, Iterable, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L127-L131) (String, Iterable, Function1, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L85-L88) (String, Object[], $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L119-L122) (String, Object[], Function1, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L148-L152) (String, String, Iterable, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L93-L97) (String, String, Object[], $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyEachFileInDirectory ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L271-L274) (File, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyEachFileInDirectory ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L279-L282) (File, FileFilter, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyEachFileInDirectory ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L287-L290) (File, FilenameFilter, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyException ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L392-L398) (Action0, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyHtml ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L157-L160) (String, $\color{#AAA}{\textsf{Options}}$) - * Approvals. [verifyXml ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L197-L201) (String, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L227-L243) (ApprovalApprover, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L194-L197) (ApprovalWriter, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L186-L189) (ApprovalWriter, ApprovalNamer, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L248-L251) (ExecutableCommand, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L170-L173) (File, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L256-L259) (Map, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L61-L65) (Object, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L264-L267) (ResultSet, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L272-L275) (SqlLoader, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L53-L56) (String, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L70-L74) (Verifiable, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L111-L114) (Iterable, Function1, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L115-L119) (Object[], Function1, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L145-L148) (String, Iterable, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L132-L136) (String, Iterable, Function1, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L90-L93) (String, Object[], $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L124-L127) (String, Object[], Function1, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L153-L157) (String, String, Iterable, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyAll ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L98-L102) (String, String, Object[], $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyEachFileInDirectory ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L284-L287) (File, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyEachFileInDirectory ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L292-L295) (File, FileFilter, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyEachFileInDirectory ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L300-L303) (File, FilenameFilter, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyException ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L405-L411) (Action0, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyHtml ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L162-L165) (String, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyXml ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L202-L205) (String, $\color{#AAA}{\textsf{Options}}$) + * Approvals. [verifyXml ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/Approvals.java#L210-L214) (String, Function1, $\color{#AAA}{\textsf{Options}}$) * AwtApprovals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/awt/AwtApprovals.java#L44-L47) (BufferedImage, $\color{#AAA}{\textsf{Options}}$) * AwtApprovals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/awt/AwtApprovals.java#L52-L55) (Component, $\color{#AAA}{\textsf{Options}}$) * AwtApprovals. [verify ](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/src/main/java/org/approvaltests/awt/AwtApprovals.java#L36-L39) (Image, $\color{#AAA}{\textsf{Options}}$) diff --git a/approvaltests-tests/src/test/java/org/approvaltests/OptionsTest.testTheVerifyApi.approved.txt b/approvaltests-tests/src/test/java/org/approvaltests/OptionsTest.testTheVerifyApi.approved.txt index 8521208a..bd36f7eb 100644 --- a/approvaltests-tests/src/test/java/org/approvaltests/OptionsTest.testTheVerifyApi.approved.txt +++ b/approvaltests-tests/src/test/java/org/approvaltests/OptionsTest.testTheVerifyApi.approved.txt @@ -62,3 +62,5 @@ public static void org.approvaltests.Approvals.verifyJson(java.lang.String) public static void org.approvaltests.Approvals.verifyJson(java.lang.String,org.approvaltests.core.Options) public static void org.approvaltests.Approvals.verifyXml(java.lang.String) public static void org.approvaltests.Approvals.verifyXml(java.lang.String,org.approvaltests.core.Options) +public static void org.approvaltests.Approvals.verifyXml(java.lang.String,org.lambda.functions.Function1) +public static void org.approvaltests.Approvals.verifyXml(java.lang.String,org.lambda.functions.Function1,org.approvaltests.core.Options) diff --git a/approvaltests/src/main/java/org/approvaltests/Approvals.java b/approvaltests/src/main/java/org/approvaltests/Approvals.java index 58992b0e..ec0d105e 100644 --- a/approvaltests/src/main/java/org/approvaltests/Approvals.java +++ b/approvaltests/src/main/java/org/approvaltests/Approvals.java @@ -10,7 +10,12 @@ import com.spun.util.persistence.SqlLoader; import org.approvaltests.approvers.ApprovalApprover; import org.approvaltests.approvers.FileApprover; -import org.approvaltests.core.*; +import org.approvaltests.core.ApprovalFailureReporter; +import org.approvaltests.core.ApprovalWriter; +import org.approvaltests.core.Options; +import org.approvaltests.core.Verifiable; +import org.approvaltests.core.VerifyParameters; +import org.approvaltests.core.VerifyResult; import org.approvaltests.namer.ApprovalNamer; import org.approvaltests.namer.MasterDirectoryNamer; import org.approvaltests.namer.NamerFactoryForOptions; @@ -196,7 +201,15 @@ public static void verifyXml(String xml) } public static void verifyXml(String xml, Options options) { - final String formattedXml = ApprovalXmlWriter.prettyPrint(xml, 2); + verifyXml(xml, x -> ApprovalXmlWriter.prettyPrint(x, 2), options); + } + public static void verifyXml(String xml, Function1 prettyPrinter) + { + verifyXml(xml, prettyPrinter, new Options()); + } + public static void verifyXml(String xml, Function1 prettyPrinter, Options options) + { + String formattedXml = prettyPrinter.call(xml); verify(formattedXml, options.forFile().withExtension(".xml")); } public static void verify(ApprovalApprover approver)