Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultipleNodeAssert: asserting node text of all nodes #192

Closed
keesvandieren opened this issue Jul 23, 2020 · 1 comment
Closed

MultipleNodeAssert: asserting node text of all nodes #192

keesvandieren opened this issue Jul 23, 2020 · 1 comment
Labels
AssertJ Support the xmlunit-assertj module enhancement
Milestone

Comments

@keesvandieren
Copy link

Given a list of DOM nodes with texts, we'd like to assert that the texts of the elements matches an array of strings we have in Java.

For attributes, there is extractingAttribute which makes this easy for attributes.

We'd like to have an extractingText there to do the same for element texts.

We would like to write the following test (we are testing an XSL-FO document):

        assertThat(letterDocument)
                .withNamespaceContext(XSL_FO_NAMESPACE_CONTEXT)
                .nodesByXPath("//fo:block[@id='recipient-address']/fo:block")
                .extractingText()
                .containsExactly("John Doo",
                        "Street 213423",
                        "2944 AA Amsterdam",
                        "The Netherlands");

So far I am unable to write well-written assertions to test this.

Maybe I am missing something?

Would you accept a PR for such an extractingText() method?

@keesvandieren keesvandieren changed the title MultipleNodeAssert: asserting node values or node text() of all nodes MultipleNodeAssert: asserting node text of all nodes Jul 23, 2020
@bodewig bodewig added AssertJ Support the xmlunit-assertj module enhancement labels Jul 23, 2020
@bodewig
Copy link
Member

bodewig commented Jul 23, 2020

That would be the content of nested Text nodes? One probably needs to be careful with the parser normalizing things even when one doesn't expect it.

Would you accept a PR for such an extractingText() method?

Sure. Thank you,

@bodewig bodewig added this to the 2.8.0 milestone Jul 28, 2020
bodewig added a commit that referenced this issue Jul 28, 2020
Add extractingText, which extracts text content of given nodes #192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AssertJ Support the xmlunit-assertj module enhancement
Projects
None yet
Development

No branches or pull requests

2 participants