Commit 9cc199be authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add new test for inclusive

parent f00af9b0
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can create a batch of entities on both Context Source and Context Broker thanks to a inclusive registration

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 Created Entity And 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

*** Test Cases ***
D012_01_inc Batch Create Entities With Inclusive Registration
    [Documentation]    Check that if one requests the Context Broker to create a batch of entities that match an inclusive registration, these are created 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_7
    
    Set Stub Reply    POST    /ngsi-ld/v1/entityOperations/create    201
    ${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
    ...    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()}

*** 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}

    ${entity1}=    Load Entity    ${entity_payload_filename}    ${entity_id1}
    ${entity2}=    Load Entity    ${entity_payload_filename}    ${entity_id2}

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

    ${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}
    ${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
    Batch Delete Entities    entities_ids_to_be_deleted=@{expected_entities_ids}
    Delete Context Source Registration    ${registration_id}
    Stop Context Source Mock Server
+43 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/CreateBatchEntities/D012_01_inc",
  "test_objective": "Check that one can create a batch of entities on both Context Source and Context Broker thanks to a inclusive registration",
  "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.7",
  "config_id": "",
  "parent_release": "v1.6.1",
  "clauses": [
    "4.3.3",
    "4.3.6.2",
    "5.6.7"
  ],
  "pics_selection": "",
  "keywords": [
    "Setup Entity Id And Registration And Start Context Source Mock Server",
    "Delete Created Entity And 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 id set to ${entity_id}\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": "D012_01_inc Batch Create Entities With Inclusive Registration",
      "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/CreateBatchEntities/D012_01_inc",
      "doc": "Check that if one requests the Context Broker to create a batch of entities that match an inclusive registration, these are created on the Context Source too",
      "tags": [
        "4_3_3",
        "4_3_6_2",
        "5_6_7",
        "additive-inclusive",
        "cf_06",
        "dist-ops",
        "since_v1.6.1"
      ],
      "setup": "Setup Entity Id And Registration And Start Context Source Mock Server",
      "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server",
      "template": null,
      "http_verb": "POST",
      "endpoint": "entityOperations/create"
    }
  ],
  "permutations": [],
  "robotpath": "DistributedOperations/Provision/BatchEntities/CreateBatchEntities",
  "robotfile": "D012_01_inc"
}
 No newline at end of file