Commit bf4684cb authored by Benedetta Arena's avatar Benedetta Arena
Browse files

Resolve "Add TCs for Partial Attribute Update in the Distributed Case"

parent 6feec2c5
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that, given an exclusive registration, partially updating an entity updates the Context Source accordingly.

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup          Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Test Teardown       Delete Registration And Stop Context Source Mock Server


*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${fragment_filename}                    vehicle-speed-two-datasetid-01-fragment.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld
${attribute_id}                         speed

*** Test Cases ***
D005_01_exc Partial Partial Attribute Update
    [Documentation]    Check that if one request the Context Broker to partially update an attribute whose id matches an exclusive registration, this is updated on the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_6_4

    ${response}=    Retrieve Entity by Id    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    ${old_isparked}=    Get Value From Json    ${response.json()}    $.isParked2

    Set Stub Reply    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}    204
    ${response}=    Partial Update Entity Attributes
    ...    ${entity_id}
    ...    ${attribute_id}
    ...    ${fragment_filename}
    ...    ${CONTENT_TYPE_LD_JSON}
    Wait For Request
    Check Response Status Code    204    ${response.status_code}

    ${stub_count}=    Get Stub Count    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0
    ${request_payload}=    Get Request Body  
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

    ${response}=    Retrieve Entity by Id    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    ${new_isparked}=    Get Value From Json    ${response.json()}    $.isParked2
    Should Be Equal    ${new_isparked}    ${old_isparked}
    Should Not Contain    ${response.json()}    speed

*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=exclusive
    ...    endpoint=/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}
    Start Context Source Mock Server

Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity by Id    ${entity_id}
    Stop Context Source Mock Server
+72 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that, given an inclusive registration, partially updating an entity updates the Context Source accordingly.

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup          Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Test Teardown       Delete Registration And Stop Context Source Mock Server

*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${fragment_filename}                    vehicle-speed-two-datasetid-01-fragment.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld
${attribute_id}                         speed

*** Test Cases ***
D005_01_inc Partial Partial Attribute Update
    [Documentation]    Check that if one request the Context Broker to partially update an attribute whose id matches an inclusive registration, this is updated on the Context Source too
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_4

    ${response}=    Retrieve Entity by Id    ${entity_id}    context=${ngsild_test_suite_context}
    ${old_isparked}=    Get Value From Json    ${response.json()}    $.isParked2

    Set Stub Reply    PATCH    /ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}    204
    ${response}=    Partial Update Entity Attributes
    ...    ${entity_id}
    ...    ${attribute_id}
    ...    ${fragment_filename}
    ...    ${CONTENT_TYPE_LD_JSON}
    Wait For Request
    Check Response Status Code    204    ${response.status_code}

    ${stub_count}=    Get Stub Count    PATCH    /ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0

    ${request_payload}=    Get Request Body  
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

    ${response}=    Retrieve Entity by Id    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    Should Contain    ${response.json()}    isParked2
    Should Contain    ${response.json()}    speed

*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}
    Start Context Source Mock Server

Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity by Id    ${entity_id}
    Stop Context Source Mock Server
+81 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that, given a redirect registration, partially updating an entity updates the Context Source accordingly.

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup          Setup Entity Id And Registration And Start Context Source Mock Server
Test Teardown       Delete Registration And Stop Context Source Mock Server

*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${fragment_filename}                    vehicle-speed-two-datasetid-01-fragment.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld
${attribute_id}                         speed

*** Test Cases ***
D005_01_red Partial Partial Attribute Update
    [Documentation]    Check that if one request the Context Broker to partially update an attribute whose id matches a redirect registration, the entity is updated on the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_4

    Set Stub Reply    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}    204
    Set Stub Reply    PATCH    /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}    204
    ${response}=    Partial Update Entity Attributes
    ...    ${entity_id}
    ...    ${attribute_id}
    ...    ${fragment_filename}
    ...    ${CONTENT_TYPE_LD_JSON}
    Wait For Request
    Check Response Status Code    204    ${response.status_code}

    ${stub_count}=    Get Stub Count    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0
    ${request_payload}=    Get Request Body  
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

    ${stub_count}=    Get Stub Count    PATCH    /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0
    ${request_payload}=    Get Request Body  
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

