Class Configuration
- Since:
- 3.13.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final booleanstatic final booleanstatic final Configurationstatic final booleanstatic final intstatic final intstatic final intstatic final intstatic final PreferredAssumptionExceptionstatic final booleanstatic final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalDateFormats(DateFormat... additionalDateFormats) Add the given date formats AssertJ will use in date assertions.AssertJ uses defaults date formats in date assertions, this property let's you register additional ones (default there are no additional date formats).voidapply()Applies this configuration to AssertJ.voidApplies this configuration to AssertJ and prints it.booleanReturns whether the extractor considers bare-named property methods likeString name().booleanReturns whether private fields comparison is enabled.describe()booleanReturns whether private fields comparison is enabled.booleanReturns whether AssertJ will use lenient parsing mode for default date formats.intReturns how many elements at most from one iterable/array/map will be displayed in error messages.intReturns the maximum length for an iterable/array to be displayed on one line.intReturns the maximum number of lines for a stacktrace to be displayed on one throw.Returns which exception is thrown if an assumption is not met.booleanbooleanReturns whether AssertJ related elements are removed from assertion errors stack trace.voidsetAdditionalDateFormats(List<DateFormat> additionalDateFormats) Returns the additional date formats AssertJ will use in date assertions.voidsetBareNamePropertyExtraction(boolean bareNamePropertyExtraction) Sets whether the extractor considers bare-named property methods likeString name().voidsetComparingPrivateFields(boolean comparingPrivateFields) Sets whether private fields comparison is enabled.voidSet all configuration settings to their default values again.voidsetDescriptionConsumer(Consumer<Description> descriptionConsumer) voidsetExtractingPrivateFields(boolean extractingPrivateFields) Sets whether private fields comparison is enabled.voidsetLenientDateParsing(boolean lenientDateParsing) Returns whether AssertJ will use lenient parsing mode for default date formats.voidsetMaxElementsForPrinting(int maxElementsForPrinting) Sets the threshold for how many elements at most from one iterable/array/map will be displaye in error messages.voidsetMaxLengthForSingleLineDescription(int maxLengthForSingleLineDescription) Sets the maximum length for an iterable/array to be displayed on one line.voidsetMaxStackTraceElementsDisplayed(int maxStackTraceElementsDisplayed) Returns the maximum number of lines for a stacktrace to be displayed on one throw.voidsetPreferredAssumptionException(PreferredAssumptionException preferredAssumptionException) Sets which exception is thrown if an assumption is not met.voidsetPrintAssertionsDescriptionEnabled(boolean printAssertionsDescription) voidsetRemoveAssertJRelatedElementsFromStackTrace(boolean removeAssertJRelatedElementsFromStackTrace) Returns whether AssertJ related elements are removed from assertion errors stack trace.
-
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:
-
REMOVE_ASSERTJ_RELATED_ELEMENTS_FROM_STACK_TRACE
public static final boolean REMOVE_ASSERTJ_RELATED_ELEMENTS_FROM_STACK_TRACE- 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:
-
PRINT_ASSERTIONS_DESCRIPTION_ENABLED
public static final boolean PRINT_ASSERTIONS_DESCRIPTION_ENABLED- See Also:
-
MAX_STACKTRACE_ELEMENTS_DISPLAYED
public static final int MAX_STACKTRACE_ELEMENTS_DISPLAYED- See Also:
-
PREFERRED_ASSUMPTION_EXCEPTION
-
DEFAULT_CONFIGURATION
-
-
Constructor Details
-
Configuration
public Configuration()
-
-
Method Details
-
setDefaults
public void setDefaults()Set all configuration settings to their default values again. -
representation
- Returns:
- the default
Representationthat 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()orapplyAndDisplay()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()orapplyAndDisplay()is called.- Parameters:
extractingPrivateFields- whether private fields comparison is enabled.
-
bareNamePropertyExtractionEnabled
public boolean bareNamePropertyExtractionEnabled()Returns whether the extractor considers bare-named property methods likeString 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 likeString name().See
Assertions.setExtractBareNamePropertyMethods(boolean)for a detailed description.Note that this change will only be effective once
apply()orapplyAndDisplay()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()orapplyAndDisplay()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()orapplyAndDisplay()is called.- Parameters:
lenientDateParsing- whether AssertJ will use lenient parsing mode for default date formats.
-
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
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()orapplyAndDisplay()is called.- Parameters:
additionalDateFormats- the date formats AssertJ will use in date assertions in addition the default ones.
-
addAdditionalDateFormats
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()orapplyAndDisplay()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()orapplyAndDisplay()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()orapplyAndDisplay()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
-
setDescriptionConsumer
-
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()orapplyAndDisplay()is called.- Parameters:
maxStackTraceElementsDisplayed- the maximum number of lines for a stacktrace to be displayed on one throw.
-
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()orapplyAndDisplay()is called.- Parameters:
preferredAssumptionException- the preferred exception to use withAssumptions.- 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
-