Top Description Fields Constructors Methods
org.assertj.core.configuration

public Class Configuration

extends Object
Class Inheritance
Static Imports
java.lang.String.format, java.util.Collections.emptyList, java.util.stream.Collectors.toList, org.assertj.core.presentation.StandardRepresentation.STANDARD_REPRESENTATION

All configuration settings for AssertJ Core.
Since
3.13.0

Field Summary

Modifier and TypeField and Description
private List<DateFormat>
public static final boolean
public static final boolean
public static final boolean
private boolean
private boolean
public static final Configuration
private Consumer<Description>
private boolean
public static final boolean
private boolean
public static final int
public static final int
public static final int
public static final int
private int
private int
private int
public static final PreferredAssumptionException
private PreferredAssumptionException
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addAdditionalDateFormats(DateFormat...
the date formats AssertJ will use in date assertions in addition the default ones.
additionalDateFormats
)

Add the given date formats AssertJ will use in date assertions.

public List<DateFormat>

Returns:

the date formats AssertJ will use in date assertions in addition the default ones.
additionalDateFormats
()

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

public void
apply()

Applies this configuration to AssertJ.

public void
applyAndDisplay()

Applies this configuration to AssertJ and prints it.

public boolean

Returns:

whether the extractor considers bare-named property methods like String name().
bareNamePropertyExtractionEnabled
()

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

public boolean

Returns:

whether private fields comparison is enabled.
comparingPrivateFieldsEnabled
()

Returns whether private fields comparison is enabled.

public String
private String
describe(DateFormat dateFormat)

private String
public Consumer<Description>
public boolean

Returns:

whether private fields comparison is enabled.
extractingPrivateFieldsEnabled
()

Returns whether private fields comparison is enabled.

pack-priv boolean
public boolean

Returns:

whether AssertJ will use lenient parsing mode for default date formats.
lenientDateParsingEnabled
()

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

public int

Returns:

the maximum length for an iterable/array to be displayed on one line.
maxElementsForPrinting
()

Returns how many elements at most from one iterable/array/map will be displayed in error messages.

public int

Returns:

the maximum length for an iterable/array to be displayed on one line.
maxLengthForSingleLineDescription
()

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

public int

Returns:

the maximum number of lines for a stacktrace to be displayed on one throw.
maxStackTraceElementsDisplayed
()

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

public PreferredAssumptionException

Returns:

the assumption exception to throw.
preferredAssumptionException
()

Returns which exception is thrown if an assumption is not met.

public boolean
public boolean

Returns:

whether AssertJ related elements are removed from assertion errors stack trace.
removeAssertJRelatedElementsFromStackTraceEnabled
()

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

public Representation

Returns:

the default Representation that is used within AssertJ.
representation
()

public void
setAdditionalDateFormats(List<DateFormat>
the date formats AssertJ will use in date assertions in addition the default ones.
additionalDateFormats
)

Returns the additional date formats AssertJ will use in date assertions.

public void
setBareNamePropertyExtraction(boolean
whether the extractor considers bare-named property methods.
bareNamePropertyExtraction
)

Sets whether the extractor considers bare-named property methods like String name().

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

Sets whether private fields comparison is enabled.

public void
setDefaults()

Set all configuration settings to their default values again.

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

Sets whether private fields comparison is enabled.

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

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

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

Sets the threshold for how many elements at most from one iterable/array/map will be displaye in error messages.

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

Sets the maximum length for an iterable/array to be displayed on one line.

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

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

public void
setPreferredAssumptionException(PreferredAssumptionException
the preferred exception to use with Assumptions.
preferredAssumptionException
)

Sets which exception is thrown if an assumption is not met.

public void
setPrintAssertionsDescriptionEnabled(boolean printAssertionsDescription)

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

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

additionalDateFormatsback to summary
private List<DateFormat> additionalDateFormats
ALLOW_COMPARING_PRIVATE_FIELDSback to summary
public static final boolean ALLOW_COMPARING_PRIVATE_FIELDS
ALLOW_EXTRACTING_PRIVATE_FIELDSback to summary
public static final boolean ALLOW_EXTRACTING_PRIVATE_FIELDS
BARE_NAME_PROPERTY_EXTRACTION_ENABLEDback to summary
public static final boolean BARE_NAME_PROPERTY_EXTRACTION_ENABLED
bareNamePropertyExtractionback to summary
private boolean bareNamePropertyExtraction
comparingPrivateFieldsback to summary
private boolean comparingPrivateFields
DEFAULT_CONFIGURATIONback to summary
public static final Configuration DEFAULT_CONFIGURATION
descriptionConsumerback to summary
private Consumer<Description> descriptionConsumer
extractingPrivateFieldsback to summary
private boolean extractingPrivateFields
LENIENT_DATE_PARSINGback to summary
public static final boolean LENIENT_DATE_PARSING
lenientDateParsingback to summary
private boolean lenientDateParsing
MAX_ELEMENTS_FOR_PRINTINGback to summary
public static final int MAX_ELEMENTS_FOR_PRINTING
MAX_INDICES_FOR_PRINTINGback to summary
public static final int MAX_INDICES_FOR_PRINTING
MAX_LENGTH_FOR_SINGLE_LINE_DESCRIPTIONback to summary
public static final int MAX_LENGTH_FOR_SINGLE_LINE_DESCRIPTION
MAX_STACKTRACE_ELEMENTS_DISPLAYEDback to summary
public static final int MAX_STACKTRACE_ELEMENTS_DISPLAYED
maxElementsForPrintingback to summary
private int maxElementsForPrinting
maxLengthForSingleLineDescriptionback to summary
private int maxLengthForSingleLineDescription
maxStackTraceElementsDisplayedback to summary
private int maxStackTraceElementsDisplayed
PREFERRED_ASSUMPTION_EXCEPTIONback to summary
public static final PreferredAssumptionException PREFERRED_ASSUMPTION_EXCEPTION
preferredAssumptionExceptionback to summary
private PreferredAssumptionException preferredAssumptionException
printAssertionsDescriptionback to summary
private boolean printAssertionsDescription
removeAssertJRelatedElementsFromStackTraceback to summary
private boolean removeAssertJRelatedElementsFromStackTrace