*** Keywords ***
Setup Entity Id And Registration And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=redirect
    ...    endpoint=/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id2}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id2}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=redirect
    ...    endpoint=/broker2
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}
    Start Context Source Mock Server

Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Context Source Registration    ${registration_id2}
    Delete Entity by Id    ${entity_id}
    Stop Context Source Mock Server
+43 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D005_01_exc",
  "test_objective": "Check that, given an exclusive registration, partially updating an entity updates the Context Source accordingly.",
  "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.4",
  "config_id": "",
  "parent_release": "v1.6.1",
  "clauses": [
    "4.3.3",
    "4.3.6.3",
    "5.6.4"
  ],
  "pics_selection": "",
  "keywords": [
    "Create Entity And Registration On The Context Broker And Start Context Source Mock Server",
    "Delete Registration And Stop Context Source Mock Server"
  ],
  "teardown": "None",
  "initial_condition": "with {\n    the SUT being in the \"initial state\" and\n    the SUT containing an initial Entity ${entity} on the Context Broker\n        with an id set to ${entity_id}\n        and payload set to ${entity_payload_filename}\n    and the SUT containing a Context Source Registration \n        with id equal to ${registration_id}\n        and payload set to ${registration_payload_file_path}\n    and the SUT containing a Context Source Mock Server\n}",
  "test_cases": [
    {
      "name": "D005_01_exc Partial Partial Attribute Update",
      "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D005_01_exc",
      "doc": "Check that if one request the Context Broker to partially update an attribute whose id matches an exclusive registration, this is updated on the Context Source",
      "tags": [
        "4_3_3",
        "4_3_6_3",
        "5_6_4",
        "cf_06",
        "dist-ops",
        "proxy-exclusive",
        "since_v1.6.1"
      ],
      "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server",
      "teardown": "Delete Registration And Stop Context Source Mock Server",
      "template": null,
      "http_verb": "GET",
      "endpoint": "entities/{id}"
    }
  ],
  "permutations": [],
  "robotpath": "DistributedOperations/Provision/EntityAttributes/PartialAttributeUpdate",
  "robotfile": "D005_01_exc"
}
 No newline at end of file
+43 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D005_01_inc",
  "test_objective": "Check that, given an inclusive registration, partially updating an entity updates the Context Source accordingly.",
  "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.4",
  "config_id": "",
  "parent_release": "v1.6.1",
  "clauses": [
    "4.3.3",
    "4.3.6.2",
    "5.6.4"
  ],
  "pics_selection": "",
  "keywords": [
    "Create Entity And Registration On The Context Broker And Start Context Source Mock Server",
    "Delete Registration And Stop Context Source Mock Server"
  ],
  "teardown": "None",
  "initial_condition": "with {\n    the SUT being in the \"initial state\" and\n    the SUT containing an initial Entity ${entity} on the Context Broker\n        with an id set to ${entity_id}\n        and payload set to ${entity_payload_filename}\n    and the SUT containing a Context Source Registration \n        with id equal to ${registration_id}\n        and payload set to ${registration_payload_file_path}\n    and the SUT containing a Context Source Mock Server\n}",
  "test_cases": [
    {
      "name": "D005_01_inc Partial Partial Attribute Update",
      "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D005_01_inc",
      "doc": "Check that if one request the Context Broker to partially update an attribute whose id matches an inclusive registration, this is updated on the Context Source too",
      "tags": [
        "4_3_3",
        "4_3_6_2",
        "5_6_4",
        "additive-inclusive",
        "cf_06",
        "dist-ops",
        "since_v1.6.1"
      ],
      "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server",
      "teardown": "Delete Registration And Stop Context Source Mock Server",
      "template": null,
      "http_verb": "GET",
      "endpoint": "entities/{id}"
    }
  ],
  "permutations": [],
  "robotpath": "DistributedOperations/Provision/EntityAttributes/PartialAttributeUpdate",
  "robotfile": "D005_01_inc"
}
 No newline at end of file
Loading