[MAGNOLIA-5867] Match nodes whose child-nodes fulfill other node matchers Created: 05/Aug/14  Updated: 04/Feb/15  Resolved: 06/Aug/14

Status: Closed
Project: Magnolia
Component/s: testing
Affects Version/s: 5.3.1
Fix Version/s: 5.3.2

Type: Improvement Priority: Neutral
Reporter: Mikaël Geljić Assignee: Mikaël Geljić
Resolution: Fixed Votes: 0
Labels: matchers
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)

 Description   

NodeMatchers currently provides several #hasNode(...) matchers, but only checking explicit name and node-type, as Strings.

In some cases where the node name doesn't necessarily matter, it would be handy to have a #hasNode(Matcher<Node>) method for evaluating child-nodes, in the similar spirit as #hasProperty(Matcher<Property>).

We can then add similar convenience methods for matching node name, or a node with a child node whose name matches further rules, e.g.:

        assertThat(node, hasNode(hasProperty("property", "value")));
        assertThat(node, hasNode(nodeName(endsWith("nut"))));
        assertThat(node, hasNode(
                Matchers.<Node> allOf(
                        nodeName(endsWith("nut")),
                        hasProperty("property", "value")
                ));

Generated at Mon Feb 12 04:09:08 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.