public class StringSubject extends ComparableSubject<StringSubject,String>
failureStrategy
Constructor and Description |
---|
StringSubject(FailureMetadata metadata,
String string) |
StringSubject(FailureStrategy failureStrategy,
String string)
Deprecated.
Switch your
Subject from accepting FailureStrategy (and exposing a
SubjectFactory ) to accepting a FailureMetadata (and exposing a Subject.Factory ), at which point you'll call the FailureMetadata overload of this
constructor instead. |
Modifier and Type | Method and Description |
---|---|
protected String |
actualCustomStringRepresentation()
Supplies the direct string representation of the actual value to other methods which may prefix
or otherwise position it in an error message.
|
void |
contains(CharSequence string)
Fails if the string does not contain the given sequence.
|
void |
containsMatch(Pattern pattern)
Fails if the string does not contain a match on the given regex.
|
void |
containsMatch(String regex)
Fails if the string does not contain a match on the given regex.
|
void |
doesNotContain(CharSequence string)
Fails if the string contains the given sequence.
|
void |
doesNotContainMatch(Pattern pattern)
Fails if the string contains a match on the given regex.
|
void |
doesNotContainMatch(String regex)
Fails if the string contains a match on the given regex.
|
void |
doesNotMatch(Pattern regex)
Fails if the string matches the given regex.
|
void |
doesNotMatch(String regex)
Fails if the string matches the given regex.
|
void |
endsWith(String string)
Fails if the string does not end with the given string.
|
void |
hasLength(int expectedLength)
Fails if the string does not have the given length.
|
void |
isEmpty()
Fails if the string is not equal to the zero-length "empty string."
|
void |
isEqualTo(Object expected)
Fails if the subject is not equal to the given object.
|
void |
isEquivalentAccordingToCompareTo(String other)
Deprecated.
Use
isEqualTo(java.lang.Object) instead. String comparison is consistent with equality. |
void |
isNotEmpty()
Fails if the string is equal to the zero-length "empty string."
|
void |
isNull()
Fails if the string is not null.
|
void |
matches(Pattern regex)
Fails if the string does not match the given regex.
|
void |
matches(String regex)
Fails if the string does not match the given regex.
|
void |
startsWith(String string)
Fails if the string does not start with the given string.
|
comparesEqualTo, isAtLeast, isAtMost, isGreaterThan, isIn, isLessThan, isNotIn
actual, actualAsString, check, equals, fail, fail, fail, failComparing, failComparing, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutSubject, failWithRawMessage, failWithRawMessageAndCause, getDisplaySubject, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isSameAs, named
@Deprecated public StringSubject(FailureStrategy failureStrategy, @Nullable String string)
Subject
from accepting FailureStrategy
(and exposing a
SubjectFactory
) to accepting a FailureMetadata
(and exposing a Subject.Factory
), at which point you'll call the FailureMetadata
overload of this
constructor instead.public StringSubject(FailureMetadata metadata, @Nullable String string)
protected String actualCustomStringRepresentation()
Subject
Subjects should override this with care.
By default, this returns String.ValueOf(getActualValue())
.
actualCustomStringRepresentation
in class Subject<StringSubject,String>
public void isEqualTo(@Nullable Object expected)
Subject
Objects.equal(java.lang.Object, java.lang.Object)
Arrays#equals
overload
Byte
, Short
, Character
, Integer
, or Long
) and they are numerically equal when converted to Long
.
isEqualTo
in class Subject<StringSubject,String>
@Deprecated public final void isEquivalentAccordingToCompareTo(String other)
isEqualTo(java.lang.Object)
instead. String comparison is consistent with equality.ComparableSubject
Comparable.compareTo(T)
, (i.e., fails if a.comparesTo(b) != 0
).
Note: Do not use this method for checking object equality. Instead, use Subject.isEqualTo(Object)
.
isEquivalentAccordingToCompareTo
in class ComparableSubject<StringSubject,String>
public void isNull()
isNull
in class Subject<StringSubject,String>
public void hasLength(int expectedLength)
public void isEmpty()
public void isNotEmpty()
public void contains(CharSequence string)
public void doesNotContain(CharSequence string)
public void startsWith(String string)
public void endsWith(String string)
public void matches(String regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void matches(Pattern regex)
public void doesNotMatch(String regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void doesNotMatch(Pattern regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void containsMatch(Pattern pattern)
public void containsMatch(String regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void doesNotContainMatch(Pattern pattern)
public void doesNotContainMatch(String regex)
Copyright © 2017. All rights reserved.