Class DiffHelper.DiffProcessor

  • Enclosing class:
    DiffHelper

    public static class DiffHelper.DiffProcessor
    extends Object
    This class realizes a fluent interface when instrumenting the Diff with information used when diffing. The last method called is start(), which starts the diff process and either throws an AssertionError or returns silently.
    • Method Detail

      • normalizeOutput

        public DiffHelper.DiffProcessor normalizeOutput​(StringNormalizer normalizer)
        Prepare this diff processor to normalize output before searching for differences.
        Parameters:
        normalizer - normalizes output before diffing
      • normalizeOutputExcludedFromDiffSynopsis

        public DiffHelper.DiffProcessor normalizeOutputExcludedFromDiffSynopsis​(StringNormalizer normalizer)
        Prepare this diff processor to normalize output before searching for differences. This method specifies a normalization, that will be in effect when comparing strings, but the normalization will not be noticable in the diff synopsis. This can be used to perform normalizations that will degenerate the two strings to unreadable strings in order to perform a very sloppy comparison. E. g. we could compare two strings after eliminating all whitespaces from both strings. If there are differences, the output won't get unreadable, since it will be based on the unnormalized versions of the two compared strings.
        Parameters:
        normalizer - normalizes output before diffing
      • restrictOutputCapacity

        public DiffHelper.DiffProcessor restrictOutputCapacity​(long bytes,
                                                               boolean failOnOverflow)
        Prepare this diff processor to restrict the maximum output capacity to a given number of bytes. If the output exceeds the capacity, Graja will throw an AssertionError if failOnOverflow is true, or it will ignore the output silently, otherwise.
        Parameters:
        bytes - maximum capacity in bytes
        failOnOverflow - if true, an AssertionError will be thrown on overflow.
        Returns:
        reference to this DiffProcessor
      • includeExplanationInDiffSynopsis

        public DiffHelper.DiffProcessor includeExplanationInDiffSynopsis​(Content explanation)
        Parameters:
        explanation - will be appended to output, if there are differences.
      • includeExplanationOnThrowableFromMethod

        public DiffHelper.DiffProcessor includeExplanationOnThrowableFromMethod​(Content explanation)
        Prepare this diff processor to include an explanation when running a method or runnable fails.
        Parameters:
        explanation - will be appended to output, if the method execution failed by throwing a Throwable. This can be used to include additional information into the output in order to give hints to the students, what input parameters have been passed to the method that caused the failure.
        Throws:
        IllegalArgumentException - if this is a DiffProcessor comparing strings, i. e. if this DiffProcessor was created by DiffHelper.compareStrings(String, String).
      • useCommentLevelOnDiff

        public DiffHelper.DiffProcessor useCommentLevelOnDiff​(Level level)
        Prepare this diff processor to use level as the comment level in the diff synopsis.
        Parameters:
        level - will be used as the comment level, if there are differences. Default is Level.INFO.
      • useCommentAudienceOnDiff

        public DiffHelper.DiffProcessor useCommentAudienceOnDiff​(Audience audience)
        Prepare this diff processor to use audience as the comment audience in the diff synopsis.
        Parameters:
        audience - will be used as the comment audience, if there are differences. Default is Audience.BOTH.
      • hideCRLF

        public DiffHelper.DiffProcessor hideCRLF()
        Prepare this diff processor to not print CR and LF characters as special symbols.
        Returns:
        this