Commit 318cb6ef authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'feature/add-tc-attribute-deleted-on-entity-deletion' into 'develop'

feat: add TCs for attributeDeleted events when an entity is deleted

See merge request !179
parents 61444617 e4d96374
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent in normalized format when an entity is deleted
...                 and attributeDeleted notification trigger is configured for a matching attribute in deleted entity

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          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-attributeDeleted-specific-attribute-normalized.jsonld
${building_filename}=                   building-simple-attributes.jsonld
${entity_expectation_file_path}=        entity-deleted-name-attribute-on-entity-deleted-normalized.json


*** Test Cases ***
046_22_12 Check that a notification is sent with matching entity
    [Documentation]    Delete an entity with a matching attribute and check the received notification
    [Tags]    sub-notification    5_8_6    since_v1.6.1

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

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

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Length Should Be    ${notification}[data]    ${1}
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    Check Notification Containing Entity Element
    ...    ${entity_expectation_file_path}
    ...    ${notification}


*** Keywords ***
Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
+47 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent in normalized format with sysAttrs when an entity is deleted
...                 and attributeDeleted notification trigger is configured for a matching attribute in deleted entity

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          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-attributeDeleted-specific-attribute-normalized-sysAttrs.jsonld
${building_filename}=                   building-simple-attributes.jsonld
${entity_expectation_file_path}=        entity-deleted-name-attribute-on-entity-deleted-normalized-sysAttrs.json


*** Test Cases ***
046_22_13 Check that a notification is sent with matching entity
    [Documentation]    Delete an entity with a matching attribute and check the received notification
    [Tags]    sub-notification    5_8_6    since_v1.6.1

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

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

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Length Should Be    ${notification}[data]    ${1}
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    Check Notification Containing Entity Element
    ...    ${entity_expectation_file_path}
    ...    ${notification}


*** Keywords ***
Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
+14 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:Building:randomUUID",
  "type": "Building",
  "createdAt": "2025-04-13T14:30:57.950376Z",
  "modifiedAt": "2025-04-13T14:30:57.950376Z",
  "deletedAt": "2025-04-13T14:30:58.095375Z",
  "name": {
    "type": "Property",
    "value": "urn:ngsi-ld:null",
    "createdAt": "2025-04-13T14:30:57.950376Z",
    "modifiedAt": "2025-04-13T14:30:57.950376Z",
    "deletedAt": "2025-04-13T14:30:58.095375Z"
  }
}
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:Building:randomUUID",
  "type": "Building",
  "deletedAt": "2025-04-13T14:06:03.199101Z",
  "name": {
    "type": "Property",
    "value": "urn:ngsi-ld:null"
  }
}
 No newline at end of file
+39 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/SUB/046_22_12",
  "test_objective": "Check that a notification is sent in normalized format when an entity is deleted\nand attributeDeleted notification trigger is configured for a matching attribute in deleted entity",
  "reference": "ETSI GS CIM 009 V1.6.1 [], clause 5.8.6",
  "config_id": "",
  "parent_release": "v1.6.1",
  "clauses": [
    "5.8.6"
  ],
  "pics_selection": "",
  "keywords": [
    "Create Initial Subscription And Entity",
    "Delete Initial Subscription And Entity"
  ],
  "teardown": "None",
  "initial_condition": "with {\n    the SUT being in the \"initial state\" and\n    the SUT containing an initial Subscription ${subscription} \n        with an id set to ${subscription_id}\n        and an initial Entity ${entity}\n        with an id set to ${entity_id}\n}",
  "test_cases": [
    {
      "name": "046_22_12 Check that a notification is sent with matching entity",
      "permutation_tp_id": "TP/NGSI-LD/CI/SUB/046_22_12",
      "doc": "Delete an entity with a matching attribute and check the received notification",
      "tags": [
        "5_8_6",
        "since_v1.6.1",
        "sub-notification"
      ],
      "setup": "Create Initial Subscription And Entity",
      "teardown": "Delete Initial Subscription And Entity",
      "template": null,
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Delete Entity by Id with Response Status Code set to 204     and\n        Notification with Notification containing entity element set to 'entity-deleted-name-attribute-on-entity-deleted-normalized.json'\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/{id}'\n        method set to 'DELETE'\n        Delete Entity Request with id set to ' ${entity_id}'\n}",
      "http_verb": "DELETE",
      "endpoint": "entities/{id}"
    }
  ],
  "permutations": [],
  "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour",
  "robotfile": "046_22_12"
}
 No newline at end of file
Loading