Class PdfComparer

java.lang.Object
com._4point.testing.matchers.aem.PdfComparer

public class PdfComparer extends Object
PdfComparer is used to compare to PDFs for visual results (sort of a "digital lightbox"). NOTE: Class is still under development - api and behaviour may change.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PdfComparer(Path goldResultsDir, Path actualResultsDir)
    Constructs a PdfComparer
  • Method Summary

    Modifier and Type
    Method
    Description
    org.hamcrest.Matcher<byte[]>
    comparesEqual(String expectedResultFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesEqual(String expectedResultFile, String exclusionsFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesEqual(Path expectedResultFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesEqual(Path expectedResultFile, Path exclusionsFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesNotEqual(String expectedResultFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesNotEqual(String expectedResultFile, String exclusionsFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesNotEqual(Path expectedResultFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.
    org.hamcrest.Matcher<byte[]>
    comparesNotEqual(Path expectedResultFile, Path exclusionsFile)
    Creates a matcher that compares a PDF in a byte array to a expected "gold" result file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PdfComparer

      public PdfComparer(Path goldResultsDir, Path actualResultsDir)
      Constructs a PdfComparer
      Parameters:
      goldResultsDir - directory where the expected (gold) pdf result files will be. This cannot be null and the directory must already exist.
      actualResultsDir - directory where the actual results will be written along with diff comparison results. This directory will be created if it does not already exist. This parameter can be null if no actual lresults are to be retained.
  • Method Details

    • comparesEqual

      public org.hamcrest.Matcher<byte[]> comparesEqual(Path expectedResultFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. If the PDFs do not match, then the byte array is written to the actual results directory and a PDF of the differences is also written to the actual results directory.
      Parameters:
      expectedResultFile - path to expected result file.
      Returns:
      the Matcher
    • comparesEqual

      public org.hamcrest.Matcher<byte[]> comparesEqual(String expectedResultFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. If the PDFs do not match, then the byte array is written to the actual results directory and a PDF of the differences is also written to the actual results directory. This is a convenience function that converts the parameter to a Path and then calls comparesEqual(Path).
      Parameters:
      expectedResultFile - name of expected result file.
      Returns:
      the Matcher
    • comparesNotEqual

      public org.hamcrest.Matcher<byte[]> comparesNotEqual(Path expectedResultFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. Nothing is written to the actual results directory regardless of the outcome of the match.
      Parameters:
      expectedResultFile - path to expected result file.
      Returns:
      the Matcher
    • comparesNotEqual

      public org.hamcrest.Matcher<byte[]> comparesNotEqual(String expectedResultFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. Nothing is written to the actual results directory regardless of the outcome of the match. This is a convenience function that converts the parameter to a Path and then calls comparesNotEqual(Path).
      Parameters:
      expectedResultFile - path to expected result file.
      Returns:
      the Matcher
    • comparesEqual

      public org.hamcrest.Matcher<byte[]> comparesEqual(Path expectedResultFile, Path exclusionsFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. If the PDFs do not match, then the byte array is written to the actual results directory and a PDF of the differences is also written to the actual results directory.
      Parameters:
      expectedResultFile - path to expected result file.
      exclusionsFile - path to the exclusions file
      Returns:
      the Matcher
    • comparesEqual

      public org.hamcrest.Matcher<byte[]> comparesEqual(String expectedResultFile, String exclusionsFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. If the PDFs do not match, then the byte array is written to the actual results directory and a PDF of the differences is also written to the actual results directory. This is a convenience function that converts the parameters to Path objects and then calls comparesEqual(Path, Path).
      Parameters:
      expectedResultFile - path to expected result file.
      exclusionsFile - path to the exclusions file
      Returns:
      the Matcher
    • comparesNotEqual

      public org.hamcrest.Matcher<byte[]> comparesNotEqual(Path expectedResultFile, Path exclusionsFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. Nothing is written to the actual results directory regardless of the outcome of the match.
      Parameters:
      expectedResultFile - path to expected result file.
      exclusionsFile - path to the exclusions file
      Returns:
      the Matcher
    • comparesNotEqual

      public org.hamcrest.Matcher<byte[]> comparesNotEqual(String expectedResultFile, String exclusionsFile)
      Creates a matcher that compares a PDF in a byte array to a expected "gold" result file. If the expected "gold" result file path is relative, then it is relative to the "gold" directory. Nothing is written to the actual results directory regardless of the outcome of the match. This is a convenience function that converts the parameters to Path objects and then calls comparesNotEqual(Path, Path).
      Parameters:
      expectedResultFile - path to expected result file.
      exclusionsFile - path to the exclusions file
      Returns:
      the Matcher