Commit 0d45a7a6 authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add new test case for partial entity creation

parent 8628e242
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entity was created in b3 and b4, but it is not created in b2
Documentation       Verify that the entity is created in b3 and b4, but it is not created in b2

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
@@ -23,7 +23,7 @@ ${b4_url}

*** Test Cases ***
IOP_CNF_03_01 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in the brokers, b1 and b2 should contain most entity attributes, 3b and b4 should only contain the location attribute.
    [Documentation]    Check that entities are created in b1 and b3. The entity is not present in b2 and in b4 there are only some attributes.
    [Tags]    6_1    I6_1_3_1    auxiliary    inclusive    interoperability

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b1_url}    context=${ngsild_test_suite_context}
@@ -86,6 +86,5 @@ Delete Entities And Delete Registrations
    Delete Context Source Registration    ${registration_id2}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id3}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b2_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b3_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b4_url}
 No newline at end of file
+87 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the partial entity is created in b3 and b4, but it is not created in b2

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

Test Setup          Setup Initial Context Source Registrations
Test Teardown       Delete Entities and Delete Registrations

*** Variables ***
${entity_payload_filename}                              interoperability/offstreet-parking1-location-and-name.jsonld
${auxiliary_registration_payload_file_path}             csourceRegistrations/interoperability/context-source-registration-auxiliary-2.jsonld
${first_inclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-inclusive-1.jsonld
${second_inclusive_registration_payload_file_path}      csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}                                         

*** Test Cases ***
IOP_CNF_03_02 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in the brokers, b1 and b2 should contain most entity attributes, 3b and b4 should only contain the location attribute.
    [Tags]    6_1    I6_1_3_2    auxiliary    inclusive    interoperability

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b1_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b2_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    404    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b3_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b4_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    404    ${response.status_code}

*** Keywords ***
Setup Initial Context Source Registrations

    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}
    
    ${registration_id1}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id1}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id1}
    ...    ${auxiliary_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b2_url}
    ...    mode=auxiliary
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id2}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id2}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${first_inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b3_url}
    ...    mode=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id3}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id3}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id3}
    ...    ${second_inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b4_url}
    ...    mode=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

Delete Entities And Delete Registrations
    Delete Context Source Registration    ${registration_id1}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id2}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id3}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b3_url}
 No newline at end of file
+13 −2
Original line number Diff line number Diff line
@@ -29,6 +29,17 @@
    }
  }, 
  "@context": [
      "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
    {
      "OffStreetParking": "https://ngsi-ld-test-suite/context#OffStreetParking",
      "Vehicle": "https://ngsi-ld-test-suite/context#Vehicle",
      "availableSpotsNumber": "https://ngsi-ld-test-suite/context#availableSpotsNumber",
      "brandName": "https://ngsi-ld-test-suite/context#brandName",
      "isParked": "https://ngsi-ld-test-suite/context#isParked",
      "name": "https://ngsi-ld-test-suite/context#name",
      "source": "https://ngsi-ld-test-suite/context#source",
      "speed": "https://ngsi-ld-test-suite/context#speed",
      "totalSpotsNumber": "https://ngsi-ld-test-suite/context#totalSpotsNumber"
    },
    "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld"
  ]
}
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:OffStreetParking:1",
  "type": "OffStreetParking",
  "name": {
    "type": "Property",
    "value": "Downtown One"
  },
  "location": {
    "type": "GeoProperty",
    "value": {
      "type": "Point",
      "coordinates": [
        -8.9,
        42.2
      ] ,
    "observedAt": "2021-04-04T11:45:00Z"
    }
  },
  "@context": [
    {
      "OffStreetParking": "https://ngsi-ld-test-suite/context#OffStreetParking",
      "Vehicle": "https://ngsi-ld-test-suite/context#Vehicle",
      "availableSpotsNumber": "https://ngsi-ld-test-suite/context#availableSpotsNumber",
      "brandName": "https://ngsi-ld-test-suite/context#brandName",
      "isParked": "https://ngsi-ld-test-suite/context#isParked",
      "name": "https://ngsi-ld-test-suite/context#name",
      "source": "https://ngsi-ld-test-suite/context#source",
      "speed": "https://ngsi-ld-test-suite/context#speed",
      "totalSpotsNumber": "https://ngsi-ld-test-suite/context#totalSpotsNumber"
    },
    "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld"
  ]
}
 No newline at end of file
+13 −3
Original line number Diff line number Diff line
@@ -29,7 +29,17 @@
    }
  },
    "@context": [
    "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
  
      {
        "OffStreetParking": "https://ngsi-ld-test-suite/context#OffStreetParking",
        "Vehicle": "https://ngsi-ld-test-suite/context#Vehicle",
        "availableSpotsNumber": "https://ngsi-ld-test-suite/context#availableSpotsNumber",
        "brandName": "https://ngsi-ld-test-suite/context#brandName",
        "isParked": "https://ngsi-ld-test-suite/context#isParked",
        "name": "https://ngsi-ld-test-suite/context#name",
        "source": "https://ngsi-ld-test-suite/context#source",
        "speed": "https://ngsi-ld-test-suite/context#speed",
        "totalSpotsNumber": "https://ngsi-ld-test-suite/context#totalSpotsNumber"
      },
    "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld"
  ]
}
 No newline at end of file