Commit 7a82c9de authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat(subscription): add TCs for GeoJSON notifications

parent c5a13430
Loading
Loading
Loading
Loading
+77 −0
Changes for TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_44.robot: 77 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent as a GeoJSON FeatureCollection when the endpoint accepts
...                 application/geo+json

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Setup          Start Local Server    ${notification_server_host}    ${notification_server_port}
Test Teardown       Delete Initial Subscription And Entity
Test Template       Update Entity And Check GeoJSON Notification


*** Variables ***
${fragment_filename}=       name-fragment.jsonld


*** Test Cases ***    SUBSCRIPTION_FILENAME    BUILDING_FILENAME    EXPECTATION_FILENAME    ENTITY_ID_SUFFIX    CONTEXT_IN_LINK_HEADER
046_44_01 Notification Is Sent As A GeoJSON FeatureCollection
    [Tags]    sub-notification    core_10_5_7    core_5_2_6_9_1    since_v1.6.1
    subscriptions/subscription-building-entities-geojson.jsonld
    ...    building-different-attributes-types.jsonld
    ...    building-different-attributes-types-046-44-01.geojson
    ...    046_44_01
    ...    ${False}
046_44_02 Notification Is Sent As A GeoJSON FeatureCollection Without Context When A JSON Body Is Preferred
    [Tags]    sub-notification    core_10_5_7    core_5_2_6_9_1    http_6_5_2    since_v1.6.1
    subscriptions/subscription-building-entities-geojson-prefer-json.jsonld
    ...    building-different-attributes-types.jsonld
    ...    building-different-attributes-types-046-44-02.geojson
    ...    046_44_02
    ...    ${True}
046_44_03 Notification Is Sent As A GeoJSON FeatureCollection With A Null Geometry For An Entity Without Location
    [Tags]    sub-notification    core_10_5_7    core_5_2_6_9_1    since_v1.6.1
    subscriptions/subscription-building-entities-geojson.jsonld
    ...    building-simple-attributes.jsonld
    ...    building-simple-attributes-046-44-03.geojson
    ...    046_44_03
    ...    ${False}


*** Keywords ***
Update Entity And Check GeoJSON Notification
    [Documentation]    Update an attribute of an entity and check the notification is a GeoJSON FeatureCollection
    [Arguments]
    ...    ${subscription_filename}
    ...    ${building_filename}
    ...    ${expectation_filename}
    ...    ${entity_id_suffix}
    ...    ${context_in_link_header}

    Create Subscription And Entity    ${subscription_filename}    ${building_filename}    ${entity_id_suffix}

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Should Start With    ${headers}[Content-Type]    application/geo+json
    IF    ${context_in_link_header}
        ${expected_header_link}=    Build Context Link    ${ngsild_test_suite_context}
        Dictionary Should Contain Item    ${headers}    Link    ${expected_header_link}
    ELSE
        Dictionary Should Not Contain Key    ${headers}    Link
    END
    Check Notification Containing GeoJSON FeatureCollection
    ...    ${expectation_filename}
    ...    ${notification}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity    ${entity_id}
    Stop Local Server
+75 −0
Changes for TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_45.robot: 75 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification sent as a GeoJSON FeatureCollection contains the changes when
...                 showChanges is true in the subscription

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Teardown       Delete Initial Subscription And Entity


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-geojson-show-changes.jsonld
${building_filename}=                   building-different-attributes-types.jsonld


*** Test Cases ***
046_45_01 Show Changes In GeoJSON For An Update Of Property
    [Tags]    sub-notification    core_10_5_7    core_5_2_6_9_1    show_changes    since_v1.6.1
    [Setup]    Create Initial Subscription And Entity    ${subscription_payload_file_path}    046_45_01
    Update Attribute And Check Previous Value In GeoJSON Notification
    ...    name-fragment.jsonld
    ...    building-different-attributes-types-previous-property-046-45-01.geojson

046_45_02 Show Changes In GeoJSON For An Update Of The Geometry GeoProperty
    [Tags]    sub-notification    core_10_5_7    core_5_2_6_9_1    show_changes    since_v1.6.1
    [Setup]    Create Initial Subscription And Entity    ${subscription_payload_file_path}    046_45_02
    Update Attribute And Check Previous Value In GeoJSON Notification
    ...    location-fragment.jsonld
    ...    building-different-attributes-types-previous-geoproperty-046-45-02.geojson

