Commit 2c93364b authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'feature/add-more-one-instance-in-batch-tests' into 'develop'

feat: add tests for batch operations with more than one instance of the same entity

See merge request !127
parents 9de3ca3f 06a8c8da
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can create a batch of entities where two have the same id

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

Test Teardown       Delete Entities


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:


*** Test Cases ***
003_10_01 Create a batch of three valid entities where two have the same id
    [Documentation]    Check that you can create a batch of entities where two have the same id
    [Tags]    be-create    5_6_7    since_v1.5.1
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${second_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${second_entity_id}
    ${first_entity}=    Load Entity    building-minimal-sample.jsonld    ${first_entity_id}
    ${second_entity}=    Load Entity    building-minimal-sample.jsonld    ${second_entity_id}
    @{entities_to_be_created}=    Create List    ${first_entity}    ${second_entity}    ${first_entity}

    ${response}=    Batch Create Entities    @{entities_to_be_created}

    @{expected_successful_entities_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Set Test Variable    @{expected_successful_entities_ids}
    @{expected_failed_entities_ids}=    Create List    ${first_entity_id}
    &{expected_batch_operation_result}=    Create Batch Operation Result
    ...    ${expected_successful_entities_ids}
    ...    ${expected_failed_entities_ids}
    Check Response Status Code    207    ${response.status_code}
    Check Response Body Containing Batch Operation Result    ${expected_batch_operation_result}    ${response.json()}


*** Keywords ***
Delete Entities
    ${response}=    Batch Delete Entities
    ...    entities_ids_to_be_deleted=@{expected_successful_entities_ids}
+38 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can delete a batch of entities with the same id

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

Test Setup          Setup Initial Entity


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:


*** Test Cases ***
006_04_01 Delete a batch of existing entities with the same id
    [Documentation]    Check that you can delete a batch entities with the same id
    [Tags]    be-delete    5_6_10    since_v1.5.1
    ${new_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    @{entities_ids_to_be_deleted}=    Create List    ${entity_id}    ${entity_id}

    ${response}=    Batch Delete Entities    entities_ids_to_be_deleted=@{entities_ids_to_be_deleted}

    @{expected_successful_entities_ids}=    Create List    ${entity_id}
    @{expected_failed_entities_ids}=    Create List    ${entity_id}
    &{response1}=    Create Batch Operation Result
    ...    ${expected_successful_entities_ids}
    ...    ${expected_failed_entities_ids}
    Check Response Status Code    207    ${response.status_code}
    Check Response Body Containing Batch Operation Result    ${response1}    ${response.json()}


*** Keywords ***
Setup Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Create Entity    building-simple-attributes-sample.jsonld    ${entity_id}
    Set Test Variable    ${entity_id}
+37 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can upsert a batch of entities where two have the same id

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

Test Teardown       Delete Entities


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:


*** Test Cases ***
004_07_01 Upsert a batch of three valid entities where two have the same id
    [Documentation]    Check that you can upsert a batch of where two have the same id
    [Tags]    be-upsert    5_6_8    since_v1.5.1
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    ${second_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    ${first_entity}=    Load Entity    building-minimal-sample.jsonld    ${first_entity_id}
    ${second_entity}=    Load Entity    building-minimal-sample.jsonld    ${second_entity_id}
    @{entities_to_be_upserted}=    Create List    ${first_entity}    ${second_entity}    ${first_entity}

    ${response}=    Batch Upsert Entities    @{entities_to_be_upserted}

    @{expected_successful_entities_ids}=    Create List    ${first_entity_id}    ${second_entity_id}
    Set Test Variable    @{expected_successful_entities_ids}
    Check Response Status Code    201    ${response.status_code}
    Check Response Body Containing Array Of URIs set to    ${expected_successful_entities_ids}    ${response.json()}


*** Keywords ***
Delete Entities
    ${response}=    Batch Delete Entities
    ...    entities_ids_to_be_deleted=@{expected_successful_entities_ids}
+38 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/Prov/BE/003_10",
  "test_objective": "Check that you can create a batch of entities where two have the same id",
  "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.6.7",
  "config_id": "",
  "parent_release": "v1.5.1",
  "clauses": [
    "5.6.7"
  ],
  "pics_selection": "",
  "keywords": [
    "Delete Entities"
  ],
  "teardown": "None",
  "initial_condition": "with {\n   the SUT containing an initial state\n}",
  "test_cases": [
    {
      "name": "003_10_01 Create a batch of three valid entities where two have the same id",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/003_10_01",
      "doc": "Check that you can create a batch of entities where two have the same id",
      "tags": [
        "5_6_7",
        "be-create",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": "Delete Entities",
      "template": null,
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Batch Create Entities with Response Status Code set to 207     and\n        Batch Create Entities with Response body containing batch operation result set to '${expected_batch_operation_result}'\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entityOperations/create'\n        method set to 'POST'\n        Request Header['Content-Type'] set to '' and\n payload set to a list of entities to be created\n}",
      "http_verb": "POST",
      "endpoint": "entityOperations/create"
    }
  ],
  "permutations": [],
  "robotpath": "ContextInformation/Provision/BatchEntities/CreateBatchOfEntities",
  "robotfile": "003_10"
}
 No newline at end of file
+38 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/Prov/BE/004_07",
  "test_objective": "Check that you can upsert a batch of entities where two have the same id",
  "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.6.8",
  "config_id": "",
  "parent_release": "v1.5.1",
  "clauses": [
    "5.6.8"
  ],
  "pics_selection": "",
  "keywords": [
    "Delete Entities"
  ],
  "teardown": "None",
  "initial_condition": "with {\n   the SUT containing an initial state\n}",
  "test_cases": [
    {
      "name": "004_07_01 Upsert a batch of three valid entities where two have the same id",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/004_07_01",
      "doc": "Check that you can upsert a batch of where two have the same id",
      "tags": [
        "5_6_8",
        "be-upsert",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": "Delete Entities",
      "template": null,
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Batch Upsert Entities with Response Status Code set to 201     and\n        Batch Upsert Entities with Response Body set to an array of created entities ids\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entityOperations/upsert?options=${update_option}'\n        method set to 'POST'\n        Request batch upsert operation over entity from filename '@{entities_to_be_upserted}' with update_option set to 'replace' and Content-Type set to 'application/ld+json'\n}",
      "http_verb": "POST",
      "endpoint": "entityOperations/upsert?options=${update_option}"
    }
  ],
  "permutations": [],
  "robotpath": "ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities",
  "robotfile": "004_07"
}
 No newline at end of file
Loading