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

Resolve "Add TCs for Update Entity Attributes in the Distributed Case"

parent f4dffbfe
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ ${entity_speed_filename} vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld



*** Test Cases ***
*** Test Cases ***
D011_01_exc Query The Context Broker With Type
D011_01_exc Query The Context Broker With Type
    [Documentation]    Check that if one queries the Context Broker for type, entity with matching type on a Context Source gets merged correctly
    [Documentation]    Check that if one queries the Context Broker for type, entity with matching type on a Context Source gets merged correctly
@@ -38,7 +37,6 @@ D011_01_exc Query The Context Broker With Type
    ${body}=    Get From Dictionary    ${response.json()}    speed
    ${body}=    Get From Dictionary    ${response.json()}    speed
    Should Contain    ${body}    speed
    Should Contain    ${body}    speed



*** Keywords ***
*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    ${entity_id}=    Generate Random Vehicle Entity Id
+11 −12
Original line number Original line Diff line number Diff line
*** Settings ***
*** Settings ***
Documentation       Verify that an entity can be retrieved by Id with a queryEntity and a queryBatch while using an exclusive registration.
Documentation       Verify that an entity can be retrieved by Id with a queryEntity and a queryBatch while using an exclusive registration.

Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
@@ -9,8 +8,8 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource


Test Teardown       Delete Registration And Stop Context Source Mock Server
Test Template      Setup Registration, Context Source Mock Server And Query The Context Broker With Type
Test Template      Setup Registration, Context Source Mock Server And Query The Context Broker With Type
Test Teardown      Delete Registration And Stop Context Source Mock Server




*** Variables ***
*** Variables ***
@@ -20,20 +19,19 @@ ${entity_speed_filename} vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld



*** Test Cases *** 
*** Test Cases *** 
D011_02_01_exc Query The Context Broker With Type With queryEntity
D011_02_01_exc Query The Context Broker With Type With queryEntity
    [Documentation]    Check that if one queries the Context Broker for type, and the registration only allows the queryEntity operation, the request is forwarded as expected
    [Documentation]    Check that if one queries the Context Broker for type, and the registration only allows the queryEntity operation, the request is forwarded as expected
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    [Template]     Setup Registration, Context Source Mock Server And Query The Context Broker With Type    
    [Template]     Setup Registration, Context Source Mock Server And Query The Context Broker With Type    
    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle
    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle

D011_02_02_exc Query The Context Broker With Type With queryBatch
D011_02_02_exc Query The Context Broker With Type With queryBatch
    [Documentation]    Check that if one queries the Context Broker for type, and the registration only allows the queryBatch operation, the request is forwarded as expected
    [Documentation]    Check that if one queries the Context Broker for type, and the registration only allows the queryBatch operation, the request is forwarded as expected
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    [Template]     Setup Registration, Context Source Mock Server And Query The Context Broker With Type
    [Template]     Setup Registration, Context Source Mock Server And Query The Context Broker With Type
    POST    /broker1/ngsi-ld/v1/entityOperations/query
    POST    /broker1/ngsi-ld/v1/entityOperations/query



*** Keywords ***
*** Keywords ***
Setup Registration, Context Source Mock Server And Query The Context Broker With Type
Setup Registration, Context Source Mock Server And Query The Context Broker With Type
    [Arguments]    ${method}    ${url} 
    [Arguments]    ${method}    ${url} 
@@ -69,6 +67,7 @@ Setup Registration, Context Source Mock Server And Query The Context Broker With
    Check Response Status Code    200    ${response.status_code}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Entities URIS set to    ${entities_id}    ${response.json()}
    Check Response Body Containing Entities URIS set to    ${entities_id}    ${response.json()}



Delete Registration And Stop Context Source Mock Server
Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Context Source Registration    ${registration_id}
    Stop Context Source Mock Server
    Stop Context Source Mock Server
 No newline at end of file
+20 −22
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ ${entity_speed_filename} vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld



*** Test Cases *** 
*** Test Cases *** 
D010_01_exc Query Context Broker And Retrieve Entity By Id
D010_01_exc Query Context Broker And Retrieve Entity By Id
    [Documentation]    Check that if one retrieves entity living on a Context Source from a Context Broker, and the registration only allows the retrieveEntity operation, the request is forwarded as expected
    [Documentation]    Check that if one retrieves entity living on a Context Source from a Context Broker, and the registration only allows the retrieveEntity operation, the request is forwarded as expected
@@ -38,7 +37,6 @@ D010_01_exc Query Context Broker And Retrieve Entity By Id
    ${body}=    Get From Dictionary    ${response.json()}    speed
    ${body}=    Get From Dictionary    ${response.json()}    speed
    Should Contain    ${body}    speed
    Should Contain    ${body}    speed
    
    

*** Keywords ***
*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
        ${entity_id}=    Generate Random Vehicle Entity Id
        ${entity_id}=    Generate Random Vehicle Entity Id
+22 −24
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ ${entity_speed_filename} vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld



*** Test Cases *** 
*** Test Cases *** 
D010_02_exc Query Context Broker And Retrieve Entity By Id
D010_02_exc Query Context Broker And Retrieve Entity By Id
    [Documentation]    Check that if one retrieves a fragmented entity locally, the response does not contain the exclusive attribute
    [Documentation]    Check that if one retrieves a fragmented entity locally, the response does not contain the exclusive attribute
@@ -32,7 +31,6 @@ D010_02_exc Query Context Broker And Retrieve Entity By Id
    ${response}=    Retrieve Entity By Id   ${entity_id}   context=${ngsild_test_suite_context}    local=${True}
    ${response}=    Retrieve Entity By Id   ${entity_id}   context=${ngsild_test_suite_context}    local=${True}
    Dictionary Should Not Contain Key    ${response.json()}    speed
    Dictionary Should Not Contain Key    ${response.json()}    speed
    
    

*** Keywords ***
*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
        ${entity_id}=    Generate Random Vehicle Entity Id
        ${entity_id}=    Generate Random Vehicle Entity Id
+63 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Documentation       Verify that an entity with an exclusive attribute is registered on the Context Source and said attribute can be updated via the Context Broker with redirectionOps

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

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

*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${entity_speed_filename}                vehicle-speed-attribute.jsonld
${entity_newSpeed_filename}             vehicle-speed-different-attribute.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld

*** Test Cases ***
D004_01_exc Create Entity and Registration And Start Context Source Mock Server
    [Documentation]    Check that the entity is updated correctly in the Context Source via redirectionOps
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_2

    Set Stub Reply    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/    204
    ${response}=    Update Entity Attributes
    ...    ${entity_id}
    ...    ${entity_newSpeed_filename}
    ...    ${CONTENT_TYPE_LD_JSON}
    ${response}=    Check Response Status Code    204    ${response.status_code}
    
    ${stub_count}=    Get Stub Count    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/
    Should Be True    ${stub_count} > 0

*** 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}    local=${True}
    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 Created Entity And Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity By Id    ${entity_id}
    Stop Context Source Mock Server
 No newline at end of file
Loading