Class FluentStringAssertion<R>
- Type Parameters:
- R- The return type.
- Direct Known Subclasses:
- FluentRequestFormParamAssertion,- FluentRequestHeaderAssertion,- FluentRequestQueryParamAssertion,- FluentResponseHeaderAssertion,- StringAssertion
Example:
   
Test Methods:
- FluentStringAssertion- is(String)
- isNot(String)
- isLines(String...)
- isSortedLines(String...)
- isIc(String)
- isNotIc(String)
- isContains(String...)
- isNotContains(String...)
- isEmpty()
- isNotEmpty()
- isString(Object)
- isMatches(String)
- isPattern(String)
- isPattern(String,int)
- isPattern(Pattern)
- isStartsWith(String)
- isEndsWith(String)
 
- FluentObjectAssertion
Transform Methods:
Configuration Methods:
See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionFluentStringAssertion(String value, R returns) Constructor.FluentStringAssertion(Assertion creator, String value, R returns) Chained constructor.
- 
Method SummaryModifier and TypeMethodDescriptionWhen enabled, text in the message is converted to valid Java strings.asLc()Converts the text to lowercase.asLength()Returns the length of this string as an integer assertion.asLines()Splits the string into lines.Removes any newlines from the string.Performs the specified substring replacement on the underlying string.asReplaceAll(String regex, String replacement) Performs the specified regular expression replacement on the underlying string.Splits the string into lines using the specified regular expression.asTransformed(Function<String, String> function) Applies a transform on the inner object and returns a new inner object.Removes any leading/trailing whitespace from the string.asUc()Converts the text to uppercase.URL-decodes the text in this assertion.Asserts that the text equals the specified value.isContains(String... values) Asserts that the text contains all of the specified substrings.isEmpty()Asserts that the text is empty.isEndsWith(String string) Asserts that the text ends with the specified string.Asserts that the text equals the specified value ignoring case.Asserts that the lines of text equals the specified value.Asserts that the text matches the specified pattern containing"*" meta characters.Asserts that the text equals the specified value.isNotContains(String... values) Asserts that the text doesn't contain any of the specified substrings.Asserts that the text is not null or empty.Asserts that the text does not equal the specified value ignoring case.Asserts that the text matches the specified regular expression.Asserts that the text matches the specified regular expression.Asserts that the text matches the specified regular expression pattern.isSortedLines(String... lines) Asserts that the text equals the specified value after splitting both by newlines and sorting the rows.isStartsWith(String string) Asserts that the text starts with the specified string.Asserts that the text equals the specified object after callingFluentObjectAssertion.toString()on the object.Allows you to override the assertion failure message.setOut(PrintStream value) If an error occurs, send the error message to the specified stream instead of STDERR.Suppresses output to STDERR.If an error occurs, send the error message to STDOUT instead of STDERR.setThrowable(Class<? extends RuntimeException> value) If an error occurs, throw this exception instead of the standardAssertionError.Methods inherited from class org.apache.juneau.assertions.FluentObjectAssertionasAny, asJson, asJsonSorted, asString, asString, asString, asTransformedTo, equals, getFailureMessage, is, isAny, isExactType, isExists, isJson, isNotAny, isNotNull, isNull, isSame, isSameJsonAs, isSameSerializedAs, isSameSortedJsonAs, isString, isType, map, opt, orElse, toString, value, valueAsString, valueIsNotNull, valueIsNullMethods inherited from class org.apache.juneau.assertions.FluentAssertionreturnsMethods inherited from class org.apache.juneau.assertions.AssertionarrayClass, className, error, error
- 
Constructor Details- 
FluentStringAssertionConstructor.- Parameters:
- value- The object being tested.
 Can be- null .
- returns- The object to return after a test method is called.
 If- null , the test method returns this object allowing multiple test method calls to be used on the same assertion.
 
- 
FluentStringAssertionChained constructor.Used when transforming one assertion into another so that the assertion config can be used by the new assertion. - Parameters:
- creator- The assertion that created this assertion.
 Should be- null if this is the top-level assertion.
- value- The object being tested.
 Can be- null .
- returns- The object to return after a test method is called.
 If- null , the test method returns this object allowing multiple test method calls to be used on the same assertion.
 
 
- 
- 
Method Details- 
asJavaStringsWhen enabled, text in the message is converted to valid Java strings.value .replaceAll("\\\\" ,"\\\\\\\\" ).replaceAll("\n" ,"\\\\n" ).replaceAll("\t" ,"\\\\t" );- Returns:
- This object.
 
- 
asTransformedDescription copied from class:FluentObjectAssertionApplies a transform on the inner object and returns a new inner object.- Overrides:
- asTransformedin class- FluentObjectAssertion<String,- R> 
- Parameters:
- function- The function to apply.
- Returns:
- This object.
 
- 
asReplaceAllPerforms the specified regular expression replacement on the underlying string.- Parameters:
- regex- The regular expression to which this string is to be matched.
- replacement- The string to be substituted for each match.
- Returns:
- This object.
 
- 
asReplacePerforms the specified substring replacement on the underlying string.- Parameters:
- target- The sequence of char values to be replaced.
- replacement- The replacement sequence of char values.
- Returns:
- This object.
 
- 
asUrlDecodeURL-decodes the text in this assertion.- Returns:
- This object.
 
- 
asLcConverts the text to lowercase.- Returns:
- This object.
 
- 
asUcConverts the text to uppercase.- Returns:
- This object.
 
- 
asLinesSplits the string into lines.- Returns:
- This object.
 
- 
asSplitSplits the string into lines using the specified regular expression.- Parameters:
- regex- The delimiting regular expression
- Returns:
- This object.
 
- 
asLengthReturns the length of this string as an integer assertion.- Returns:
- This object.
 
- 
asOneLineRemoves any newlines from the string.- Returns:
- This object.
 
- 
asTrimmedRemoves any leading/trailing whitespace from the string.- Returns:
- This object.
 
- 
isAsserts that the text equals the specified value.Similar to is(String)except error message states diff position.Example:// Validates the response body of an HTTP call is the text "OK". client .get(URL ) .run() .assertContent().is("OK" );- Overrides:
- isin class- FluentObjectAssertion<String,- R> 
- Parameters:
- value- The value to check against.
 If multiple values are specified, they are concatenated with newlines.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isNotAsserts that the text equals the specified value.- Overrides:
- isNotin class- FluentObjectAssertion<String,- R> 
- Parameters:
- value- The value to check against.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isLinesAsserts that the lines of text equals the specified value.Example:// Validates the response body of an HTTP call is the text "OK". client .get(URL ) .run() .assertContent().isLines("Line 1" ,"Line 2" ,"Line 3" );- Parameters:
- lines- The value to check against.
 If multiple values are specified, they are concatenated with newlines.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isSortedLinesAsserts that the text equals the specified value after splitting both by newlines and sorting the rows.Example:// Validates the response body of an HTTP call is the text "OK". client .get(URL ) .run() .assertContent().isSortedLines("Line 1" ,"Line 2" ,"Line 3" );- Parameters:
- lines- The value to check against.
 If multiple values are specified, they are concatenated with newlines.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isIcAsserts that the text equals the specified value ignoring case.- Parameters:
- value- The value to check against.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isNotIcAsserts that the text does not equal the specified value ignoring case.- Parameters:
- value- The value to check against.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isContainsAsserts that the text contains all of the specified substrings.- Parameters:
- values- The values to check against.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isNotContainsAsserts that the text doesn't contain any of the specified substrings.- Parameters:
- values- The values to check against.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isEmptyAsserts that the text is empty.- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isNotEmptyAsserts that the text is not null or empty.- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isMatchesAsserts that the text matches the specified pattern containing"*" meta characters.The "*" meta character can be used to represent zero or more characters..- Parameters:
- searchPattern- The search pattern.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isPatternAsserts that the text matches the specified regular expression.- Parameters:
- regex- The pattern to test for.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isPatternAsserts that the text matches the specified regular expression.- Parameters:
- regex- The pattern to test for.
- flags- Pattern match flags. See- Pattern.compile(String, int).
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isPatternAsserts that the text matches the specified regular expression pattern.- Parameters:
- pattern- The pattern to test for.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isStartsWithAsserts that the text starts with the specified string.- Parameters:
- string- The string to test for.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isEndsWithAsserts that the text ends with the specified string.- Parameters:
- string- The string to test for.
- Returns:
- The fluent return object.
- Throws:
- AssertionError- If assertion failed.
 
- 
isStringAsserts that the text equals the specified object after callingFluentObjectAssertion.toString()on the object.- Parameters:
- value- The value to check against.
- Returns:
- The fluent return object.
 
- 
setMsgDescription copied from class:AssertionAllows you to override the assertion failure message.String can contain "{msg}" to represent the original message.Example:import static org.apache.juneau.assertions.Assertions.*;// Throws an assertion with a custom message instead of the default "Value was null." assertString (myString ) .setMsg("My string was bad: {msg}" ) .isNotNull();- Overrides:
- setMsgin class- FluentObjectAssertion<String,- R> 
- Parameters:
- msg- The assertion failure message.
- args- Optional message arguments.
- Returns:
- This object.
 
- 
setOutDescription copied from class:AssertionIf an error occurs, send the error message to the specified stream instead of STDERR.- Overrides:
- setOutin class- FluentObjectAssertion<String,- R> 
- Parameters:
- value- The output stream. Can be- null to suppress output.
- Returns:
- This object.
 
- 
setSilentDescription copied from class:AssertionSuppresses output to STDERR.This is the equivalent to calling out( .null )- Overrides:
- setSilentin class- FluentObjectAssertion<String,- R> 
- Returns:
- This object.
 
- 
setStdOutDescription copied from class:AssertionIf an error occurs, send the error message to STDOUT instead of STDERR.- Overrides:
- setStdOutin class- FluentObjectAssertion<String,- R> 
- Returns:
- This object.
 
- 
setThrowableDescription copied from class:AssertionIf an error occurs, throw this exception instead of the standardAssertionError.The throwable class must have a public constructor that takes in any of the following parameters: If the throwable cannot be instantiated, a RuntimeExceptionis thrown instead.Example:import static org.apache.juneau.assertions.Assertions.*;// Throws a BadRequest instead of an AssertionError if the string is null. assertString (myString ) .setThrowable(BadRequest.class ) .isNotNull();- Overrides:
- setThrowablein class- FluentObjectAssertion<String,- R> 
- Parameters:
- value- The new value for this setting.
- Returns:
- This object.
 
 
-