Package org.xmlunit.assertj3
Class SingleNodeAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SingleNodeAssert,org.w3c.dom.Node>
-
- org.xmlunit.assertj3.SingleNodeAssert
-
- All Implemented Interfaces:
org.assertj.core.api.Assert<SingleNodeAssert,org.w3c.dom.Node>
,org.assertj.core.api.Descriptable<SingleNodeAssert>
,org.assertj.core.api.ExtensionPoints<SingleNodeAssert,org.w3c.dom.Node>
public class SingleNodeAssert extends org.assertj.core.api.AbstractAssert<SingleNodeAssert,org.w3c.dom.Node>
Assertion methods forNode
.Simple Example
import static org.xmlunit.assertj.XmlAssert.assertThat; final String xml = "<a><b attr=\"abc\"></b></a>"; assertThat(xml).nodesByXPath("//a/b").first().hasAttribute("attr", "abc").
- Since:
- XMLUnit 2.8.1
-
-
Field Summary
Fields Modifier and Type Field Description private XPathEngine
engine
-
Constructor Summary
Constructors Constructor Description SingleNodeAssert(org.w3c.dom.Node node, XPathEngine engine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SingleNodeAssert
doesNotHaveAttribute(java.lang.String attributeName)
Verifies that the actual node has not attribute with given name.SingleNodeAssert
doesNotHaveAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Verifies that the actual node has not attribute with given name and value.SingleNodeAssert
hasAttribute(java.lang.String attributeName)
Verifies that the actual node has attribute with given name.SingleNodeAssert
hasAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Verifies that the actual node has attribute with given name and value.SingleNodeAssert
hasXPath(java.lang.String xPath)
Verifies that the actual node or any child node matches givenxPath
.(package private) boolean
isNodeSetEmpty(java.lang.String xPath)
-
Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, 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, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Field Detail
-
engine
private final XPathEngine engine
-
-
Constructor Detail
-
SingleNodeAssert
SingleNodeAssert(org.w3c.dom.Node node, XPathEngine engine)
-
-
Method Detail
-
hasAttribute
public SingleNodeAssert hasAttribute(java.lang.String attributeName)
Verifies that the actual node has attribute with given name.- Parameters:
attributeName
- name of the expected attribute- Returns:
- this
- Throws:
java.lang.AssertionError
- if the actual node isnull
.java.lang.AssertionError
- if node has not attribute with given name.
-
hasAttribute
public SingleNodeAssert hasAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Verifies that the actual node has attribute with given name and value.- Parameters:
attributeName
- name of the expected attributeattributeValue
- expected attribute value- Returns:
- this
- Throws:
java.lang.AssertionError
- if the actual node isnull
.java.lang.AssertionError
- if node has not attribute with given name and value.
-
doesNotHaveAttribute
public SingleNodeAssert doesNotHaveAttribute(java.lang.String attributeName)
Verifies that the actual node has not attribute with given name.- Parameters:
attributeName
- name of the not-expected attribute- Returns:
- this
- Throws:
java.lang.AssertionError
- if the actual node isnull
.java.lang.AssertionError
- if node has attribute with given name.
-
doesNotHaveAttribute
public SingleNodeAssert doesNotHaveAttribute(java.lang.String attributeName, java.lang.String attributeValue)
Verifies that the actual node has not attribute with given name and value.- Parameters:
attributeName
- name of the expected attributeattributeValue
- not-expected attribute value- Returns:
- this
- Throws:
java.lang.AssertionError
- if the actual node isnull
.java.lang.AssertionError
- if node has attribute with given name and value.
-
hasXPath
public SingleNodeAssert hasXPath(java.lang.String xPath)
Verifies that the actual node or any child node matches givenxPath
. The actual node is the root forxPath
.- Parameters:
xPath
- XPath expression to check- Returns:
- this
- Throws:
java.lang.AssertionError
- if the actual node isnull
.java.lang.AssertionError
- if node has attribute with given name and value.- Since:
- XMLUnit 2.6.4
-
isNodeSetEmpty
boolean isNodeSetEmpty(java.lang.String xPath)
-
-