Commit 6e1181b6 authored by Benedetta Arena's avatar Benedetta Arena
Browse files

fix: change tests following review

parent dce95ecc
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -16,18 +16,20 @@ Test Teardown Delete Created Entity And Registration And Stop Context Sour
*** Variables ***
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${entity_speed_payload_filename}        vehicle-speed-attribute.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld
${entity_pattern}                       urn:ngsi-ld:Vehicle:*
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld

*** Test Cases ***
D012_01_exc Batch Create Entities With Exclusive Registration
    [Documentation]    Check that if one requests the Context Broker to create a batch of entities that match an exclusive registration, these are created on the Context Source too
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_6_7
    
    ${speed_entity1}=    Load Entity    ${entity_speed_payload_filename}    ${entity_id1}
    ${speed_entity2}=    Load Entity    ${entity_speed_payload_filename}    ${entity_id2}
    @{entities_to_be_created}=    Create List    ${speed_entity1}    ${speed_entity2}
    @{expected_entities_ids}=    Create List    ${entity_id1}    ${entity_id2}
    ${first_speed_entity}=    Load Entity    ${entity_speed_payload_filename}    ${first_entity_id}
    ${second_speed_entity}=    Load Entity    ${entity_speed_payload_filename}    ${second_entity_id}
    @{entities_to_be_created}=    Create List    ${first_speed_entity}    ${second_speed_entity}
    @{expected_entities_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Set Suite Variable    @{entities_to_be_created}
    Set Suite Variable    @{expected_entities_ids}

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entityOperations/create    201
    ${response}=    Batch Create Entities
@@ -39,14 +41,14 @@ D012_01_exc Batch Create Entities With Exclusive Registration

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

    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id1}    local=true
    ${response}=    Create Entity    ${entity_payload_filename}    ${first_entity_id}    local=true
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id2}    local=true
    ${response}=    Create Entity    ${entity_payload_filename}    ${second_entity_id}    local=true
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
@@ -54,7 +56,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${EMPTY}
    ...    entity_pattern=${entity_pattern}
    ...    mode=exclusive
    ...    endpoint=/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
+19 −14
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ Test Teardown Delete Created Entity And Registration And Stop Context Sour

*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld
${entity_pattern}                       urn:ngsi-ld:Vehicle:*
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld

*** Test Cases ***
D012_01_inc Batch Create Entities With Inclusive Registration
@@ -26,30 +27,34 @@ D012_01_inc Batch Create Entities With Inclusive Registration
    ${response}=    Batch Create Entities
    ...    @{entities_to_be_created}
    Check Response Status Code    201    ${response.status_code}
    Check Response Body Containing Array Of URIs set to    @{expected_entities_ids}    ${response.json()}

    ${entities_to_be_queried}=    Catenate    SEPARATOR=,    ${entity_id1}    ${entity_id2}
    ${response1}=    Query Entities
    ${stub_count}=    Get Stub Count    POST    /ngsi-ld/v1/entityOperations/create
    Should Be Equal    ${stub_count}    1

    @{ignore_keys}=    Create List    @context    speed
    ${entities_to_be_queried}=    Catenate    SEPARATOR=,    ${first_entity_id}    ${second_entity_id}
    ${response}=    Query Entities
    ...    entity_ids=${entities_to_be_queried}
    ...    entity_types=Vehicle
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Created Resources Set To
    ...    expected_resources=${entities_to_be_created}
    ...    response_body=${response1.json()}
    ...    response_body=${response.json()}
    ...    ignored_keys=@{ignore_keys}

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

    ${entity1}=    Load Entity    ${entity_payload_filename}    ${entity_id1}
    ${entity2}=    Load Entity    ${entity_payload_filename}    ${entity_id2}
    ${first_entity}=    Load Entity    ${entity_payload_filename}    ${first_entity_id}
    ${second_entity}=    Load Entity    ${entity_payload_filename}    ${second_entity_id}

    @{entities_to_be_created}=    Create List    ${entity1}    ${entity2}
    @{expected_entities_ids}=    Create List    ${entity_id1}    ${entity_id2}
    @{entities_to_be_created}=    Create List    ${first_entity}    ${second_entity}
    @{expected_entities_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Set Suite Variable    @{entities_to_be_created}
    Set Suite Variable    @{expected_entities_ids}

@@ -58,7 +63,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${EMPTY}
    ...    entity_pattern=${entity_pattern}
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

+16 −13
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can create a batch of entities on the both Context Source thanks to a redirect registration
Documentation       Check that one can create a batch of entities on both Context Source thanks to a redirect registration

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
@@ -15,17 +15,20 @@ Test Teardown Delete Registration And Stop Context Source Mock Server

*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld
${entity_pattern}                       urn:ngsi-ld:Vehicle:*
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld

*** Test Cases ***
D012_01_red Batch Create Entities With Redirect Registration
    [Documentation]    Check that if one requests the Context Broker to create a batch of entities that match a redirect registration, these are created on the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_6_7
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_7

    ${entity1}=    Load Entity    ${entity_speed_payload_filename}    ${entity_id1}
    ${entity2}=    Load Entity    ${entity_speed_payload_filename}    ${entity_id2}
    @{entities_to_be_created}=    Create List    ${entity1}    ${entity2}
    ${first_entity}=    Load Entity    ${entity_payload_filename}    ${first_entity_id}
    ${second_entity}=    Load Entity    ${entity_payload_filename}    ${second_entity_id}
    @{entities_to_be_created}=    Create List    ${first_entity}    ${second_entity}
    @{expected_entities_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Set Suite Variable    @{entities_to_be_created}
    Set Suite Variable    @{expected_entities_ids}

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entityOperations/create    201
    Set Stub Reply    POST    /broker2/ngsi-ld/v1/entityOperations/create    201
@@ -40,17 +43,17 @@ D012_01_red Batch Create Entities With Redirect Registration

*** Keywords ***
Setup Entity Id And Registration And Start Context Source Mock Server
    ${entity_id1}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id1}
    ${entity_id2}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id2}
    ${first_entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${first_entity_id}
    ${second_entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${second_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=${EMPTY}
    ...    entity_pattern=${entity_pattern}
    ...    mode=redirect
    ...    endpoint=/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
@@ -61,7 +64,7 @@ Setup Entity Id And Registration And Start Context Source Mock Server
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${registration_payload_file_path}
    ...    entity_id=${EMPTY}
    ...    entity_pattern=${entity_pattern}
    ...    mode=redirect
    ...    endpoint=/broker2
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
+20 −0
Original line number Diff line number Diff line

{
  "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "idPattern": "urn:ngsi-ld:Vehicle:*",
          "type": "Vehicle"
        }
        ]
    }
  ],
  "operations": ["redirectionOps"],
  "endpoint": "http://my.csource.org:1026/",
  "@context":[
    "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
 ]
}
 No newline at end of file
+21 −0
Original line number Diff line number Diff line

{
  "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "idPattern": "urn:ngsi-ld:Vehicle:*",
          "type": "Vehicle"
        }
     ],
      "propertyNames":["speed"]
    }
  ],
  "operations": ["redirectionOps"],
  "endpoint": "http://my.csource.org:1026/",
  "@context":[
    "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
 ]
}
 No newline at end of file
Loading