Commit 03b80019 authored by kzangeli's avatar kzangeli
Browse files

fix(037): entity-id discovery semantics, GeoJSON polygon, three-page pagination

037_10_01 queried /csourceRegistrations with REGISTRATION ids in ?id=,
but the parameter is a 'List of entity ids to be retrieved' — it
filters by what the registrations' EntityInfos can provide. The test
now queries two Building entity ids: the second and third registrations
(type Building, no id constraint) can provide them, the first one
(Vehicle:A456 pinned + OffStreetParking id patterns) cannot and is
excluded. The expected ids were also passed comma-joined into the
keyword's @{varargs} (one element); now separate arguments.

Both 037-10 expectation files are rebuilt from the actual fixtures —
they carried a 'location' member the csourceProperty fixture never had.

037_07_02's polygon was not valid GeoJSON (RFC 7946): single ring at
the wrong nesting level and not closed. Now [[[...,first==last]]], the
same shape its passing siblings use.

037_11 assumed three type=Building registrations but its first fixture
registers Vehicle/OffStreetParking only — 037_11_01/02 expected a third
page that never existed (and _01's next-link pointed at
/csourceSubscriptions, a copy-paste slip; offset=2 of three matches is
the last page, so no next link per clause 5.5.9). First fixture is now
a Building one and _03 expects all three.

Analysis recorded as testsuite-doubts.md #98.
parent d9a20233
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ ${expectation_file_path}= csourceRegistrations/exp
    near;maxDistance==2000    Point    [-8.503,41.202]    ${EMPTY}    ${expectation_file_path}
037_07_02 Within Polygon
    [Tags]    csr-query    5_10_2
    within    Polygon    [[-13.503,47.202],[6.541, 52.961],[20.37,44.653],[9.46,32.57],[-15.23,21.37]]    location    ${expectation_file_path}
    # RFC 7946: Polygon coordinates are an array of linear RINGS (one more
    # nesting level), and a ring is closed — first position == last position.
    within    Polygon    [[[-13.503,47.202],[6.541, 52.961],[20.37,44.653],[9.46,32.57],[-15.23,21.37],[-13.503,47.202]]]    location    ${expectation_file_path}


*** Keywords ***
+6 −1
Original line number Diff line number Diff line
@@ -21,7 +21,12 @@ ${third_context_source_registration_payload_file_path}= csourceRegistrations
*** Test Cases ***    QUERY_PARAM_NAME    QUERY_PARAM_VALUE    EXPECTATION_FILE_PATH    EXPECTED_CONTEXT_SOURCE_REGISTRATION_IDS
037_10_01 With List Of Entity Ids
    [Tags]    csr-query    5_10_2
    id    ${first_context_source_registration_id},${third_context_source_registration_id}    csourceRegistrations/expectations/context-source-registrations-037-10-01.json    ${first_context_source_registration_id},${third_context_source_registration_id}
    # 'id' filters by ENTITY ids ("List of entity ids to be retrieved") — not
    # by registration ids. The two Building ids below can be provided by the
    # second and third registrations (type Building, no id constraint) but NOT
    # by the first one, whose EntityInfos pin Vehicle:A456 and OffStreetParking
    # id patterns (testsuite-doubts.md #98).
    id    urn:ngsi-ld:Building:building001,urn:ngsi-ld:Building:building002    csourceRegistrations/expectations/context-source-registrations-037-10-01.json    ${second_context_source_registration_id}    ${third_context_source_registration_id}
037_10_02 With NGSI-LD Query
    [Tags]    csr-query    5_10_2
    q    csourceProperty1=="aValue"    csourceRegistrations/expectations/context-source-registrations-037-10-02.json    ${third_context_source_registration_id}
+14 −4
Original line number Diff line number Diff line
@@ -13,7 +13,10 @@ Test Template Query Context Source Registration With Limit And Offset Para


