Commit 897e075f authored by Ranim Naimi's avatar Ranim Naimi
Browse files

using entity type selection language to query entities with multiple types

parent 0134d819
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Query entities with Entity Type Selection Language.

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

Suite Setup         Setup Initial Entities
Suite Teardown      Delete Initial Entities
Test Template       Query entities with multiple types using Entity Type Selection Language


*** Variables ***
${entity_id_prefix}=            urn:ngsi-ld:MultiTypes:
${first_entity_filename}=       building-simple-attributes-sample.jsonld
${second_entity_filename}=      building-with-different-type-sample.jsonld
${third_entity_filename}=       building-with-two-types-sample.jsonld
${first_entity_type}=           Building
${second_entity_type}=          Parking
${third_entity_type}=           TouristDestination
${options_parameter}=           keyValues


*** Test Cases ***    ENTITY_TYPES_SELECTION    EXPECTED_COUNT
019_08_01 entities first query    ${first_entity_type}    2
019_08_02 entities second query    (${first_entity_type};${third_entity_type})    1
019_08_03 entities third query    ${first_entity_type},${second_entity_type}    3
019_08_04 entities fourth query    ${second_entity_type},${third_entity_type}    2
019_08_05 entities fifth query    (${first_entity_type};${second_entity_type}),${third_entity_type}    1


*** Keywords ***
Query entities with multiple types using Entity Type Selection Language
    [Documentation]    Query entities with Entity Type Selection Language.
    [Tags]    e-query    4_17
    [Arguments]    ${entity_types_selection}    ${expected_count}

    ${response}=    Query Entities
    ...    entity_types=${entity_types_selection}
    ...    context=${ngsild_test_suite_context}
    ...    count=${True}
    ...    options=${options_parameter}

    Check Response Status Code    200    ${response.status_code}
    Check Response Headers Containing NGSILD-Results-Count Equals To    ${expected_count}    ${response.headers}

Setup Initial Entities
    ${first_entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    ${first_entity_filename}
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}
    ${second_entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    ${second_entity_filename}
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}
    ${third_entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${third_entity_id}
    ${create_response3}=    Create Entity Selecting Content Type
    ...    ${third_entity_filename}
    ...    ${third_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response3.status_code}

Delete Initial Entities
    Delete Entity by Id    ${first_entity_id}
    Delete Entity by Id    ${second_entity_id}
    Delete Entity by Id    ${third_entity_id}
+25 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:MultiTypes:randomUUID",
    "type": ["Parking" ],
    "name": {
        "type": "Property",
        "value": "Eiffel Tower"
    },
    "subCategory": {
        "type": "Property",
        "value": "tourism"
    },
    "airQualityLevel": {
        "type": "Property",
        "value": 4,
        "unitCode": "C62",
        "observedAt": "2020-09-09T16:40:00.000Z"
    },
    "almostFull": {
        "type": "Property",
        "value": false
    },
    "@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
+25 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:MultiTypes:randomUUID",
    "type": ["Building", "TouristDestination" ],
    "name": {
        "type": "Property",
        "value": "Eiffel Tower"
    },
    "subCategory": {
        "type": "Property",
        "value": "tourism"
    },
    "airQualityLevel": {
        "type": "Property",
        "value": 4,
        "unitCode": "C62",
        "observedAt": "2020-09-09T16:40:00.000Z"
    },
    "almostFull": {
        "type": "Property",
        "value": false
    },
    "@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
+7 −0
Original line number Diff line number Diff line
@@ -224,6 +224,13 @@ class TestCIConsumptions(TestCase):

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_019_08(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_08.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_08.json'
        difference_file = f'{self.folder_test_suites}/doc/results/out_019_08.json'

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_018_01_01(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/018_01_01.json'