Commit 83d675ab authored by Benedetta Arena's avatar Benedetta Arena
Browse files

fix: improve logic of CreateEntity

parent d3c03476
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -8,17 +8,13 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
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
${registration_id_prefix}               urn:ngsi-ld:Registration:
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld


@@ -27,7 +23,7 @@ D001_01_exc Create Entity With Exclusive Registration
    [Documentation]    Check that the entity is created correctly on both the Context Broker and the Context Source. The entity shall be retrieved correctly.
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    proxy-exclusive    4_3_6_3    5_6_1
    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities    201
    ${speed_entity}=    Create Entity    ${entity_speed_filename}    ${entity_id}
    ${speed_entity}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${speed_entity.status_code}

    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entities
@@ -37,15 +33,11 @@ D001_01_exc Create Entity With Exclusive Registration
    ${body}=    Set To Dictionary    ${response.json()}
    Should Not Contain    ${body}    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}    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
+4 −3
Original line number Diff line number Diff line
@@ -10,13 +10,13 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

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


*** Variables ***
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-complete.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld


*** Test Cases ***
@@ -27,6 +27,7 @@ D001_01_inc Create Entity On Both Context Broker And Context Source
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    Wait for redirected request
    ${request_payload}=    Get Request Body
    ${payload_list}=    Evaluate    [json.loads('''${request_payload}''')]    json
    @{entities_id}=    Create List    ${entity_id}
+3 −4
Original line number Diff line number Diff line
@@ -9,14 +9,12 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

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


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


@@ -67,6 +65,7 @@ Setup Entity Id And Registration And Start Context Source Mock Server
    Check Response Status Code    201    ${response2.status_code}
    
    Start Context Source Mock Server

Delete Registrations And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Context Source Registration    ${registration_id2}
+5 −14
Original line number Diff line number Diff line
@@ -8,19 +8,14 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource

Suite Setup          Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Suite Teardown       Delete Created Entity And Registration And Stop Context Source Mock Server
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
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

${entity_payload_filename}              vehicle-speed-attribute.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-without-redirection-ops.jsonld

*** Test Cases ***
D001_02_exc Create Entity Without Redirection Operations
@@ -28,21 +23,17 @@ D001_02_exc Create Entity Without Redirection Operations
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    proxy-exclusive    4_3_6_3    5_6_1

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities    409
    ${response}=    Create Entity    ${entity_speed_filename}    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    409    ${response.status_code}

    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entities
    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
+2 −2
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Suite Setup          Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Suite Teardown       Delete Created Entity And Registration And Stop Context Source Mock Server
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 ***
Loading