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

NodeMatchers improvements: Property matchers

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Neutral
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.3
    • Component/s: testing
    • Labels:
      None
    • Magnolia Release:
      5.3

      Description

      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")))));
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: