Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6813

Add hasChildWhich node matcher

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Won't Do
    • Neutral
    • None
    • None
    • None
    • None
    • Basel 70
    • 3

    Description

      The following matcher is seen in multiple projects:

      • rest-tools
      • resources
      • UI
      • templating-samples
          private Matcher<? super Node> hasChildWhich(final Matcher<Node> matcher) {
              return new TypeSafeMatcher<Node>() {
                  @Override
                  protected boolean matchesSafely(Node node) {
                      try {
                          return NodeUtil.getNodes(node, o -> matcher.matches(o)).iterator().hasNext();
                      } catch (RepositoryException e) {
                          throw new RuntimeException(e);
                      }
                  }
      
                  @Override
                  public void describeTo(Description description) {
                      description.appendText("a node with a child with ");
                      matcher.describeTo(description);
                  }
              };
          }
      

      It would be nice to add it to our collection and use it from there directly.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              mmichel Maxime Michel
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Task DoD