Class Configuration


  • public class Configuration
    extends Object
    All configuration settings for AssertJ Core.
    Since:
    3.13.0
    • Field Detail

      • DEFAULT_CONFIGURATION

        public static final Configuration DEFAULT_CONFIGURATION
      • MAX_LENGTH_FOR_SINGLE_LINE_DESCRIPTION

        public static final int MAX_LENGTH_FOR_SINGLE_LINE_DESCRIPTION
        See Also:
        Constant Field Values
      • MAX_ELEMENTS_FOR_PRINTING

        public static final int MAX_ELEMENTS_FOR_PRINTING
        See Also:
        Constant Field Values
      • REMOVE_ASSERTJ_RELATED_ELEMENTS_FROM_STACK_TRACE

        public static final boolean REMOVE_ASSERTJ_RELATED_ELEMENTS_FROM_STACK_TRACE
        See Also:
        Constant Field Values
      • ALLOW_COMPARING_PRIVATE_FIELDS

        public static final boolean ALLOW_COMPARING_PRIVATE_FIELDS
        See Also:
        Constant Field Values
      • ALLOW_EXTRACTING_PRIVATE_FIELDS

        public static final boolean ALLOW_EXTRACTING_PRIVATE_FIELDS
        See Also:
        Constant Field Values
      • BARE_NAME_PROPERTY_EXTRACTION_ENABLED

        public static final boolean BARE_NAME_PROPERTY_EXTRACTION_ENABLED
        See Also:
        Constant Field Values
      • comparingPrivateFields

        private boolean comparingPrivateFields
      • extractingPrivateFields

        private boolean extractingPrivateFields
      • bareNamePropertyExtraction

        private boolean bareNamePropertyExtraction
      • removeAssertJRelatedElementsFromStackTrace

        private boolean removeAssertJRelatedElementsFromStackTrace
      • lenientDateParsing

        private boolean lenientDateParsing
      • additionalDateFormats

        private List<DateFormat> additionalDateFormats
      • maxLengthForSingleLineDescription

        private int maxLengthForSingleLineDescription
      • maxElementsForPrinting

        private int maxElementsForPrinting
    • Constructor Detail

      • Configuration

        public Configuration()
    • Method Detail

      • hasCustomRepresentation

        boolean hasCustomRepresentation()
      • comparingPrivateFieldsEnabled

        public boolean comparingPrivateFieldsEnabled()
        Returns whether private fields comparison is enabled. Default is true.

        See Assertions.setAllowComparingPrivateFields(boolean) for a detailed description.

        Returns:
        whether private fields comparison is enabled.
      • setComparingPrivateFields

        public void setComparingPrivateFields​(boolean comparingPrivateFields)
        Sets whether private fields comparison is enabled.

        See Assertions.setAllowComparingPrivateFields(boolean) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        comparingPrivateFields - whether private fields comparison is enabled.
      • extractingPrivateFieldsEnabled

        public boolean extractingPrivateFieldsEnabled()
        Returns whether private fields comparison is enabled. Default is true.

        See Assertions.setAllowExtractingPrivateFields(boolean) for a detailed description.

        Returns:
        whether private fields comparison is enabled.
      • setExtractingPrivateFields

        public void setExtractingPrivateFields​(boolean extractingPrivateFields)
        Sets whether private fields comparison is enabled.

        See Assertions.setAllowExtractingPrivateFields(boolean) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        extractingPrivateFields - whether private fields comparison is enabled.
      • bareNamePropertyExtractionEnabled

        public boolean bareNamePropertyExtractionEnabled()
        Returns whether the extractor considers bare-named property methods like String name(). Default is true.

        See Assertions.setExtractBareNamePropertyMethods(boolean) for a detailed description.

        Returns:
        whether the extractor considers bare-named property methods like String name().
      • setBareNamePropertyExtraction

        public void setBareNamePropertyExtraction​(boolean bareNamePropertyExtraction)
        Sets whether the extractor considers bare-named property methods like String name().

        See Assertions.setExtractBareNamePropertyMethods(boolean) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        bareNamePropertyExtraction - whether the extractor considers bare-named property methods.
      • removeAssertJRelatedElementsFromStackTraceEnabled

        public boolean removeAssertJRelatedElementsFromStackTraceEnabled()
        Returns whether AssertJ related elements are removed from assertion errors stack trace. Default is true.

        See Assertions.setRemoveAssertJRelatedElementsFromStackTrace(boolean) for a detailed description.

        Returns:
        whether AssertJ related elements are removed from assertion errors stack trace.
      • setRemoveAssertJRelatedElementsFromStackTrace

        public void setRemoveAssertJRelatedElementsFromStackTrace​(boolean removeAssertJRelatedElementsFromStackTrace)
        Returns whether AssertJ related elements are removed from assertion errors stack trace.

        See Assertions.setRemoveAssertJRelatedElementsFromStackTrace(boolean) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        removeAssertJRelatedElementsFromStackTrace - whether AssertJ related elements are removed from assertion errors stack trace.
      • lenientDateParsingEnabled

        public boolean lenientDateParsingEnabled()
        Returns whether AssertJ will use lenient parsing mode for default date formats. Default is false.

        See Assertions.setLenientDateParsing(boolean) for a detailed description.

        Returns:
        whether AssertJ will use lenient parsing mode for default date formats.
      • setLenientDateParsing

        public void setLenientDateParsing​(boolean lenientDateParsing)
        Returns whether AssertJ will use lenient parsing mode for default date formats.

        See Assertions.setLenientDateParsing(boolean) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        lenientDateParsing - whether AssertJ will use lenient parsing mode for default date formats.
      • additionalDateFormats

        public List<DateFormat> additionalDateFormats()
        AssertJ uses defaults date formats in date assertions, this property let's you register additional ones (default there are no additional date formats).

        See Assertions.registerCustomDateFormat(java.text.DateFormat) for a detailed description.

        Returns:
        the date formats AssertJ will use in date assertions in addition the default ones.
      • setAdditionalDateFormats

        public void setAdditionalDateFormats​(List<DateFormat> additionalDateFormats)
        Returns the additional date formats AssertJ will use in date assertions.

        See Assertions.registerCustomDateFormat(java.text.DateFormat) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        additionalDateFormats - the date formats AssertJ will use in date assertions in addition the default ones.
      • addAdditionalDateFormats

        public void addAdditionalDateFormats​(DateFormat... additionalDateFormats)
        Add the given date formats AssertJ will use in date assertions.

        See Assertions.registerCustomDateFormat(java.text.DateFormat) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        additionalDateFormats - the date formats AssertJ will use in date assertions in addition the default ones.
      • maxLengthForSingleLineDescription

        public int maxLengthForSingleLineDescription()
        Returns the maximum length for an iterable/array to be displayed on one line. Default is 80.

        See Assertions.setMaxLengthForSingleLineDescription(int) for a detailed description.

        Returns:
        the maximum length for an iterable/array to be displayed on one line.
      • setMaxLengthForSingleLineDescription

        public void setMaxLengthForSingleLineDescription​(int maxLengthForSingleLineDescription)
        Sets the maximum length for an iterable/array to be displayed on one line.

        See Assertions.setMaxLengthForSingleLineDescription(int) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        maxLengthForSingleLineDescription - the maximum length for an iterable/array to be displayed on one line.
      • maxElementsForPrinting

        public int maxElementsForPrinting()
        Returns the maximum length for an iterable/array to be displayed on one line. Default is 1000.

        See Assertions.setMaxLengthForSingleLineDescription(int) for a detailed description.

        Returns:
        the maximum length for an iterable/array to be displayed on one line.
      • setMaxElementsForPrinting

        public void setMaxElementsForPrinting​(int maxElementsForPrinting)
        Returns the maximum length for an iterable/array to be displayed on one line.

        See Assertions.setMaxLengthForSingleLineDescription(int) for a detailed description.

        Note that this change will only be effective once apply() or applyAndDisplay() is called.

        Parameters:
        maxElementsForPrinting - the maximum length for an iterable/array to be displayed on one line.
      • apply

        public void apply()
        Applies this configuration to AssertJ.
      • applyAndDisplay

        public void applyAndDisplay()
        Applies this configuration to AssertJ and prints it.
      • describe

        public String describe()
      • describeAdditionalDateFormats

        private String describeAdditionalDateFormats()