FEST
  1. FEST
  2. FEST-324

Allow assertion on extracted values of a given property of collection/array elements

    Details

    • Type: New Feature New Feature
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: FEST-Assert 1.2
    • Fix Version/s: FEST-Assert 1.3
    • Component/s: Assert
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Sometimes you need to control a collection result, but checking all the elements is overkill so you only want to control a specific property on each collection elements.

      Example :
      Imagine you query a system to find persons, a Person has a name, an age and a unique id.
      To check a collection result of Person, it's enough to control that the ids of the returned persons are the expected ones.
      The idea is to extract the values of the property on each elements and make some assertion on the extracted values.

      // team is a Collection of Person
      assertThat(team).onProperty("id").contains(12, 55, 4);

      using reflection, onProperty("id") extracts the value of property "id" of each team elements, it returns a new CollectionAssert whose "actual" attribute is composed of ids of team Persons, you can apply then all available Collection assertions ...

      It would also be nice to access nested properties with '.' notation, something like :
      assertThat(team).onProperty("adress.street").contains("Sesame street", "Boulevard Saint Germain", "Rue de Tolbiac");

        Activity

        Hide
        Joel Costigliola added a comment -

        the svn revision 951 is related to this issue

        Show
        Joel Costigliola added a comment - the svn revision 951 is related to this issue

          People

          • Assignee:
            Joel Costigliola
            Reporter:
            Joel Costigliola
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: