Commit d34f4182 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'fix/query-entities-via-post' into 'develop'

fix(019_02): query entities via POST not using the correct syntax

See merge request !112
parents a722d94f 4a4b748e
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can query several entities via POST Interaction based on ids
Documentation       Check that you can query one entity via POST Interaction based on id

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

Suite Setup         Create Entities
Suite Teardown      Delete Entities


@@ -17,9 +18,22 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building


*** Test Cases ***
019_02_01 Query several entities via POST Interaction based on ids
    [Documentation]    Check that you can query several entities via POST Interaction based on ids
019_02_01 Query one entity via POST Interaction based on id
    [Documentation]    Check that you can query one entity via POST Interaction based on id
    [Tags]    e-query    5_7_2
    @{entities_ids_to_be_compared}=    Create List    ${first_entity_id}
    ${response}=    Query Entities Via POST
    ...    entity_id=${first_entity_id}
    ...    entity_type=${entity_type}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity elements
    ...    ${expectation_filename}
    ...    ${entities_ids_to_be_compared}
    ...    ${response.json()}


*** Keywords ***
Create Entities
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${response}=    Create Entity Selecting Content Type
@@ -41,20 +55,7 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building
    ...    ${third_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    @{entities_ids_to_be_compared}=    Create List    ${first_entity_id}    ${second_entity_id}
    ${entities_ids_to_be_retrieved}=    Catenate    SEPARATOR=,    ${first_entity_id}    ${second_entity_id}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_type}
    ${response}=    Query Entities Via POST
    ...    entity_ids=${entities_ids_to_be_retrieved}
    ...    entity_types=${entity_types_to_be_retrieved}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity elements
    ...    ${expectation_filename}
    ...    ${entities_ids_to_be_compared}
    ...    ${response.json()}


*** Keywords ***
Delete Entities
    Delete Entity by Id Returning Response    ${first_entity_id}
    Delete Entity by Id Returning Response    ${second_entity_id}
+27 −25
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can query several entities via POST Interaction based on the entities types
Documentation       Check that you can query several entities via POST Interaction based on the entity type

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

Suite Setup         Create Entities
Suite Teardown      Delete Entities


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${parking_id_prefix}=       urn:ngsi-ld:OffStreetParking:
${building_filename}=       building-minimal-sample.jsonld
${vehicle_filename}=        vehicle-simple-attributes-sample.jsonld
${parking_filename}=        parking-simple-attributes-sample.jsonld
${expectation_filename}=    two-types-vehicle-offstreetparking-expectation.jsonld
${expectation_filename}=    two-vehicles-expectation.jsonld
${building_entity_type}=    https://ngsi-ld-test-suite/context#Building
${vehicle_entity_type}=     https://ngsi-ld-test-suite/context#Vehicle
${parking_entity_type}=     https://ngsi-ld-test-suite/context#OffStreetParking


*** Test Cases ***
019_02_02 Query several entities via POST Interaction based on the entities types
    [Documentation]    Check that you can query several entities via POST Interaction based on the entities types
    [Documentation]    Check that you can query several entities via POST Interaction based on the entity type
    [Tags]    e-query    5_7_2
    ${entities_ids_to_be_compared}=    Create List    ${first_vehicle_entity_id}    ${second_vehicle_entity_id}
    ${response}=    Query Entities Via POST
    ...    entity_type=${vehicle_entity_type}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity Elements With Different Types
    ...    ${expectation_filename}
    ...    ${entities_ids_to_be_compared}
    ...    ${response.json()}
    ...    ignore_core_context_version=True


*** Keywords ***
Create Entities
    ${building_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${building_entity_id}
    ${response}=    Create Entity Selecting Content Type
@@ -33,32 +45,22 @@ ${parking_entity_type}= https://ngsi-ld-test-suite/context#OffStreetParking
    ...    ${building_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${vehicle_entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Suite Variable    ${vehicle_entity_id}
    ${first_vehicle_entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Suite Variable    ${first_vehicle_entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${vehicle_filename}
    ...    ${vehicle_entity_id}
    ...    ${first_vehicle_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${parking_entity_id}=    Generate Random Entity Id    ${parking_id_prefix}
    Set Suite Variable    ${parking_entity_id}
    ${second_vehicle_entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Suite Variable    ${second_vehicle_entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${parking_filename}
    ...    ${parking_entity_id}
    ...    ${vehicle_filename}
    ...    ${second_vehicle_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    @{entity_types_to_be_compared}=    Create List    ${vehicle_entity_type}    ${parking_entity_type}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${vehicle_entity_type}    ${parking_entity_type}
    ${response}=    Query Entities Via POST    entity_types=${entity_types_to_be_retrieved}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity elements
    ...    ${expectation_filename}
    ...    ${entity_types_to_be_compared}
    ...    ${response.json()}


*** Keywords ***
Delete Entities
    Delete Entity by Id Returning Response    ${building_entity_id}
    Delete Entity by Id Returning Response    ${vehicle_entity_id}
    Delete Entity by Id Returning Response    ${parking_entity_id}
    Delete Entity by Id Returning Response    ${first_vehicle_entity_id}
    Delete Entity by Id Returning Response    ${second_vehicle_entity_id}
+14 −12
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Suite Setup         Create Entities
Suite Teardown      Delete Entities


@@ -21,6 +22,19 @@ ${entity_id_pattern}= urn:ngsi-ld:Building:.*
019_02_03 Query several entities via POST Interaction based on the given id pattern
    [Documentation]    Check that you can query several entities via POST Interaction based on the given id pattern
    [Tags]    e-query    5_7_2
    @{entities_ids_to_be_compared}=    Create List    ${first_entity_id}    ${second_entity_id}
    ${response}=    Query Entities Via POST
    ...    entity_id_pattern=${entity_id_pattern}
    ...    entity_type=${entity_type}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity elements
    ...    ${expectation_filename}
    ...    ${entities_ids_to_be_compared}
    ...    ${response.json()}


*** Keywords ***
Create Entities
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${response}=    Create Entity Selecting Content Type
@@ -35,19 +49,7 @@ ${entity_id_pattern}= urn:ngsi-ld:Building:.*
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    @{entities_ids_to_be_compared}=    Create List    ${first_entity_id}    ${second_entity_id}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_type}
    ${response}=    Query Entities Via POST
    ...    entity_id_pattern=${entity_id_pattern}
    ...    entity_types=${entity_types_to_be_retrieved}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity elements
    ...    ${expectation_filename}
    ...    ${entities_ids_to_be_compared}
    ...    ${response.json()}


*** Keywords ***
Delete Entities
    Delete Entity by Id Returning Response    ${first_entity_id}
    Delete Entity by Id Returning Response    ${second_entity_id}
+29 −27
Original line number Diff line number Diff line
@@ -6,49 +6,51 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Suite Setup         Create Entities
Suite Teardown      Delete Entities


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:
${filename}=                        building-minimal-sample.jsonld
${expectation_filename}=            building-minimal-expectation.json
${attribute_airqualitylevel}=       https://ngsi-ld-test-suite/context#airQualityLevel
${attribute_subcategory}=           https://ngsi-ld-test-suite/context#subCategory
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${building_filename}=       building-minimal-sample.jsonld
${vehicle_filename}=        vehicle-simple-attributes-sample.jsonld
${expectation_filename}=    vehicle-simple-attributes-core-context-expectation.json
${attribute_brandname}=     https://ngsi-ld-test-suite/context#brandName
${attribute_isparked}=      https://uri.etsi.org/ngsi-ld/default-context/isParked


*** Test Cases ***
019_02_04 Query several entities via POST Interaction based on attribute names
    [Documentation]    Check that you can query several entities via POST Interaction based on attribute names
    [Tags]    e-query    5_7_2
    ${first_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${second_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${second_entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${attributes_to_be_retrieved}=    Catenate
    ...    SEPARATOR=,
    ...    ${attribute_airqualitylevel}
    ...    ${attribute_subcategory}
    @{entities_ids_to_be_retrieved}=    Create List    ${first_entity_id}    ${second_entity_id}
    @{attributes_to_be_retrieved}=    Create List    ${attribute_brandname}    ${attribute_isparked}
    @{entities_ids_to_be_retrieved}=    Create List    ${vehicle_entity_id}
    ${response}=    Query Entities Via POST    attrs=${attributes_to_be_retrieved}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity elements
    Check Response Body Containing List Containing Entity Elements
    ...    ${expectation_filename}
    ...    ${entities_ids_to_be_retrieved}
    ...    ${response.json()}


*** Keywords ***
Create Entities
    ${building_entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${building_entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${building_filename}
    ...    ${building_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${vehicle_entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Suite Variable    ${vehicle_entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${vehicle_filename}
    ...    ${vehicle_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}

Delete Entities
    Delete Entity by Id Returning Response    ${first_entity_id}
    Delete Entity by Id Returning Response    ${second_entity_id}
    Delete Entity by Id Returning Response    ${building_entity_id}
    Delete Entity by Id Returning Response    ${vehicle_entity_id}
+42 −0
Original line number Diff line number Diff line
[
    {
        "id": "urn:ngsi-ld:Vehicle:8012188779712372",
        "type": "https://ngsi-ld-test-suite/context#Vehicle",
        "https://ngsi-ld-test-suite/context#brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "providedBy": {
                "type": "Relationship",
                "object": "urn:ngsi-ld:Person:Bob"
            },
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z"
        },
        "@context": [
            "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld"
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:8012188779712372",
        "type": "https://ngsi-ld-test-suite/context#Vehicle",
        "https://ngsi-ld-test-suite/context#brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "providedBy": {
                "type": "Relationship",
                "object": "urn:ngsi-ld:Person:Bob"
            },
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z"
        },
        "@context": [
            "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld"
        ]
    }
]
 No newline at end of file
Loading