Package org.assertj.core.internal
Class Strings
java.lang.Object
org.assertj.core.internal.Strings
Reusable assertions for
CharSequence
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ComparisonStrategy
private static final String
(package private) Failures
private static final Strings
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
areEqualIgnoringCase
(CharSequence actual, CharSequence expected) private boolean
areEqualIgnoringWhitespace
(CharSequence actual, CharSequence expected) void
assertBlank
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
isNull
, empty or consists of one or more whitespace characters.void
assertContains
(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies that the givenCharSequence
contains the given strings.void
assertContainsAnyOf
(AssertionInfo info, CharSequence actual, CharSequence[] values) void
assertContainsIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence sequence) Verifies that the givenCharSequence
contains the given sequence, ignoring case considerations.void
assertContainsIgnoringNewLines
(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies the givenCharSequence
has the strings, ignoring newlines.void
assertContainsIgnoringWhitespaces
(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies that the givenCharSequence
contains the given strings, ignoring whitespaces.void
assertContainsOnlyDigits
(AssertionInfo info, CharSequence actual) Verifies that the givenCharSequence
contains only digits.void
assertContainsOnlyOnce
(AssertionInfo info, CharSequence actual, CharSequence sequence) Verifies that actualCharSequence
s contains only once the given sequence.void
assertContainsOnlyWhitespaces
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
consists of one or more whitespace characters.void
assertContainsPattern
(AssertionInfo info, CharSequence actual, CharSequence regex) Verifies that the givenCharSequence
contains the given regular expression.void
assertContainsPattern
(AssertionInfo info, CharSequence actual, Matcher matcher) Verifies that the givenCharSequence
contains the given regular expression.void
assertContainsPattern
(AssertionInfo info, CharSequence actual, Pattern pattern) Verifies that the givenCharSequence
contains the given regular expression.void
assertContainsSequence
(AssertionInfo info, CharSequence actual, CharSequence[] sequence) Verifies that the given charSequence contains the given sequence of charSequence, without any other charSequences between them.void
assertContainsSubsequence
(AssertionInfo info, CharSequence actual, CharSequence[] subsequence) Verifies that the actualCharSequence
contains all the given values in the given order (possibly with other values between them).void
assertContainsWhitespaces
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
contains one or more whitespace characters.void
assertDoesNotContain
(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies that the givenCharSequence
does not contain any one of the given values.void
assertDoesNotContainAnyWhitespaces
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
isNull
, empty or contains only non-whitespace characters.void
assertDoesNotContainIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies that the givenCharSequence
does not contain any one of the given values, ignoring case considerations.void
assertDoesNotContainOnlyWhitespaces
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
isNull
, empty or contains at least one non-whitespace character.void
assertDoesNotContainPattern
(AssertionInfo info, CharSequence actual, CharSequence regex) Verifies that the givenCharSequence
does not contain the given regular expression.void
assertDoesNotContainPattern
(AssertionInfo info, CharSequence actual, Pattern pattern) Verifies that the givenCharSequence
does not contain the given regular expression.void
assertDoesNotEndWith
(AssertionInfo info, CharSequence actual, CharSequence suffix) Verifies that the givenCharSequence
does not end with the given suffix.void
assertDoesNotEndWithIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence suffix) Verifies that the givenCharSequence
does not end with the given suffix, ignoring case considerations.void
assertDoesNotMatch
(AssertionInfo info, CharSequence actual, CharSequence regex) Verifies that the givenCharSequence
does not match the given regular expression.void
assertDoesNotMatch
(AssertionInfo info, CharSequence actual, Pattern pattern) Verifies that the givenCharSequence
does not match the given regular expression.void
assertDoesNotStartWith
(AssertionInfo info, CharSequence actual, CharSequence prefix) Verifies that the givenCharSequence
does not start with the given prefix.void
assertDoesNotStartWithIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence prefix) Verifies that the givenCharSequence
does not start with the given prefix, ignoring case considerations.void
assertEmpty
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
is empty.void
assertEndsWith
(AssertionInfo info, CharSequence actual, CharSequence suffix) Verifies that the givenCharSequence
ends with the given suffix.void
assertEndsWithIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence suffix) Verifies that the givenCharSequence
ends with the given suffix, ignoring case considerations.void
assertEqualsIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, ignoring case considerations.void
assertEqualsIgnoringWhitespace
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, ignoring any differences in whitespace.void
assertEqualsNormalizingPunctuationAndWhitespace
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, after the punctuation of both strings have been normalized.void
assertEqualsNormalizingWhitespace
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, after the whitespace of both strings has been normalized.void
assertEqualsToNormalizingUnicode
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, on their canonical form relying onNormalizer
.void
assertHasLineCount
(AssertionInfo info, CharSequence actual, int expectedLineCount) Asserts that the line count of the givenCharSequence
is equal to the expected one.void
assertHasSameSizeAs
(AssertionInfo info, CharSequence actual, CharSequence other) void
assertHasSameSizeAs
(AssertionInfo info, CharSequence actual, Iterable<?> other) Asserts that the number of entries in the givenCharSequence
has the same size as the otherIterable
.void
assertHasSameSizeAs
(AssertionInfo info, CharSequence actual, Object array) Asserts that the number of entries in the givenCharSequence
has the same size as the other array.void
assertHasSize
(AssertionInfo info, CharSequence actual, int expectedSize) Asserts that the size of the givenCharSequence
is equal to the expected one.void
assertHasSizeBetween
(AssertionInfo info, CharSequence actual, int lowerBoundary, int higherBoundary) Asserts that the size of the givenCharSequence
is between the given lower and higher boundary (inclusive).void
assertHasSizeGreaterThan
(AssertionInfo info, CharSequence actual, int expectedMinSizeExcluded) Asserts that the size of the givenCharSequence
is greater than the expected sizevoid
assertHasSizeGreaterThanOrEqualTo
(AssertionInfo info, CharSequence actual, int expectedMinSizeIncluded) Asserts that the size of the givenCharSequence
is greater than or equal to the expected sizevoid
assertHasSizeLessThan
(AssertionInfo info, CharSequence actual, int expectedMaxSizeExcluded) Asserts that the size of the givenCharSequence
is less than the expected sizevoid
assertHasSizeLessThanOrEqualTo
(AssertionInfo info, CharSequence actual, int expectedMaxSizeIncluded) Asserts that the size of the givenCharSequence
is less than or equal to the expected sizevoid
assertIsBase64
(AssertionInfo info, String actual) Verifies that actual is a valid Base64 encoded string.void
assertIsEqualToIgnoringNewLines
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that actual is equal to expected ignoring new linesvoid
assertIsEqualToNormalizingNewlines
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, normalizing newlines.void
assertIsSubstringOf
(AssertionInfo info, CharSequence actual, CharSequence sequence) void
assertJavaBlank
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
consists of one or more whitespace characters according toCharacter.isWhitespace(char)
.void
assertLowerCase
(AssertionInfo info, CharSequence actual) void
assertMatches
(AssertionInfo info, CharSequence actual, CharSequence regex) Verifies that the givenCharSequence
matches the given regular expression.void
assertMatches
(AssertionInfo info, CharSequence actual, Matcher matcher) Verifies that the givenCharSequence
matches the given regular expression.void
assertMatches
(AssertionInfo info, CharSequence actual, Pattern pattern) Verifies that the givenCharSequence
matches the given regular expression.void
assertMixedCase
(AssertionInfo info, CharSequence actual) void
assertNotBlank
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
contains at least one non-whitespace character.void
assertNotEmpty
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
is not empty.void
assertNotEqualsIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are not equal, ignoring case considerations.void
assertNotEqualsIgnoringWhitespace
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are not equal, ignoring any differences in whitespace.void
assertNotEqualsNormalizingWhitespace
(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are not equal, after the whitespace of both strings has been normalized.void
assertNotJavaBlank
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
isNull
, empty or contains at least one non-whitespace character according toCharacter.isWhitespace(char)
.private void
assertNotNull
(AssertionInfo info, CharSequence actual) void
assertNullOrEmpty
(AssertionInfo info, CharSequence actual) Asserts that the givenCharSequence
isnull
or empty.void
assertStartsWith
(AssertionInfo info, CharSequence actual, CharSequence prefix) Verifies that the givenCharSequence
starts with the given prefix.void
assertStartsWithIgnoringCase
(AssertionInfo info, CharSequence actual, CharSequence prefix) Verifies that the givenCharSequence
starts with the given prefix, ignoring case considerations.void
assertUpperCase
(AssertionInfo info, CharSequence actual) void
assertVisible
(AssertionInfo info, CharSequence actual) void
assertXmlEqualsTo
(AssertionInfo info, CharSequence actualXml, CharSequence expectedXml) private void
private static void
checkCharSequenceIsNotNull
(CharSequence sequence) private void
checkIsNotEmpty
(CharSequence... values) private void
checkIsNotNull
(CharSequence... values) private void
checkIsNotNull
(Matcher matcher) private void
checkIsNotNull
(Pattern pattern) private void
checkRegexIsNotNull
(CharSequence regex) private boolean
containsIgnoreCase
(CharSequence actual, CharSequence sequence) private boolean
private boolean
containsOnlyWhitespaces
(CharSequence actual) private boolean
containsWhitespaces
(CharSequence actual) private int
countOccurrences
(CharSequence sequenceToSearch, CharSequence actual) Count occurrences of sequenceToSearch in actualCharSequence
.private void
doCommonCheckForCharSequence
(AssertionInfo info, CharSequence actual, CharSequence[] sequence) private boolean
endsWith
(CharSequence actual, CharSequence suffix, boolean ignoreCase) private static void
failIfPrefixIsNull
(CharSequence prefix) private static void
failIfSuffixIsNull
(CharSequence suffix) Comparator
<?> private static boolean
private int
indexOf
(String string, CharSequence toFind) static Strings
instance()
Returns the singleton instance of this class based onStandardComparisonStrategy
.private boolean
isBlank
(CharSequence actual) private boolean
isJavaBlank
(CharSequence actual) private boolean
isLowerCase
(CharSequence actual) private boolean
isNullOrEmpty
(CharSequence actual) private boolean
isUpperCase
(CharSequence actual) private static String
normalizeNewlines
(CharSequence actual) private static String
normalizeWhitespace
(CharSequence toNormalize) private static String
normalizeWhitespaceAndPunctuation
(CharSequence toNormalize) private NullPointerException
private static String
removeAllWhitespaces
(CharSequence toBeStripped) private static String
removeNewLines
(CharSequence text) private String
removeUpTo
(String string, CharSequence toRemove) private boolean
startsWith
(CharSequence actual, CharSequence prefix, boolean ignoreCase) private boolean
private boolean
stringContains
(CharSequence actual, CharSequence sequence)
-
Field Details
-
EMPTY_STRING
- See Also:
-
INSTANCE
-
PUNCTUATION_REGEX
- See Also:
-
comparisonStrategy
-
failures
Failures failures
-
-
Constructor Details
-
Strings
Strings() -
Strings
-
-
Method Details
-
instance
Returns the singleton instance of this class based onStandardComparisonStrategy
.- Returns:
- the singleton instance of this class based on
StandardComparisonStrategy
.
-
getComparator
-
assertNullOrEmpty
Asserts that the givenCharSequence
isnull
or empty.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is notnull
*and* it is not empty.
-
assertEmpty
Asserts that the givenCharSequence
is empty.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
is not empty.
-
assertNotEmpty
Asserts that the givenCharSequence
is not empty.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
is empty.
-
hasContent
-
assertBlank
Asserts that the givenCharSequence
isNull
, empty or consists of one or more whitespace characters.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is not blank.
-
assertNotBlank
Asserts that the givenCharSequence
contains at least one non-whitespace character.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is blank.
-
isBlank
-
containsWhitespaces
-
containsOnlyWhitespaces
-
isNullOrEmpty
-
containsOneOrMoreWhitespaces
-
strictlyContainsWhitespaces
-
assertContainsWhitespaces
Asserts that the givenCharSequence
contains one or more whitespace characters.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
does not contain any whitespace characters.
-
assertContainsOnlyWhitespaces
Asserts that the givenCharSequence
consists of one or more whitespace characters.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is not blank.
-
assertDoesNotContainAnyWhitespaces
Asserts that the givenCharSequence
isNull
, empty or contains only non-whitespace characters.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
contains one or more whitespace characters.
-
assertDoesNotContainOnlyWhitespaces
Asserts that the givenCharSequence
isNull
, empty or contains at least one non-whitespace character.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is blank.
-
assertJavaBlank
Asserts that the givenCharSequence
consists of one or more whitespace characters according toCharacter.isWhitespace(char)
.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is not blank.
-
assertNotJavaBlank
Asserts that the givenCharSequence
isNull
, empty or contains at least one non-whitespace character according toCharacter.isWhitespace(char)
.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
is blank.
-
isJavaBlank
-
assertHasSize
Asserts that the size of the givenCharSequence
is equal to the expected one.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.expectedSize
- the expected size ofactual
.- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the size of the givenCharSequence
is different than the expected one.
-
assertHasSizeLessThan
public void assertHasSizeLessThan(AssertionInfo info, CharSequence actual, int expectedMaxSizeExcluded) Asserts that the size of the givenCharSequence
is less than the expected size- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.expectedMaxSizeExcluded
- the expected max size ofactual
- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the size of the givenCharSequence
is equal to or greater than the expected max size
-
assertHasSizeLessThanOrEqualTo
public void assertHasSizeLessThanOrEqualTo(AssertionInfo info, CharSequence actual, int expectedMaxSizeIncluded) Asserts that the size of the givenCharSequence
is less than or equal to the expected size- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.expectedMaxSizeIncluded
- the expected max size ofactual
- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the size of the givenCharSequence
is greater than the expected max size
-
assertHasSizeGreaterThan
public void assertHasSizeGreaterThan(AssertionInfo info, CharSequence actual, int expectedMinSizeExcluded) Asserts that the size of the givenCharSequence
is greater than the expected size- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.expectedMinSizeExcluded
- the expected min size ofactual
- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the size of the givenCharSequence
is equal to or less than the expected max size
-
assertHasSizeGreaterThanOrEqualTo
public void assertHasSizeGreaterThanOrEqualTo(AssertionInfo info, CharSequence actual, int expectedMinSizeIncluded) Asserts that the size of the givenCharSequence
is greater than or equal to the expected size- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.expectedMinSizeIncluded
- the expected min size ofactual
- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the size of the givenCharSequence
is greater than the expected max size
-
assertHasSizeBetween
public void assertHasSizeBetween(AssertionInfo info, CharSequence actual, int lowerBoundary, int higherBoundary) Asserts that the size of the givenCharSequence
is between the given lower and higher boundary (inclusive).- Parameters:
info
- contains information about the assertion.actual
- the givenIterable
.lowerBoundary
- the lower boundary compared to which actual size should be greater than or equal to.higherBoundary
- the higher boundary compared to which actual size should be less than or equal to.- Throws:
AssertionError
- if the given array isnull
.AssertionError
- if the number of elements in the given array is not between the boundaries.
-
assertHasLineCount
Asserts that the line count of the givenCharSequence
is equal to the expected one.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.expectedLineCount
- the expected line count ofactual
.- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the line count of the givenCharSequence
is different than the expected one.
-
assertHasSameSizeAs
Asserts that the number of entries in the givenCharSequence
has the same size as the otherIterable
.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.other
- the group to compare- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenIterable
isnull
.AssertionError
- if the number of entries in the givenCharSequence
does not have the same size.
-
assertHasSameSizeAs
Asserts that the number of entries in the givenCharSequence
has the same size as the other array.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.array
- the array to compare- Throws:
AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the number of entries in the givenCharSequence
does not have the same size.
-
assertHasSameSizeAs
-
assertContains
Verifies that the givenCharSequence
contains the given strings.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.values
- the values to look for.- Throws:
NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given values is empty.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not contain the given sequence.
-
assertContainsAnyOf
-
assertContainsOnlyDigits
Verifies that the givenCharSequence
contains only digits.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.- Throws:
NullPointerException
- ifactual
isnull
.AssertionError
- ifactual
contains non-digit characters or contains no digits at all.
-
checkIsNotNull
-
checkIsNotEmpty
-
stringContains
-
assertContainsIgnoringCase
public void assertContainsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence sequence) Verifies that the givenCharSequence
contains the given sequence, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.sequence
- the sequence to search for.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not contain the given sequence.
-
containsIgnoreCase
-
assertContainsIgnoringNewLines
public void assertContainsIgnoringNewLines(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies the givenCharSequence
has the strings, ignoring newlines.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.values
- the values to look for.- Throws:
NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given values is empty.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if actualCharSequence
doesn't have sequence
-
assertContainsIgnoringWhitespaces
public void assertContainsIgnoringWhitespaces(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies that the givenCharSequence
contains the given strings, ignoring whitespaces.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.values
- the values to look for.- Throws:
NullPointerException
- if the given sequence isnull
.IllegalArgumentException
- if the given values is empty.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not contain the given sequence.
-
assertDoesNotContainIgnoringCase
public void assertDoesNotContainIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence... values) Verifies that the givenCharSequence
does not contain any one of the given values, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.values
- the sequences to search for.- Throws:
NullPointerException
- if the given list of values isnull
.NullPointerException
- if any one of the given values isnull
.IllegalArgumentException
- if the list of given values is empty.AssertionError
- if the actualCharSequence
isnull
.AssertionError
- if the actualCharSequence
contains any one of the given values, ignoring case considerations.
-
assertDoesNotContain
Verifies that the givenCharSequence
does not contain any one of the given values.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.values
- the values to search for.- Throws:
NullPointerException
- if the given list of values isnull
.NullPointerException
- if any one of the given values isnull
.IllegalArgumentException
- if the list of given values is empty.AssertionError
- if the actualCharSequence
isnull
.AssertionError
- if the actualCharSequence
contains any one of the given values.
-
checkCharSequenceIsNotNull
-
assertEqualsIgnoringCase
public void assertEqualsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are not equal.
-
assertNotEqualsIgnoringCase
public void assertNotEqualsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are not equal, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are equal ignoring case considerations.
-
areEqualIgnoringCase
-
assertIsEqualToNormalizingNewlines
public void assertIsEqualToNormalizingNewlines(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, normalizing newlines.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
(newlines will be normalized).expected
- the expectedCharSequence
(newlines will be normalized)..- Throws:
AssertionError
- if the givenCharSequence
s are equal after normalizing newlines.
-
normalizeNewlines
-
assertEqualsIgnoringWhitespace
public void assertEqualsIgnoringWhitespace(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, ignoring any differences in whitespace.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are not equal.
-
assertNotEqualsIgnoringWhitespace
public void assertNotEqualsIgnoringWhitespace(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are not equal, ignoring any differences in whitespace.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are equal.
-
areEqualIgnoringWhitespace
-
removeAllWhitespaces
-
assertEqualsNormalizingWhitespace
public void assertEqualsNormalizingWhitespace(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, after the whitespace of both strings has been normalized.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are not equal.- Since:
- 2.8.0 / 3.8.0
-
assertNotEqualsNormalizingWhitespace
public void assertNotEqualsNormalizingWhitespace(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are not equal, after the whitespace of both strings has been normalized.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are equal.- Since:
- 2.8.0 / 3.8.0
-
normalizeWhitespace
-
assertEqualsNormalizingPunctuationAndWhitespace
public void assertEqualsNormalizingPunctuationAndWhitespace(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, after the punctuation of both strings have been normalized.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are not equal.- Since:
- 3.16.0
-
normalizeWhitespaceAndPunctuation
-
assertEqualsToNormalizingUnicode
public void assertEqualsToNormalizingUnicode(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that twoCharSequence
s are equal, on their canonical form relying onNormalizer
. UsingNormalizer.Form.NFC
for canonical decomposition, followed by canonical composition.Examples:
// assertion succeeds assertThat("Ä").isEqualToNormalizingUnicode("Ä"); // assertion fails assertThat("Ä").isEqualToNormalizingUnicode("Ä");
- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.expected
- the expectedCharSequence
.- Throws:
AssertionError
- if the givenCharSequence
s are not equal.- Since:
- 3.19.0
-
assertContainsOnlyOnce
Verifies that actualCharSequence
s contains only once the given sequence.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.sequence
- the givenCharSequence
.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not contains only once the givenCharSequence
.
-
countOccurrences
Count occurrences of sequenceToSearch in actualCharSequence
.- Parameters:
sequenceToSearch
- the sequence to search in in actualCharSequence
.actual
- theCharSequence
to search occurrences in.- Returns:
- the number of occurrences of sequenceToSearch in actual
CharSequence
.
-
assertStartsWith
Verifies that the givenCharSequence
starts with the given prefix.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.prefix
- the given prefix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not start with the given prefix.
-
assertStartsWithIgnoringCase
public void assertStartsWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence prefix) Verifies that the givenCharSequence
starts with the given prefix, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.prefix
- the given prefix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not start with the given prefix, ignoring case.- Since:
- 3.23.0
-
assertDoesNotStartWith
Verifies that the givenCharSequence
does not start with the given prefix.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.prefix
- the given prefix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
starts with the given prefix.
-
assertDoesNotStartWithIgnoringCase
public void assertDoesNotStartWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence prefix) Verifies that the givenCharSequence
does not start with the given prefix, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.prefix
- the given prefix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
starts with the given prefix, ignoring case.- Since:
- 3.23.0
-
failIfPrefixIsNull
-
startsWith
-
assertEndsWith
Verifies that the givenCharSequence
ends with the given suffix.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.suffix
- the given suffix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not end with the given suffix.
-
assertEndsWithIgnoringCase
public void assertEndsWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence suffix) Verifies that the givenCharSequence
ends with the given suffix, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.suffix
- the given suffix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not end with the given suffix, ignoring case.- Since:
- 3.23.0
-
assertDoesNotEndWith
Verifies that the givenCharSequence
does not end with the given suffix.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.suffix
- the given suffix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
ends with the given suffix.
-
assertDoesNotEndWithIgnoringCase
public void assertDoesNotEndWithIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence suffix) Verifies that the givenCharSequence
does not end with the given suffix, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
.suffix
- the given suffix.- Throws:
NullPointerException
- if the given sequence isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
ends with the given suffix, ignoring case.- Since:
- 3.23.0
-
failIfSuffixIsNull
-
endsWith
-
assertMatches
Verifies that the givenCharSequence
matches the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.regex
- the regular expression to which the actualCharSequence
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not match the given regular expression.
-
assertDoesNotMatch
Verifies that the givenCharSequence
does not match the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.regex
- the regular expression to which the actualCharSequence
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
matches the given regular expression.
-
checkRegexIsNotNull
-
assertMatches
Verifies that the givenCharSequence
matches the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.pattern
- the regular expression to which the actualCharSequence
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
does not match the given regular expression.
-
assertMatches
Verifies that the givenCharSequence
matches the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.matcher
- the matcher to check for matching.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
does not match the given regular expression.
-
assertDoesNotMatch
Verifies that the givenCharSequence
does not match the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.pattern
- the regular expression to which the actualCharSequence
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenCharSequence
matches the given regular expression.
-
checkIsNotNull
-
patternToMatchIsNull
-
checkIsNotNull
-
assertNotNull
-
assertContainsSequence
public void assertContainsSequence(AssertionInfo info, CharSequence actual, CharSequence[] sequence) Verifies that the given charSequence contains the given sequence of charSequence, without any other charSequences between them.- Parameters:
info
- contains information about the assertion.actual
- the given charSequence.sequence
- the sequence of charSequence to look for.- Throws:
NullPointerException
- if the given sequence of charSequence isnull
.IllegalArgumentException
- if the given sequence of charSequence is empty.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
does not contain the given sequence of charSequence.
-
assertContainsSubsequence
public void assertContainsSubsequence(AssertionInfo info, CharSequence actual, CharSequence[] subsequence) Verifies that the actualCharSequence
contains all the given values in the given order (possibly with other values between them).- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.subsequence
- the Strings to look for, in order.- Throws:
AssertionError
- if the givenCharSequence
isnull
.NullPointerException
- if the given subsequence isnull
.IllegalArgumentException
- if the given subsequence is empty.AssertionError
- if the givenCharSequence
does not contain the given subsequence of charSequence.
-
removeUpTo
-
indexOf
-
assertXmlEqualsTo
-
assertIsSubstringOf
-
assertContainsPattern
Verifies that the givenCharSequence
contains the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.regex
- the regular expression to find in the actualCharSequence
.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not contain the given regular expression.
-
assertContainsPattern
Verifies that the givenCharSequence
contains the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.matcher
- the matcher for finding in the actualCharSequence
.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
does not contain the given regular expression.
-
assertContainsPattern
Verifies that the givenCharSequence
contains the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.pattern
- the regular expression to find in the actualCharSequence
.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
does not contain the given regular expression.
-
assertDoesNotContainPattern
public void assertDoesNotContainPattern(AssertionInfo info, CharSequence actual, CharSequence regex) Verifies that the givenCharSequence
does not contain the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.regex
- the regular expression to find in the actualCharSequence
.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the actualCharSequence
contains the given regular expression.
-
assertDoesNotContainPattern
Verifies that the givenCharSequence
does not contain the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenCharSequence
.pattern
- the regular expression to find in the actualCharSequence
.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenCharSequence
isnull
.AssertionError
- if the givenCharSequence
contains the given regular expression.
-
checkCharSequenceArrayDoesNotHaveNullElements
-
assertIsEqualToIgnoringNewLines
public void assertIsEqualToIgnoringNewLines(AssertionInfo info, CharSequence actual, CharSequence expected) Verifies that actual is equal to expected ignoring new lines- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
(new lines will be ignored).expected
- the expectedCharSequence
(new lines will be ignored).
-
assertLowerCase
-
isLowerCase
-
assertUpperCase
-
isUpperCase
-
assertMixedCase
-
assertIsBase64
Verifies that actual is a valid Base64 encoded string.- Parameters:
info
- contains information about the assertion.actual
- the actualCharSequence
(new lines will be ignored).- Throws:
AssertionError
- ifactual
isnull
.AssertionError
- ifactual
is not a valid Base64 encoded string.
-
removeNewLines
-
doCommonCheckForCharSequence
private void doCommonCheckForCharSequence(AssertionInfo info, CharSequence actual, CharSequence[] sequence) -
assertVisible
-