org.assertj.core.internal
Class Strings

java.lang.Object
  extended by org.assertj.core.internal.Strings

public class Strings
extends Object

Reusable assertions for CharSequences.

Author:
Alex Ruiz, Joel Costigliola, Nicolas François, Mikhail Mazursky

Constructor Summary
Strings(ComparisonStrategy comparisonStrategy)
           
 
Method Summary
 void assertContains(AssertionInfo info, CharSequence actual, CharSequence... values)
          Verifies that the given CharSequence contains the given strings.
 void assertContainsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence sequence)
          Verifies that the given CharSequence contains the given sequence, ignoring case considerations.
 void assertContainsOnlyOnce(AssertionInfo info, CharSequence actual, CharSequence sequence)
          Verifies that actual CharSequences contains only once the given sequence.
 void assertContainsSequence(AssertionInfo info, CharSequence actual, CharSequence[] values)
           
 void assertDoesNotContain(AssertionInfo info, CharSequence actual, CharSequence sequence)
          Verifies that the given CharSequence does not contain the given sequence.
 void assertDoesNotMatch(AssertionInfo info, CharSequence actual, CharSequence regex)
          Verifies that the given CharSequence does not match the given regular expression.
 void assertDoesNotMatch(AssertionInfo info, CharSequence actual, Pattern pattern)
          Verifies that the given CharSequence does not match the given regular expression.
 void assertEmpty(AssertionInfo info, CharSequence actual)
          Asserts that the given CharSequence is empty.
 void assertEndsWith(AssertionInfo info, CharSequence actual, CharSequence suffix)
          Verifies that the given CharSequence ends with the given suffix.
 void assertEqualsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence expected)
          Verifies that two CharSequences are equal, ignoring case considerations.
 void assertHasLineCount(AssertionInfo info, CharSequence actual, int expectedLineCount)
          Asserts that the line count of the given CharSequence 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 given CharSequence has the same size as the other Iterable.
 void assertHasSameSizeAs(AssertionInfo info, CharSequence actual, Object array)
          Asserts that the number of entries in the given CharSequence has the same size as the other array.
 void assertHasSize(AssertionInfo info, CharSequence actual, int expectedSize)
          Asserts that the size of the given CharSequence is equal to the expected one.
 void assertMatches(AssertionInfo info, CharSequence actual, CharSequence regex)
          Verifies that the given CharSequence matches the given regular expression.
 void assertMatches(AssertionInfo info, CharSequence actual, Pattern pattern)
          Verifies that the given CharSequence matches the given regular expression.
 void assertNotEmpty(AssertionInfo info, CharSequence actual)
          Asserts that the given CharSequence is not empty.
 void assertNullOrEmpty(AssertionInfo info, CharSequence actual)
          Asserts that the given CharSequence is null or empty.
 void assertStartsWith(AssertionInfo info, CharSequence actual, CharSequence prefix)
          Verifies that the given CharSequence starts with the given prefix.
 void assertXmlEqualsTo(AssertionInfo info, CharSequence actualXml, CharSequence expectedXml)
           
 Comparator<?> getComparator()
           
static Strings instance()
          Returns the singleton instance of this class based on StandardComparisonStrategy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strings

public Strings(ComparisonStrategy comparisonStrategy)
Method Detail

instance

public static Strings instance()
Returns the singleton instance of this class based on StandardComparisonStrategy.

Returns:
the singleton instance of this class based on StandardComparisonStrategy.

getComparator

public Comparator<?> getComparator()

assertNullOrEmpty

public void assertNullOrEmpty(AssertionInfo info,
                              CharSequence actual)
Asserts that the given CharSequence is null or empty.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
Throws:
AssertionError - if the given CharSequence is not null *and* it is not empty.

assertEmpty

public void assertEmpty(AssertionInfo info,
                        CharSequence actual)
Asserts that the given CharSequence is empty.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
Throws:
AssertionError - if the given CharSequence is null.
AssertionError - if the given CharSequence is not empty.

assertNotEmpty

public void assertNotEmpty(AssertionInfo info,
                           CharSequence actual)
Asserts that the given CharSequence is not empty.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
Throws:
AssertionError - if the given CharSequence is null.
AssertionError - if the given CharSequence is empty.

assertHasSize

public void assertHasSize(AssertionInfo info,
                          CharSequence actual,
                          int expectedSize)
Asserts that the size of the given CharSequence is equal to the expected one.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
expectedSize - the expected size of actual.
Throws:
AssertionError - if the given CharSequence is null.
AssertionError - if the size of the given CharSequence is different than the expected one.

assertHasLineCount

public void assertHasLineCount(AssertionInfo info,
                               CharSequence actual,
                               int expectedLineCount)
Asserts that the line count of the given CharSequence is equal to the expected one.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
expectedLineCount - the expected line count of actual.
Throws:
AssertionError - if the given CharSequence is null.
AssertionError - if the line count of the given CharSequence is different than the expected one.

assertHasSameSizeAs

public void assertHasSameSizeAs(AssertionInfo info,
                                CharSequence actual,
                                Iterable<?> other)