046_45_03 Show Changes In GeoJSON When An Entity Is Deleted
    [Documentation]    Delete an entity and check the notification contains the previous values for all attributes
    [Tags]    sub-notification    core_10_5_7    core_5_2_6_9_1    show_changes    since_v1.6.1
    [Setup]    Create Initial Subscription And Entity
    ...    subscriptions/subscription-building-entities-geojson-show-changes-entityDeleted.jsonld
    ...    046_45_03

    ${response}=    Delete Entity    ${entity_id}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing GeoJSON FeatureCollection
    ...    building-different-attributes-types-deleted-entity-046-45-03.geojson
    ...    ${notification}


*** Keywords ***
Update Attribute And Check Previous Value In GeoJSON Notification
    [Documentation]    Update an attribute in entity and check the GeoJSON notification contains the previous value
    [Arguments]    ${fragment_filename}    ${expectation_filename}

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing GeoJSON FeatureCollection
    ...    ${expectation_filename}
    ...    ${notification}

Create Initial Subscription And Entity
    [Arguments]    ${subscription_filename}    ${entity_id_suffix}
    Create Subscription And Entity    ${subscription_filename}    ${building_filename}    ${entity_id_suffix}
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity    ${entity_id}
    Stop Local Server
+47 −0
Changes for data/subscriptions/expectations/building-different-attributes-types-046-44-01.geojson: 47 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
   "type": "FeatureCollection",
   "features": [
      {
         "id": "urn:ngsi-ld:Building:046_44_01",
         "type": "Feature",
         "geometry": {
            "type": "Point",
            "coordinates": [
               -8.5,
               41.2
            ]
         },
         "properties": {
            "type": "Building",
            "name": {
               "type": "Property",
               "value": "Tour Eiffel"
            },
            "locatedAt": {
               "type": "Relationship",
               "object": "urn:ngsi-ld:City:Paris"
            },
            "location": {
               "type": "GeoProperty",
               "value": {
                  "type": "Point",
                  "coordinates": [
                     -8.5,
                     41.2
                  ]
               }
            },
            "street": {
               "type": "LanguageProperty",
               "languageMap": {
                  "fr": "Grand Place",
                  "nl": "Grote Markt"
               }
            }
         }
      }
   ],
   "@context": [
      "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
   ]
}
+44 −0
Changes for data/subscriptions/expectations/building-different-attributes-types-046-44-02.geojson: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
   "type": "FeatureCollection",
   "features": [
      {
         "id": "urn:ngsi-ld:Building:046_44_02",
         "type": "Feature",
         "geometry": {
            "type": "Point",
            "coordinates": [
               -8.5,
               41.2
            ]
         },
         "properties": {
            "type": "Building",
            "name": {
               "type": "Property",
               "value": "Tour Eiffel"
            },
            "locatedAt": {
               "type": "Relationship",
               "object": "urn:ngsi-ld:City:Paris"
            },
            "location": {
               "type": "GeoProperty",
               "value": {
                  "type": "Point",
                  "coordinates": [
                     -8.5,
                     41.2
                  ]
               }
            },
            "street": {
               "type": "LanguageProperty",
               "languageMap": {
                  "fr": "Grand Place",
                  "nl": "Grote Markt"
               }
            }
         }
      }
   ]
}
+48 −0
Changes for data/subscriptions/expectations/building-different-attributes-types-deleted-entity-046-45-03.geojson: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
   "type": "FeatureCollection",
   "features": [
      {
         "id": "urn:ngsi-ld:Building:046_45_03",
         "type": "Feature",
         "geometry": null,
         "properties": {
            "type": "Building",
            "deletedAt": "2025-08-19T08:31:53.757142Z",
            "name": {
               "type": "Property",
               "previousValue": "Eiffel Tower",
               "value": "urn:ngsi-ld:null"
            },
            "locatedAt": {
               "type": "Relationship",
               "previousObject": "urn:ngsi-ld:City:Paris",
               "object": "urn:ngsi-ld:null"
            },
            "location": {
               "type": "GeoProperty",
               "previousValue": {
                  "type": "Point",
                  "coordinates": [
                     -8.5,
                     41.2
                  ]
               },
               "value": "urn:ngsi-ld:null"
            },
            "street": {
               "type": "LanguageProperty",
               "previousLanguageMap": {
                  "fr": "Grand Place",
                  "nl": "Grote Markt"
               },
               "languageMap": {
                  "@none": "urn:ngsi-ld:null"
               }
            }
         }
      }
   ],
   "@context": [
      "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
   ]
}
Loading