From a6ded4ab2e54d27626cfb0436fef6ab8d3f22888 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 25 Nov 2023 18:54:56 +0100 Subject: [PATCH] fix: tests asking for GeoJSON representation --- .../Entity/QueryEntities/019_02_05.robot | 15 ++-- .../Entity/QueryEntities/019_05.robot | 49 +++++------- .../Entity/RetrieveEntity/018_05.robot | 36 +++++---- ...ding-location-attribute-normalized.geojson | 29 +++++++ ...ding-location-attribute-simplified.geojson | 20 +++++ ...ings-location-attribute-normalized.geojson | 60 +++++++++++++++ ...vehicle-parking-simple-expectation.geojson | 76 +++++++++++++++++++ .../ContextInformationConsumption.resource | 6 ++ 8 files changed, 240 insertions(+), 51 deletions(-) create mode 100644 data/entities/expectations/building-location-attribute-normalized.geojson create mode 100644 data/entities/expectations/building-location-attribute-simplified.geojson create mode 100644 data/entities/expectations/two-buildings-location-attribute-normalized.geojson create mode 100644 data/entities/expectations/vehicle-parking-simple-expectation.geojson diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot index dcdc68ca..7d9d8980 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot @@ -15,27 +15,24 @@ ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: ${parking_id_prefix}= urn:ngsi-ld:OffStreetParking: ${vehicle_filename}= vehicle-simple-attributes-sample.jsonld ${parking_filename}= parking-simple-attributes-sample.jsonld -${expectation_filename}= building-minimal-expectation.json +${expectation_filename}= vehicle-parking-simple-expectation.geojson ${vehicle_entity_type}= https://ngsi-ld-test-suite/context#Vehicle ${parking_entity_type}= https://ngsi-ld-test-suite/context#OffStreetParking -${geometry_property}= location *** Test Cases *** 019_02_05 Query several entities via POST Interaction asking for a GeoJSON representation [Documentation] Check that you can query entitites via POST Interaction asking for a GeoJSON representation [Tags] e-query 5_7_2 - @{entities_ids_to_be_compared}= Create List ${vehicle_entity_id} ${parking_entity_id} ${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} + ... entity_type=${entity_types_to_be_retrieved} ... accept=${CONTENT_TYPE_GEOJSON} - ... geometry_property=${geometry_property} + ... context=${ngsild_test_suite_context} 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()} + Check Response Body Content + ... expectation_filename=${expectation_filename} + ... response_body=${response.json()} *** Keywords *** diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot index e4b15bb5..319f4322 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot @@ -1,63 +1,54 @@ *** Settings *** -Documentation Check that the queried entities by id can be returned in a geoJSON format +Documentation Check that the queried entities by id can be returned in GeoJSON format 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 Initial Entities Suite Teardown Delete Entities *** Variables *** ${building_id_prefix}= urn:ngsi-ld:Building: ${filename}= building-location-attribute-sample.jsonld -${expectation_filename}= building-simple-attributes-simplified-expectation.json +${expectation_filename}= two-buildings-location-attribute-normalized.geojson ${entity_type}= https://ngsi-ld-test-suite/context#Building -${accept_header}= application/geo+json *** Test Cases *** -019_05_01 Get an entity by id that can be returned in a geoJSON format - [Documentation] Check that the queried entities by id can be returned in a geoJSON format +019_05_01 Get an entity by id that can be returned in GeoJSON format + [Documentation] Check that the queried entities by id can be returned in GeoJSON format [Tags] e-query 6_3_7 + ${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 + ... entity_ids=${entities_ids_to_be_retrieved} + ... entity_types=${entity_types_to_be_retrieved} + ... accept=${CONTENT_TYPE_GEOJSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 200 ${response.status_code} + Check Response Body Content + ... expectation_filename=${expectation_filename} + ... response_body=${response.json()} + + +*** Keywords *** +Create Initial Entities ${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} - ${third_entity_id}= Generate Random Entity Id ${building_id_prefix} - Set Suite Variable ${third_entity_id} - ${response}= Create Entity Selecting Content Type - ... ${filename} - ... ${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 - ... entity_ids=${entities_ids_to_be_retrieved} - ... entity_types=${entity_types_to_be_retrieved} - ... accept=${accept_header} - 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} - Delete Entity by Id Returning Response ${third_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot index dbb9d5df..e2feff37 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot @@ -1,38 +1,48 @@ *** Settings *** -Documentation Check that the queried entity by id can be returned in a geoJSON format +Documentation Check that the queried entity by id can be returned in a GeoJSON format 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 Initial Entity Suite Teardown Delete Created Entity +Test Template Retrieve Entity In GeoJSON Representation *** Variables *** ${building_id_prefix}= urn:ngsi-ld:Building: ${filename}= building-location-attribute-sample.jsonld -${expectation_filename}= building-simple-attributes-simplified-expectation.json -${options_parameter}= keyValues -${accept_header}= application/geo+json -*** Test Cases *** -018_05_01 Get an entity by id that can be returned in a geoJSON format - [Documentation] Check that the queried entity by id can be returned in a geoJSON format +*** Test Cases *** OPTIONS EXPECTATION_FILENAME +018_05_01_Simplified [Tags] e-retrieve 6_3_7 + keyValues building-location-attribute-simplified.geojson +018_05_02_Normalized [Tags] e-retrieve 6_3_7 + ${EMPTY} building-location-attribute-normalized.geojson + + +*** Keywords *** +Retrieve Entity In GeoJSON Representation + [Documentation] Check that the queried entity by id can be returned in a GeoJSON format [Tags] e-retrieve 6_3_7 + [Arguments] ${options} ${expectation_filename} + ${response}= Query Entity + ... ${entity_id} + ... ${CONTENT_TYPE_GEOJSON} + ... options=${options} + ... context=${ngsild_test_suite_context} + Check Response Status Code 200 ${response.status_code} + Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response.json()} + +Create Initial Entity ${entity_id}= Generate Random Entity Id ${building_id_prefix} Set Suite Variable ${entity_id} ${response}= Create Entity Selecting Content Type ... ${filename} ... ${entity_id} ... ${CONTENT_TYPE_LD_JSON} - Check Response Status Code 201 ${response.status_code} - ${response}= Query Entity ${entity_id} ${accept_header} options=${options_parameter} - Check Response Status Code 200 ${response.status_code} - Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response.json()} - -*** Keywords *** Delete Created Entity Delete Entity by Id Returning Response ${entity_id} diff --git a/data/entities/expectations/building-location-attribute-normalized.geojson b/data/entities/expectations/building-location-attribute-normalized.geojson new file mode 100644 index 00000000..c025fc16 --- /dev/null +++ b/data/entities/expectations/building-location-attribute-normalized.geojson @@ -0,0 +1,29 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } +} diff --git a/data/entities/expectations/building-location-attribute-simplified.geojson b/data/entities/expectations/building-location-attribute-simplified.geojson new file mode 100644 index 00000000..a211bead --- /dev/null +++ b/data/entities/expectations/building-location-attribute-simplified.geojson @@ -0,0 +1,20 @@ +{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": "Eiffel Tower", + "subCategory": "tourism", + "location": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } +} diff --git a/data/entities/expectations/two-buildings-location-attribute-normalized.geojson b/data/entities/expectations/two-buildings-location-attribute-normalized.geojson new file mode 100644 index 00000000..60a81324 --- /dev/null +++ b/data/entities/expectations/two-buildings-location-attribute-normalized.geojson @@ -0,0 +1,60 @@ +{ + "type": "FeatureCollection", + "features": [{ + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } + }, { + "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + }, + "properties": { + "type": "Building", + "name": { + "type": "Property", + "value": "Eiffel Tower" + }, + "subCategory": { + "type": "Property", + "value": "tourism" + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [13.3986, 52.5547] + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } + }] +} diff --git a/data/entities/expectations/vehicle-parking-simple-expectation.geojson b/data/entities/expectations/vehicle-parking-simple-expectation.geojson new file mode 100644 index 00000000..a13e5641 --- /dev/null +++ b/data/entities/expectations/vehicle-parking-simple-expectation.geojson @@ -0,0 +1,76 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "id": "urn:ngsi-ld:Vehicle:9584898452850406", + "type": "Feature", + "properties": { + "type": "Vehicle", + "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://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } + }, + { + "id": "urn:ngsi-ld:OffStreetParking:8449859096747487", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -8.5, + 41.2 + ] + }, + "properties": { + "type": "OffStreetParking", + "name": { + "type": "Property", + "value": "Downtown One" + }, + "availableSpotNumber": { + "type": "Property", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Camera:C1" + }, + "reliability": { + "type": "Property", + "value": 0.7 + }, + "value": 121, + "observedAt": "2017-07-29T12:05:02Z" + }, + "totalSpotNumber": { + "type": "Property", + "value": 200 + }, + "location": { + "type": "GeoProperty", + "value": { + "type": "Point", + "coordinates": [ + -8.5, + 41.2 + ] + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } + } + ] +} diff --git a/resources/ApiUtils/ContextInformationConsumption.resource b/resources/ApiUtils/ContextInformationConsumption.resource index 17e702e3..0fbad1d8 100755 --- a/resources/ApiUtils/ContextInformationConsumption.resource +++ b/resources/ApiUtils/ContextInformationConsumption.resource @@ -92,12 +92,18 @@ Query Entities Via POST ... ${entity_type}=${EMPTY} ... ${content_type}=${CONTENT_TYPE_JSON} ... ${accept}=${CONTENT_TYPE_JSON} + ... ${context}=${EMPTY} ... ${attrs}=${EMPTY} ... ${entity_id_pattern}=${EMPTY} ... ${geometry_property}=${EMPTY} &{headers}= Create Dictionary Set To Dictionary ${headers} Content-Type ${content_type} Set To Dictionary ${headers} Accept ${accept} + IF '${context}'!='' + Set To Dictionary + ... ${headers} + ... Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + END &{body}= Create Dictionary Set To Dictionary ${body} type=Query &{entities}= Create Dictionary -- GitLab