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

NodeMatchers improvements: Property matchers

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 5.3
    • None
    • testing
    • None

      It'd be useful to have matchers like hasProperty() where we can match on the property's name, value, or anything.

      Example use cases:

      assertThat(node, allOf(
                      hasProperty(propertyName(containsString("y"))),
                      hasProperty("abc", containsString("oo")),
                      hasProperty(
                              Matchers.<Property>allOf(
                                      propertyName(containsString("ef")),
                                      propertyValue(isA(Long.class))
                              )
                      )
              ));
              // It's a pity we have to help the either().or() matcher with generics here, but I couldn't find a way around that. Other option is to use anyOf() which I find less readable.
              assertThat(node, everyProperty(Matchers.<Property>either(propertyName(startsWith("jcr:"))).or(propertyValue(equalTo("mgnl:dummyNode")))));
      

        Acceptance criteria

              gjoseph Magnolia International
              gjoseph Magnolia International
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD