Class ValueAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractCharSequenceAssert<ValueAssert,String>
org.xmlunit.assertj3.ValueAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<ValueAssert,String>, org.assertj.core.api.Descriptable<ValueAssert>, org.assertj.core.api.EnumerableAssert<ValueAssert,Character>, org.assertj.core.api.ExtensionPoints<ValueAssert,String>

public class ValueAssert extends org.assertj.core.api.AbstractCharSequenceAssert<ValueAssert,String>
Assertion methods for String result 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
  • Field Summary

    Fields inherited from class org.assertj.core.api.AbstractAssert

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Method Summary

    Modifier and Type
    Method
    Description
    org.assertj.core.api.AbstractBooleanAssert<?>
    Returns an Assert object that allows performing assertions on boolean value of the String under test.
    org.assertj.core.api.AbstractDoubleAssert<?>
    Returns an Assert object that allows performing assertions on integer value of the String under test.
    org.assertj.core.api.AbstractIntegerAssert<?>
    Returns an Assert object that allows performing assertions on integer value of the String under test.
    Returns an XmlAssert object that allows performing assertions on XML value of the String under test.
    asXml(String wrapNodeName)
    Returns an XmlAssert object that allows performing assertions on XML value of the String under test wrapping around tag with name given in wrapNodeName.
    isEqualTo(boolean expected)
    Try convert the String under test to boolean using asBoolean() and compare with given value.
    isEqualTo(double expected)
    Try convert the String under test to double using asDouble() and compare with given value.
    isEqualTo(int expected)
    Try convert the String under test to int using asInt() and compare with given value.

    Methods inherited from class org.assertj.core.api.AbstractCharSequenceAssert

    contains, contains, containsIgnoringCase, containsOnlyDigits, containsOnlyOnce, containsOnlyWhitespaces, containsPattern, containsPattern, containsSequence, containsSequence, containsSubsequence, containsSubsequence, containsWhitespaces, doesNotContain, doesNotContain, doesNotContainAnyWhitespaces, doesNotContainIgnoringCase, doesNotContainOnlyWhitespaces, doesNotContainPattern, doesNotContainPattern, doesNotEndWith, doesNotMatch, doesNotMatch, doesNotStartWith, endsWith, hasLineCount, hasSameSizeAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, inHexadecimal, inUnicode, isBlank, isEmpty, isEqualToIgnoringCase, isEqualToIgnoringNewLines, isEqualToIgnoringWhitespace, isEqualToNormalizingNewlines, isEqualToNormalizingPunctuationAndWhitespace, isEqualToNormalizingWhitespace, isJavaBlank, isLowerCase, isNotBlank, isNotEmpty, isNotEqualToIgnoringCase, isNotEqualToIgnoringWhitespace, isNotEqualToNormalizingWhitespace, isNotJavaBlank, isNullOrEmpty, isSubstringOf, isUpperCase, isXmlEqualTo, isXmlEqualToContentOf, matches, matches, startsWith, usingComparator, usingComparator, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator

    Methods inherited from class org.assertj.core.api.AbstractAssert

    asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, 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, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, as, describedAs
  • Method Details

    • asInt

      public org.assertj.core.api.AbstractIntegerAssert<?> asInt()
      Returns an Assert object that allows performing assertions on integer value of the String under test.
      Returns:
      an Assert object for integer assertions
      Throws:
      AssertionError - if the actual value is null.
      AssertionError - if the actual value does not contain a parsable integer
    • asDouble

      public org.assertj.core.api.AbstractDoubleAssert<?> asDouble()
      Returns an Assert object that allows performing assertions on integer value of the String under test.
      Returns:
      an Assert object for double assertions
      Throws:
      AssertionError - if the actual value is null.
      AssertionError - if the actual value does not contain a parsable double
    • asBoolean

      public org.assertj.core.api.AbstractBooleanAssert<?> asBoolean()
      Returns an Assert object that allows performing assertions on boolean value of the String under test.

      If actual value after lowercasing is one of the following "true", "false", then it can be parsed to boolean.

      Returns:
      an Assert object for boolean assertions
      Throws:
      AssertionError - if the actual value is null.
      AssertionError - if the actual value does not contain a parsable boolean
    • asXml

      public XmlAssert asXml()
      Returns an XmlAssert object that allows performing assertions on XML value of the String under test.
      Returns:
      an Assert object for XML assertions
      Throws:
      AssertionError - if the actual value is null.
    • asXml

      public XmlAssert asXml(String wrapNodeName)
      Returns an XmlAssert object that allows performing assertions on XML value of the String under 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 Assert object for XML assertions
      Throws:
      AssertionError - if the actual value is null.
      Since:
      XMLUnit 2.6.4
    • isEqualTo

      public ValueAssert isEqualTo(int expected)
      Try convert the String under test to int using asInt() and compare with given value.
      Parameters:
      expected - expected value
      Returns:
      this
    • isEqualTo

      public ValueAssert isEqualTo(double expected)
      Try convert the String under test to double using asDouble() and compare with given value.
      Parameters:
      expected - expected value
      Returns:
      this
    • isEqualTo

      public ValueAssert isEqualTo(boolean expected)
      Try convert the String under test to boolean using asBoolean() and compare with given value.
      Parameters:
      expected - expected value
      Returns:
      this