Package org.assertj.core.api
Class WritableAssertionInfo
- java.lang.Object
-
- org.assertj.core.api.WritableAssertionInfo
-
- All Implemented Interfaces:
AssertionInfo
public class WritableAssertionInfo extends Object implements AssertionInfo
Writable information about an assertion.- Author:
- Alex Ruiz, Yvonne Wang
-
-
Field Summary
Fields Modifier and Type Field Description private Description
description
private static String
EMPTY_STRING
private String
overridingErrorMessage
private Supplier<String>
overridingErrorMessageSupplier
private Representation
representation
-
Constructor Summary
Constructors Constructor Description WritableAssertionInfo()
WritableAssertionInfo(Representation customRepresentation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Description
description()
Returns the description of an assertion.void
description(String newDescription, Object... args)
Sets the description of an assertion, if given null an emptyDescription
is set.void
description(Description newDescription)
Sets the description of an assertion, if given null an emptyDescription
is set.String
descriptionText()
Returns the text of this object's description, it is an empty String if no description was set.boolean
hasDescription()
Returns whether the text of this object's description was set.static String
mostRelevantDescriptionIn(WritableAssertionInfo info, String newDescription)
String
overridingErrorMessage()
Returns the message that, if specified, will replace the default message of an assertion failure.void
overridingErrorMessage(String newErrorMessage)
Sets the message that will replace the default message of an assertion failure.void
overridingErrorMessage(Supplier<String> supplier)
Sets the lazy fail message that will replace the default message of an assertion failure by using a supplier.Representation
representation()
String
toString()
void
useBinaryRepresentation()
void
useHexadecimalRepresentation()
void
useRepresentation(Representation newRepresentation)
void
useUnicodeRepresentation()
-
-
-
Field Detail
-
EMPTY_STRING
private static final String EMPTY_STRING
- See Also:
- Constant Field Values
-
overridingErrorMessage
private String overridingErrorMessage
-
description
private Description description
-
representation
private Representation representation
-
-
Constructor Detail
-
WritableAssertionInfo
public WritableAssertionInfo(Representation customRepresentation)
-
WritableAssertionInfo
public WritableAssertionInfo()
-
-
Method Detail
-
overridingErrorMessage
public String overridingErrorMessage()
Returns the message that, if specified, will replace the default message of an assertion failure.- Specified by:
overridingErrorMessage
in interfaceAssertionInfo
- Returns:
- the message that, if specified, will replace the default message of an assertion failure.
-
overridingErrorMessage
public void overridingErrorMessage(String newErrorMessage)
Sets the message that will replace the default message of an assertion failure.- Parameters:
newErrorMessage
- the new message. It can benull
.- Throws:
IllegalStateException
- if the message has already been overridden withoverridingErrorMessage(Supplier)
.
-
overridingErrorMessage
public void overridingErrorMessage(Supplier<String> supplier)
Sets the lazy fail message that will replace the default message of an assertion failure by using a supplier.- Parameters:
supplier
- the new message by a supplier. It can benull
.- Throws:
IllegalStateException
- if the message has already been overridden withoverridingErrorMessage(String)
.
-
description
public Description description()
Returns the description of an assertion.- Specified by:
description
in interfaceAssertionInfo
- Returns:
- the description of an assertion.
-
descriptionText
public String descriptionText()
Returns the text of this object's description, it is an empty String if no description was set.- Returns:
- the text of this object's description.
-
hasDescription
public boolean hasDescription()
Returns whether the text of this object's description was set.- Returns:
- whether the text of this object's description was set.
-
description
public void description(String newDescription, Object... args)
Sets the description of an assertion, if given null an emptyDescription
is set.- Parameters:
newDescription
- the new description.args
- ifnewDescription
is a format String,args
is argument ofString.format(String, Object...)
- See Also:
description(Description)
-
description
public void description(Description newDescription)
Sets the description of an assertion, if given null an emptyDescription
is set.To remove or clear the description, pass a
as argument.EmptyTextDescription
- Parameters:
newDescription
- the new description.
-
representation
public Representation representation()
- Specified by:
representation
in interfaceAssertionInfo
-
useHexadecimalRepresentation
public void useHexadecimalRepresentation()
-
useUnicodeRepresentation
public void useUnicodeRepresentation()
-
useBinaryRepresentation
public void useBinaryRepresentation()
-
useRepresentation
public void useRepresentation(Representation newRepresentation)
-
mostRelevantDescriptionIn
public static String mostRelevantDescriptionIn(WritableAssertionInfo info, String newDescription)
-
-