Class Configuration
- Since:
- 3.13.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
static final boolean
static final Configuration
static final boolean
static final int
static final int
static final int
static final int
static final PreferredAssumptionException
static final boolean
static final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalDateFormats
(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).void
apply()
Applies this configuration to AssertJ.void
Applies this configuration to AssertJ and prints it.boolean
Returns whether the extractor considers bare-named property methods likeString name()
.boolean
Returns whether private fields comparison is enabled.describe()
boolean
Returns whether private fields comparison is enabled.boolean
Returns whether AssertJ will use lenient parsing mode for default date formats.int
Returns how many elements at most from one iterable/array/map will be displayed in error messages.int
Returns the maximum length for an iterable/array to be displayed on one line.int
Returns 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.boolean
boolean
Returns whether AssertJ related elements are removed from assertion errors stack trace.void
setAdditionalDateFormats
(List<DateFormat> additionalDateFormats) Returns the additional date formats AssertJ will use in date assertions.void
setBareNamePropertyExtraction
(boolean bareNamePropertyExtraction) Sets whether the extractor considers bare-named property methods likeString name()
.void
setComparingPrivateFields
(boolean comparingPrivateFields) Sets whether private fields comparison is enabled.void
Set all configuration settings to their default values again.void
setDescriptionConsumer
(Consumer<Description> descriptionConsumer) void
setExtractingPrivateFields
(boolean extractingPrivateFields) Sets whether private fields comparison is enabled.void
setLenientDateParsing
(boolean lenientDateParsing) Returns whether AssertJ will use lenient parsing mode for default date formats.void
setMaxElementsForPrinting
(int maxElementsForPrinting) Sets the threshold for how many elements at most from one iterable/array/map will be displaye in error messages.void
setMaxLengthForSingleLineDescription
(int maxLengthForSingleLineDescription) Sets the maximum length for an iterable/array to be displayed on one line.void
setMaxStackTraceElementsDisplayed
(int maxStackTraceElementsDisplayed) Returns the maximum number of lines for a stacktrace to be displayed on one throw.void
setPreferredAssumptionException
(PreferredAssumptionException preferredAssumptionException) Sets which exception is thrown if an assumption is not met.void
setPrintAssertionsDescriptionEnabled
(boolean printAssertionsDescription) void
setRemoveAssertJRelatedElementsFromStackTrace
(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
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()
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
-