Class Configuration

java.lang.Object
org.assertj.core.configuration.Configuration

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

    • MAX_LENGTH_FOR_SINGLE_LINE_DESCRIPTION

      public static final int MAX_LENGTH_FOR_SINGLE_LINE_DESCRIPTION
      See Also:
    • MAX_ELEMENTS_FOR_PRINTING

      public static final int MAX_ELEMENTS_FOR_PRINTING
      See Also:
    • MAX_INDICES_FOR_PRINTING

      public static final int MAX_INDICES_FOR_PRINTING
      See Also:
    • ALLOW_COMPARING_PRIVATE_FIELDS

      public static final boolean ALLOW_COMPARING_PRIVATE_FIELDS
      See Also:
    • ALLOW_EXTRACTING_PRIVATE_FIELDS

      public static final boolean ALLOW_EXTRACTING_PRIVATE_FIELDS
      See Also:
    • BARE_NAME_PROPERTY_EXTRACTION_ENABLED

      public static final boolean BARE_NAME_PROPERTY_EXTRACTION_ENABLED
      See Also:
    • LENIENT_DATE_PARSING

      public static final boolean LENIENT_DATE_PARSING
      See Also:
    • MAX_STACKTRACE_ELEMENTS_DISPLAYED

      public static final int MAX_STACKTRACE_ELEMENTS_DISPLAYED
      See Also:
    • PREFERRED_ASSUMPTION_EXCEPTION

      public static final PreferredAssumptionException PREFERRED_ASSUMPTION_EXCEPTION
    • DEFAULT_CONFIGURATION

      public static final Configuration DEFAULT_CONFIGURATION
  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • setDefaults

      public void setDefaults()
      Set all configuration settings to their default values again.
    • representation

      public Representation representation()
      Returns:
      the default Representation that is used within AssertJ.
    • 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 how many elements at most from one iterable/array/map will be displayed in error messages.

      Default is 1000.

      See Assertions.setMaxElementsForPrinting(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)
      Sets the threshold for how many elements at most from one iterable/array/map will be displaye in error messages.

      See Assertions.setMaxElementsForPrinting(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.
    • printAssertionsDescription

      public boolean printAssertionsDescription()
    • setPrintAssertionsDescriptionEnabled

      public void setPrintAssertionsDescriptionEnabled(boolean printAssertionsDescription)
    • descriptionConsumer

      public Consumer<Description> descriptionConsumer()
    • setDescriptionConsumer

      public void setDescriptionConsumer(Consumer<Description> descriptionConsumer)
    • maxStackTraceElementsDisplayed

      public int maxStackTraceElementsDisplayed()
      Returns the maximum number of lines for a stacktrace to be displayed on one throw. Default is 3.

      See (int) for a detailed description.

      Returns:
      the maximum number of lines for a stacktrace to be displayed on one throw.
    • setMaxStackTraceElementsDisplayed

      public void setMaxStackTraceElementsDisplayed(int maxStackTraceElementsDisplayed)
      Returns the maximum number of lines for a stacktrace to be displayed on one throw.

      See (int) for a detailed description.

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

      Parameters:
      maxStackTraceElementsDisplayed - the maximum number of lines for a stacktrace to be displayed on one throw.
    • preferredAssumptionException

      public PreferredAssumptionException preferredAssumptionException()
      Returns which exception is thrown if an assumption is not met.

      See Assumptions.setPreferredAssumptionException(PreferredAssumptionException) for a detailed description.

      Returns:
      the assumption exception to throw.
      Since:
      3.21.0
    • setPreferredAssumptionException

      public void setPreferredAssumptionException(PreferredAssumptionException preferredAssumptionException)
      Sets which exception is thrown if an assumption is not met.

      See Assumptions.setPreferredAssumptionException(PreferredAssumptionException) for a detailed description.

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

      Parameters:
      preferredAssumptionException - the preferred exception to use with Assumptions.
      Since:
      3.21.0
    • 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()