Commit bab4153e authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: query the location property from different type of entities

parent d93c24fd
Loading
Loading
Loading
Loading
+150 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entities found in b2, b3 and b4 can be queried from b1 via Query.
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 ***
${first_vehicle_payload_filename}                     interoperability/vehicle1-full.jsonld
${second_vehicle_payload_filename}                    interoperability/vehicle2-full.jsonld
${first_offstreet_payload_filename}                   interoperability/offstreet-parking1-full.jsonld
${second_offstreet_payload_filename}                  interoperability/offstreet-parking2-full.jsonld
${first_parking_location_name_payload_filename}       interoperability/offstreet-parking1-location-and-name.jsonld
${second_parking_location_name_payload_filename}      interoperability/offstreet-parking2-location-and-name.jsonld
${first_inclusive_registration_payload_file_path}     csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${second_inclusive_registration_payload_file_path}    csourceRegistrations/interoperability/context-source-registration-inclusive-3.jsonld
${first_redirect_registration_payload_file_path}      csourceRegistrations/interoperability/context-source-registration-redirect-2.jsonld
${second_redirect_registration_payload_file_path}     csourceRegistrations/interoperability/context-source-registration-redirect-3.jsonld
${third_redirect_registration_payload_file_path}      csourceRegistrations/interoperability/context-source-registration-redirect-4.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}                                         

*** Test Cases ***
IOP_CNF_02_02 Create Entity In B1 And Query Entity In All Brokers
    [Documentation]    Check that entities can be queried from all brokers.
    [Tags]    6_3    I6_3_2_2    inclusive    redirect    interoperability

    ${response}=    Query Entities    entity_types=OffstreetParking,Vehicle    attrs=location    broker_url=${b1_url}
    Check Response Status Code    200    ${response.status_code}
    &{payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${parking1_payload}=    Get From Dictionary    ${payload}    ${first_parking_entity_id}
    ${parking2_payload}=    Get From Dictionary    ${payload}    ${second_parking_entity_id}
    ${vehicle1_payload}=    Get From Dictionary    ${payload}    ${first_vehicle_entity_id}
    ${vehicle2_payload}=    Get From Dictionary    ${payload}    ${second_vehicle_entity_id}
    Should Contain    ${parking1_payload}    location
    Should Contain    ${parking2_payload}    location
    Should Contain    ${vehicle1_payload}    location
    Should Contain    ${vehicle2_payload}    location

    ${response}=    Query Entities    entity_types=OffstreetParking,Vehicle    attrs=location    broker_url=${b2_url}
    &{first_expected_payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${response}=    Query Entities    entity_types=OffstreetParking,Vehicle    attrs=location    broker_url=${b3_url}
    &{second_expected_payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${response}=    Query Entities    entity_types=OffstreetParking,Vehicle    attrs=location    broker_url=${b4_url}
    &{third_expected_payload}=    Evaluate    {i['id']: i for i in ${response.json()}}

    ${expected_vehicle1}=    Get From Dictionary    ${first_expected_payload}    ${first_vehicle_entity_id}
    ${expected_parking1}=    Get From Dictionary    ${second_expected_payload}    ${first_parking_entity_id}
    ${expected_vehicle2}=    Get From Dictionary    ${third_expected_payload}    ${second_vehicle_entity_id}
    ${expected_parking2}=    Get From Dictionary    ${third_expected_payload}    ${second_parking_entity_id}
    Should Be Equal    ${vehicle1_payload}    ${expected_vehicle1}
    Should Be Equal    ${parking1_payload}    ${expected_parking1}
    Should Be Equal    ${vehicle2_payload}    ${expected_vehicle2}
    Should Be Equal    ${parking2_payload}    ${expected_parking2}

*** Keywords ***
Setup Initial Context Source Registrations
    ${first_parking_entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${first_parking_entity_id}
    ${second_parking_entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${second_parking_entity_id}
    ${first_vehicle_entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${first_vehicle_entity_id}
    ${second_vehicle_entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${second_vehicle_entity_id}

    ${response}=    Create Entity    ${first_vehicle_payload_filename}    ${first_vehicle_entity_id}    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${first_offstreet_payload_filename}    ${first_parking_entity_id}    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${first_parking_location_name_payload_filename}    ${first_parking_entity_id}    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_offstreet_payload_filename}    ${second_parking_entity_id}    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_parking_location_name_payload_filename}    ${second_parking_entity_id}    broker_url=${b4_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_vehicle_payload_filename}    ${second_vehicle_entity_id}    broker_url=${b4_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}
    ...    ${first_inclusive_registration_payload_file_path}
    ...    entity_id=${first_parking_entity_id}
    ...    endpoint=${b2_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_id2}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id2}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${second_inclusive_registration_payload_file_path}
    ...    entity_id=${first_vehicle_entity_id}
    ...    endpoint=${b2_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}
    ...    ${first_redirect_registration_payload_file_path}
    ...    entity_id=${first_parking_entity_id}
    ...    endpoint=${b3_url}
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

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

    ${registration_id5}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id5}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id5}
    ...    ${third_redirect_registration_payload_file_path}
    ...    entity_id=${second_vehicle_entity_id}
    ...    endpoint=${b4_url}
    ${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 Context Source Registration    ${registration_id4}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id5}    broker_url=${b1_url}
    Delete Entity By Id    ${first_parking_entity_id}    broker_url=${b2_url}
    Delete Entity by Id    ${first_vehicle_entity_id}    broker_url=${b2_url}
    Delete Entity By Id    ${first_parking_entity_id}    broker_url=${b3_url}
    Delete Entity By Id    ${second_parking_entity_id}    broker_url=${b3_url}
    Delete Entity By Id    ${second_vehicle_entity_id}    broker_url=${b4_url}
    Delete Entity by Id    ${second_parking_entity_id}    broker_url=${b4_url}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:Inclusive:3",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "type": "Vehicle"
        }
      ]
    }
  ],
  "mode": "inclusive",
  "operations": ["redirectionOps"],
  "endpoint": "xxx",
  "@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
+23 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:Redirect:4",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "type": "Vehicle",
          "id": "urn:ngsi-ld:Vehicle:2"
        }
      ],
      "propertyNames": [
        "location"		
      ]
    }
  ],
  "mode": "redirect",
  "operations": ["redirectionOps"],
  "endpoint": "xxx",
  "@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
+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
+45 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:1",
    "type": "Vehicle",
    "brandName": {
        "type": "Property",
        "value": "Brand1"
    },
    "speed": {
        "type": "Property",
        "value": 0,
        "source": {
            "type": "Property",
            "value": "Speedometer"
        } 
    },
    "isParked": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:OffStreetParking:1",
        "observedAt": "2017-07-29T12:00:04Z"
    },
    "location": {
      "type": "GeoProperty",
      "value": {
        "type": "Point",
        "coordinates": [
          -8.45,
          41.2
        ]
      }
    }, 
    "@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
Loading