*** Variables ***
${first_context_source_registration_payload_file_path}=     csourceRegistrations/context-source-registration.jsonld
# All three registrations must match type=Building — the pagination rows
# below assume three pages. The generic context-source-registration.jsonld
# registers Vehicle/OffStreetParking only (testsuite-doubts.md #98).
${first_context_source_registration_payload_file_path}=     csourceRegistrations/context-source-registration-csourceProperty.jsonld
${second_context_source_registration_payload_file_path}=    csourceRegistrations/context-source-registration-location.jsonld
${third_context_source_registration_payload_file_path}=     csourceRegistrations/context-source-registration-detailed-information.jsonld

@@ -21,30 +24,37 @@ ${third_context_source_registration_payload_file_path}= csourceRegistrations
*** Test Cases ***    LIMIT    OFFSET    EXPECTED_NUMBER    PREV_LINK    NEXT_LINK
037_11_01 Query Second Subscription
    [Tags]    csr-query    5_10_2
    ${1}    ${2}    ${1}    </ngsi-ld/v1/csourceRegistrations?type=Building&limit=1&offset=1>;rel="prev";type="application/ld+json"    </ngsi-ld/v1/csourceSubscriptions?type=Building&limit=1&offset=3>;rel="next";type="application/ld+json"
    # offset=2 with limit=1 over three matches is the LAST page — no next link
    # (clause 5.5.9; the previous expectation also pointed the next link at
    # /csourceSubscriptions, a copy-paste slip).
    ${1}    ${2}    ${1}    </ngsi-ld/v1/csourceRegistrations?type=Building&limit=1&offset=1>;rel="prev";type="application/ld+json"    ${EMPTY}
037_11_02 Query Last Subscription
    [Tags]    csr-query    5_10_2
    ${2}    ${2}    ${1}    </ngsi-ld/v1/csourceRegistrations?type=Building&limit=2&offset=0>;rel="prev";type="application/ld+json"    ${EMPTY}
037_11_03 Query All Subscriptions
    [Tags]    csr-query    5_10_2
    ${15}    ${0}    ${2}    ${EMPTY}    ${EMPTY}
    ${15}    ${0}    ${3}    ${EMPTY}    ${EMPTY}


*** Keywords ***
Query Context Source Registration With Limit And Offset Parameters
    [Documentation]    Check that one can query context source registrations with providing page and limit parameters, pagination logic shall be in place as mandated by clause 5.5.9.
    [Arguments]    ${limit}    ${offset}    ${expected_number}    ${prev_link}    ${next_link}
    # accept=ld+json: the pagination keyword compares the WHOLE Link header,
    # and the application/json form carries the @context Link alongside the
    # pagination one.
    ${response}=    Query Context Source Registrations
    ...    context=${ngsild_test_suite_context}
    ...    type=Building
    ...    limit=${limit}
    ...    offset=${offset}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Number Of Entities
    ...    ContextSourceRegistration
    ...    ${expected_number}
    ...    ${response.json()}
    Check Pagination Prev And Next Headers    ${prev_link}    ${next_link}    ${response.json()}
    Check Pagination Prev And Next Headers    ${prev_link}    ${next_link}    ${response.headers}

Setup Initial Context Source Registrations
    ${first_context_source_registration_id}=    Generate Random CSR Id
+8 −11
Original line number Diff line number Diff line
@@ -8,6 +8,13 @@
          {
            "type": "Building"
          }
        ],
        "propertyNames": [
          "name",
          "subCategory"
        ],
        "relationshipNames": [
          "locatedAt"
        ]
      }
    ],
@@ -25,18 +32,8 @@
        ]
      }
    ],
    "location": {
      "type": "Point",
      "coordinates": [
        -8.521,
        41.2
      ]
    },
    "endpoint": "http://my.csource.org:1026",
    "csourceProperty1": "aValue",
    "csourceProperty2": "anotherValue",
    "@context": [
      "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
    ]
    "csourceProperty2": "anotherValue"
  }
]
 No newline at end of file
+1 −11
Original line number Diff line number Diff line
@@ -11,18 +11,8 @@
        ]
      }
    ],
    "location": {
      "type": "Point",
      "coordinates": [
        -8.521,
        41.2
      ]
    },
    "endpoint": "http://my.csource.org:1026",
    "csourceProperty1": "aValue",
    "csourceProperty2": "anotherValue",
    "@context": [
      "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
    ]
    "csourceProperty2": "anotherValue"
  }
]
 No newline at end of file
Loading