Package org.xmlunit.assertj3
Class ValueAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractCharSequenceAssert<ValueAssert,java.lang.String>
-
- org.xmlunit.assertj3.ValueAssert
-
- All Implemented Interfaces:
org.assertj.core.api.Assert<ValueAssert,java.lang.String>,org.assertj.core.api.Descriptable<ValueAssert>,org.assertj.core.api.EnumerableAssert<ValueAssert,java.lang.Character>,org.assertj.core.api.ExtensionPoints<ValueAssert,java.lang.String>
public class ValueAssert extends org.assertj.core.api.AbstractCharSequenceAssert<ValueAssert,java.lang.String>
Assertion methods forStringresult of XPath evaluation.Simple Example
import static org.xmlunit.assertj.XmlAssert.assertThat; final String xml = "<a><b attr=\"abc\"></b></a>"; assertThat(xml).valueByXPath("count(//a/b)").isEqualTo(3);- Since:
- XMLUnit 2.8.1
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.assertj.core.api.AbstractBooleanAssert<?>asBoolean()Returns anAssertobject that allows performing assertions on boolean value of theStringunder test.org.assertj.core.api.AbstractDoubleAssert<?>asDouble()Returns anAssertobject that allows performing assertions on integer value of theStringunder test.org.assertj.core.api.AbstractIntegerAssert<?>asInt()Returns anAssertobject that allows performing assertions on integer value of theStringunder test.XmlAssertasXml()Returns anXmlAssertobject that allows performing assertions on XML value of theStringunder test.XmlAssertasXml(java.lang.String wrapNodeName)Returns anXmlAssertobject that allows performing assertions on XML value of theStringunder test wrapping around tag with name given in wrapNodeName.ValueAssertisEqualTo(boolean expected)Try convert theStringunder test to boolean usingasBoolean()and compare with given value.ValueAssertisEqualTo(double expected)Try convert theStringunder test to double usingasDouble()and compare with given value.ValueAssertisEqualTo(int expected)Try convert theStringunder test to int usingasInt()and compare with given value.-
Methods inherited from class org.assertj.core.api.AbstractCharSequenceAssert
contains, contains, containsAnyOf, containsIgnoringCase, containsIgnoringNewLines, containsIgnoringWhitespaces, containsOnlyDigits, containsOnlyOnce, containsOnlyWhitespaces, containsPattern, containsPattern, containsPatternSatisfying, containsPatternSatisfying, containsSequence, containsSequence, containsSubsequence, containsSubsequence, containsWhitespaces, doesNotContain, doesNotContain, doesNotContainAnyWhitespaces, doesNotContainIgnoringCase, doesNotContainOnlyWhitespaces, doesNotContainPattern, doesNotContainPattern, doesNotEndWith, doesNotEndWithIgnoringCase, doesNotEndWithWhitespaces, doesNotMatch, doesNotMatch, doesNotStartWith, doesNotStartWithIgnoringCase, doesNotStartWithWhitespaces, endsWith, endsWithIgnoringCase, hasLineCount, hasSameSizeAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, inBinary, inHexadecimal, inUnicode, isAlphabetic, isAlphanumeric, isASCII, isBlank, isEmpty, isEqualToIgnoringCase, isEqualToIgnoringNewLines, isEqualToIgnoringWhitespace, isEqualToNormalizingNewlines, isEqualToNormalizingPunctuationAndWhitespace, isEqualToNormalizingUnicode, isEqualToNormalizingWhitespace, isHexadecimal, isJavaBlank, isLowerCase, isMixedCase, isNotBlank, isNotEmpty, isNotEqualToIgnoringCase, isNotEqualToIgnoringWhitespace, isNotEqualToNormalizingWhitespace, isNotJavaBlank, isNullOrEmpty, isPrintable, isSubstringOf, isUpperCase, isVisible, isXmlEqualTo, isXmlEqualToContentOf, matches, matches, matchesSatisfying, matchesSatisfying, startsWith, startsWithIgnoringCase, usingComparator, usingComparator, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator
-
Methods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingEquals, usingEquals, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Method Detail
-
asInt
public org.assertj.core.api.AbstractIntegerAssert<?> asInt()
Returns anAssertobject that allows performing assertions on integer value of theStringunder test.- Returns:
- an
Assertobject for integer assertions - Throws:
java.lang.AssertionError- if the actual value isnull.java.lang.AssertionError- if the actual value does not contain a parsable integer
-
asDouble
public org.assertj.core.api.AbstractDoubleAssert<?> asDouble()
Returns anAssertobject that allows performing assertions on integer value of theStringunder test.- Returns:
- an
Assertobject for double assertions - Throws:
java.lang.AssertionError- if the actual value isnull.java.lang.AssertionError- if the actual value does not contain a parsable double
-
asBoolean
public org.assertj.core.api.AbstractBooleanAssert<?> asBoolean()
Returns anAssertobject that allows performing assertions on boolean value of theStringunder test.If actual value after lowercasing is one of the following "true", "false", then it can be parsed to boolean.
- Returns:
- an
Assertobject for boolean assertions - Throws:
java.lang.AssertionError- if the actual value isnull.java.lang.AssertionError- if the actual value does not contain a parsable boolean
-
asXml
public XmlAssert asXml()
Returns anXmlAssertobject that allows performing assertions on XML value of theStringunder test.- Returns:
- an
Assertobject for XML assertions - Throws:
java.lang.AssertionError- if the actual value isnull.
-
asXml
public XmlAssert asXml(java.lang.String wrapNodeName)
Returns anXmlAssertobject that allows performing assertions on XML value of theStringunder test wrapping around tag with name given in wrapNodeName. If wrapNodeName is null or empty then wrapping is not applied.Pseudocode:
// given wrapNodeName = "ul"; actual = "%lt;li>a</li><li></li>"; // then xml = "<ul><li>a</li><li></li></ul>"; return XmlAssert.assertThat(xml);
- Parameters:
wrapNodeName- name of the element to wrap around the string under test- Returns:
- an
Assertobject for XML assertions - Throws:
java.lang.AssertionError- if the actual value isnull.- Since:
- XMLUnit 2.6.4
-
isEqualTo
public ValueAssert isEqualTo(int expected)
Try convert theStringunder test to int usingasInt()and compare with given value.- Parameters:
expected- expected value- Returns:
- this
-
isEqualTo
public ValueAssert isEqualTo(double expected)
Try convert theStringunder test to double usingasDouble()and compare with given value.- Parameters:
expected- expected value- Returns:
- this
-
isEqualTo
public ValueAssert isEqualTo(boolean expected)
Try convert theStringunder test to boolean usingasBoolean()and compare with given value.- Parameters:
expected- expected value- Returns:
- this
-
-