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 dcdc68caa6aa3bc3dd3220a2aa1757a50277bf41..7d9d89803792311857e3e8b539c705d56f1e3a0c 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 e4b15bb5794db60ff6a396cc26a838e683214a0a..319f43221abd49ba334677ff2bd75ec26f55d4e0 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 dbb9d5df920d8655cec01d301f0f98356a5dc0e0..e2feff37a2982d3d21301937be465bebee031f42 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 0000000000000000000000000000000000000000..c025fc16e363ee204d378dc3ce4198356e5c0f25 --- /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 0000000000000000000000000000000000000000..a211beadc0c7c3a90cd0a436c984195f01536b24 --- /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 0000000000000000000000000000000000000000..60a813242597fc535bf2610cbee464bd74e437e2 --- /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 0000000000000000000000000000000000000000..a13e5641e171a51a647732916fa20d13181cc73f --- /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 17e702e3aff208adebbe38e8161bca398417f522..0fbad1d81c11a658dfec8b3bb8b3e2258942c8fd 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