Asserts that the number of entries in the given CharSequence has the same size as the other Iterable.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
other - the group to compare
Throws:
AssertionError - if the given CharSequence is null.
AssertionError - if the given Iterable is null.
AssertionError - if the number of entries in the given CharSequence does not have the same size.

assertHasSameSizeAs

public void assertHasSameSizeAs(AssertionInfo info,
                                CharSequence actual,
                                Object array)
Asserts that the number of entries in the given CharSequence has the same size as the other array.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
array - the array to compare
Throws:
AssertionError - if the given CharSequence is null.
AssertionError - if the given array is null.
AssertionError - if the number of entries in the given CharSequence does not have the same size.

assertHasSameSizeAs

public void assertHasSameSizeAs(AssertionInfo info,
                                CharSequence actual,
                                CharSequence other)

assertContains

public void assertContains(AssertionInfo info,
                           CharSequence actual,
                           CharSequence... values)
Verifies that the given CharSequence contains the given strings.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
values - the values to look for.
Throws:
NullPointerException - if the given sequence is null.
IllegalArgumentException - if the given values is empty.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence does not contain the given sequence.

assertContainsIgnoringCase

public void assertContainsIgnoringCase(AssertionInfo info,
                                       CharSequence actual,
                                       CharSequence sequence)
Verifies that the given CharSequence contains the given sequence, ignoring case considerations.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
sequence - the sequence to search for.
Throws:
NullPointerException - if the given sequence is null.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence does not contain the given sequence.

assertDoesNotContain

public void assertDoesNotContain(AssertionInfo info,
                                 CharSequence actual,
                                 CharSequence sequence)
Verifies that the given CharSequence does not contain the given sequence.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
sequence - the sequence to search for.
Throws:
NullPointerException - if the given sequence is null.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence contains the given sequence.

assertEqualsIgnoringCase

public void assertEqualsIgnoringCase(AssertionInfo info,
                                     CharSequence actual,
                                     CharSequence expected)
Verifies that two CharSequences are equal, ignoring case considerations.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
expected - the expected CharSequence.
Throws:
AssertionError - if the given CharSequences are not equal.

assertContainsOnlyOnce

public void assertContainsOnlyOnce(AssertionInfo info,
                                   CharSequence actual,
                                   CharSequence sequence)
Verifies that actual CharSequences contains only once the given sequence.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
sequence - the given CharSequence.
Throws:
NullPointerException - if the given sequence is null.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence does not contains only once the given CharSequence.

assertStartsWith

public void assertStartsWith(AssertionInfo info,
                             CharSequence actual,
                             CharSequence prefix)
Verifies that the given CharSequence starts with the given prefix.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
prefix - the given prefix.
Throws:
NullPointerException - if the given sequence is null.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence does not start with the given prefix.

assertEndsWith

public void assertEndsWith(AssertionInfo info,
                           CharSequence actual,
                           CharSequence suffix)
Verifies that the given CharSequence ends with the given suffix.

Parameters:
info - contains information about the assertion.
actual - the actual CharSequence.
suffix - the given suffix.
Throws:
NullPointerException - if the given sequence is null.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence does not end with the given suffix.

assertMatches

public void assertMatches(AssertionInfo info,
                          CharSequence actual,
                          CharSequence regex)
Verifies that the given CharSequence matches the given regular expression.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
regex - the regular expression to which the actual CharSequence is to be matched.
Throws:
NullPointerException - if the given pattern is null.
PatternSyntaxException - if the regular expression's syntax is invalid.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence does not match the given regular expression.

assertDoesNotMatch

public void assertDoesNotMatch(AssertionInfo info,
                               CharSequence actual,
                               CharSequence regex)
Verifies that the given CharSequence does not match the given regular expression.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
regex - the regular expression to which the actual CharSequence is to be matched.
Throws:
NullPointerException - if the given pattern is null.
PatternSyntaxException - if the regular expression's syntax is invalid.
AssertionError - if the given CharSequence is null.
AssertionError - if the actual CharSequence matches the given regular expression.

assertMatches

public void assertMatches(AssertionInfo info,
                          CharSequence actual,
                          Pattern pattern)
Verifies that the given CharSequence matches the given regular expression.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
pattern - the regular expression to which the actual CharSequence is to be matched.
Throws:
NullPointerException - if the given pattern is null.
AssertionError - if the given CharSequence is null.
AssertionError - if the given CharSequence does not match the given regular expression.

assertDoesNotMatch

public void assertDoesNotMatch(AssertionInfo info,
                               CharSequence actual,
                               Pattern pattern)
Verifies that the given CharSequence does not match the given regular expression.

Parameters:
info - contains information about the assertion.
actual - the given CharSequence.
pattern - the regular expression to which the actual CharSequence is to be matched.
Throws:
NullPointerException - if the given pattern is null.
AssertionError - if the given CharSequence matches the given regular expression.

assertContainsSequence

public void assertContainsSequence(AssertionInfo info,
                                   CharSequence actual,
                                   CharSequence[] values)

assertXmlEqualsTo

public void assertXmlEqualsTo(AssertionInfo info,
                              CharSequence actualXml,
                              CharSequence expectedXml)


Copyright © 2013–2015 AssertJ. All rights reserved.