Constructor Detail

Configurationback to summary
public Configuration()

Method Detail

addAdditionalDateFormatsback to summary
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:DateFormat[]

the date formats AssertJ will use in date assertions in addition the default ones.

additionalDateFormatsback to summary
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:List<DateFormat>

the date formats AssertJ will use in date assertions in addition the default ones.

applyback to summary
public void apply()

Applies this configuration to AssertJ.

applyAndDisplayback to summary
public void applyAndDisplay()

Applies this configuration to AssertJ and prints it.

bareNamePropertyExtractionEnabledback to summary
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:boolean

whether the extractor considers bare-named property methods like String name().

comparingPrivateFieldsEnabledback to summary
public boolean comparingPrivateFieldsEnabled()

Returns whether private fields comparison is enabled. Default is true.

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

Returns:boolean

whether private fields comparison is enabled.

describeback to summary
public String describe()
describeback to summary
private String describe(DateFormat dateFormat)
describeAdditionalDateFormatsback to summary
private String describeAdditionalDateFormats()
descriptionConsumerback to summary
public Consumer<Description> descriptionConsumer()
extractingPrivateFieldsEnabledback to summary
public boolean extractingPrivateFieldsEnabled()

Returns whether private fields comparison is enabled. Default is true.

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

Returns:boolean

whether private fields comparison is enabled.

hasCustomRepresentationback to summary
pack-priv boolean hasCustomRepresentation()
lenientDateParsingEnabledback to summary
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:boolean

whether AssertJ will use lenient parsing mode for default date formats.

maxElementsForPrintingback to summary
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:int

the maximum length for an iterable/array to be displayed on one line.

maxLengthForSingleLineDescriptionback to summary
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:int

the maximum length for an iterable/array to be displayed on one line.

maxStackTraceElementsDisplayedback to summary
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:int

the maximum number of lines for a stacktrace to be displayed on one throw.

preferredAssumptionExceptionback to summary
public PreferredAssumptionException preferredAssumptionException()

Returns which exception is thrown if an assumption is not met.

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

Returns:PreferredAssumptionException

the assumption exception to throw.

Since
3.21.0
printAssertionsDescriptionback to summary
public boolean printAssertionsDescription()
removeAssertJRelatedElementsFromStackTraceEnabledback to summary
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:boolean

whether AssertJ related elements are removed from assertion errors stack trace.

representationback to summary
public Representation representation()
Returns:Representation

the default Representation that is used within AssertJ.

setAdditionalDateFormatsback to summary
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:List<DateFormat>

the date formats AssertJ will use in date assertions in addition the default ones.

setBareNamePropertyExtractionback to summary
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:boolean

whether the extractor considers bare-named property methods.

setComparingPrivateFieldsback to summary
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:boolean

whether private fields comparison is enabled.

setDefaultsback to summary
public void setDefaults()

Set all configuration settings to their default values again.

setDescriptionConsumerback to summary
public void setDescriptionConsumer(Consumer<Description> descriptionConsumer)
setExtractingPrivateFieldsback to summary
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:boolean

whether private fields comparison is enabled.

setLenientDateParsingback to summary
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:boolean

whether AssertJ will use lenient parsing mode for default date formats.

setMaxElementsForPrintingback to summary
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:int

the maximum length for an iterable/array to be displayed on one line.

setMaxLengthForSingleLineDescriptionback to summary
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:int

the maximum length for an iterable/array to be displayed on one line.

setMaxStackTraceElementsDisplayedback to summary
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:int

the maximum number of lines for a stacktrace to be displayed on one throw.

setPreferredAssumptionExceptionback to summary
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:PreferredAssumptionException

the preferred exception to use with Assumptions.

Since
3.21.0
setPrintAssertionsDescriptionEnabledback to summary
public void setPrintAssertionsDescriptionEnabled(boolean printAssertionsDescription)
setRemoveAssertJRelatedElementsFromStackTraceback to summary
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:boolean

whether AssertJ related elements are removed from assertion errors stack trace.