diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot index 3d0d9fa0fb4a0b4689342aa8dfeabc35170ecb36..8c8d91202183ba7eca189e141911d7a6e29b875d 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot @@ -1,11 +1,12 @@ *** 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} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot index 168f397cad2db6bd9d25a17e0acc7907b4b632a5..a55452e772d9274b02bf0d267daac23b47485009 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot @@ -1,31 +1,43 @@ *** 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} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot index 3ac2651056c757a000ee83f4cc3f39143879cc2b..514238f25faf05bf0bf85e2e8c13ba187cfe4748 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot @@ -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} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot index 58a65d1ed9f7414146fb55785fab5b5efc226d1c..71e3d751dda9a0586118c5c38a9784bce0d034f8 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot @@ -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 +${building_id_prefix}= urn:ngsi-ld:Building: +${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} diff --git a/data/entities/expectations/two-vehicles-expectation.jsonld b/data/entities/expectations/two-vehicles-expectation.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..66aa4628641744ff859ca1e83cc677f6d27f4641 --- /dev/null +++ b/data/entities/expectations/two-vehicles-expectation.jsonld @@ -0,0 +1,42 @@ +[ + { + "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 diff --git a/data/entities/expectations/vehicle-simple-attributes-core-context-expectation.json b/data/entities/expectations/vehicle-simple-attributes-core-context-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..54eca92534d500d21893510ebaa7c7a8bf8b01da --- /dev/null +++ b/data/entities/expectations/vehicle-simple-attributes-core-context-expectation.json @@ -0,0 +1,17 @@ +{ + "id": "urn:ngsi-ld:Vehicle:3542857210001312", + "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" + } +} \ No newline at end of file diff --git a/data/temporalEntities/entity-operations-after-query.jsonld b/data/temporalEntities/entity-operations-after-query.jsonld index 4eeabb72141bc6c0be3ba5f5a7679350d0773f74..22271295de145a0136b57cce4eb28d736a9c5764 100644 --- a/data/temporalEntities/entity-operations-after-query.jsonld +++ b/data/temporalEntities/entity-operations-after-query.jsonld @@ -1,5 +1,10 @@ { - "type":"Vehicle", - "timerel":"after", - "timeAt":"2020-08-02T12:05:00Z" + "type": "Query", + "entities": [{ + "type": "Vehicle" + }], + "temporalQ": { + "timerel":"after", + "timeAt":"2020-08-02T12:05:00Z" + } } \ No newline at end of file diff --git a/data/temporalEntities/entity-operations-before-query.jsonld b/data/temporalEntities/entity-operations-before-query.jsonld index 03791c34ca4e849f0c83a53e48f74bc5cff153e0..41e11c34f39428a25c80bc5326dd23b246041724 100644 --- a/data/temporalEntities/entity-operations-before-query.jsonld +++ b/data/temporalEntities/entity-operations-before-query.jsonld @@ -1,5 +1,10 @@ { - "type":"Vehicle", - "timerel":"before", - "timeAt":"2020-08-02T12:05:00Z" + "type": "Query", + "entities": [{ + "type": "Vehicle" + }], + "temporalQ": { + "timerel":"before", + "timeAt":"2020-08-02T12:05:00Z" + } } \ No newline at end of file diff --git a/resources/ApiUtils/ContextInformationConsumption.resource b/resources/ApiUtils/ContextInformationConsumption.resource index 7782d2f0bfe6098bf13fd2fb8e287e98d6f64a03..17e702e3aff208adebbe38e8161bca398417f522 100755 --- a/resources/ApiUtils/ContextInformationConsumption.resource +++ b/resources/ApiUtils/ContextInformationConsumption.resource @@ -12,7 +12,9 @@ ${ENTITIES_ENDPOINT_PATH} entities/ ${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH} entityOperations/query ${ENTITIES_TYPES_ENDPOINT_PATH} types +${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json +${CONTENT_TYPE_GEOJSON} application/geo+json ${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/errors/BadRequestData ${ERROR_TYPE_INVALID_REQUEST} https://uri.etsi.org/ngsi-ld/errors/InvalidRequest @@ -86,34 +88,41 @@ Query Entities Query Entities Via POST [Arguments] - ... ${entity_ids}=${EMPTY} - ... ${entity_types}=${EMPTY} - ... ${content_type}=${CONTENT_TYPE_LD_JSON} + ... ${entity_id}=${EMPTY} + ... ${entity_type}=${EMPTY} + ... ${content_type}=${CONTENT_TYPE_JSON} + ... ${accept}=${CONTENT_TYPE_JSON} ... ${attrs}=${EMPTY} ... ${entity_id_pattern}=${EMPTY} - ... ${geoproperty}=${EMPTY} + ... ${geometry_property}=${EMPTY} &{headers}= Create Dictionary - &{params}= Create Dictionary - ${entity_ids_length}= Get Length ${entity_ids} - ${entity_types_length}= Get Length ${entity_types} - ${attrs_length}= Get Length ${attrs} Set To Dictionary ${headers} Content-Type ${content_type} - IF ${entity_ids_length}>0 - Set To Dictionary ${params} id=${entity_ids} + Set To Dictionary ${headers} Accept ${accept} + &{body}= Create Dictionary + Set To Dictionary ${body} type=Query + &{entities}= Create Dictionary + IF '${entity_id}'!='' + Set To Dictionary ${entities} id=${entity_id} END - IF ${entity_types_length}>0 - Set To Dictionary ${params} type=${entity_types} + IF '${entity_type}'!='' + Set To Dictionary ${entities} type=${entity_type} END - IF ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} IF '${entity_id_pattern}'!='' - Set To Dictionary ${params} idPattern=${entity_id_pattern} + Set To Dictionary ${entities} idPattern=${entity_id_pattern} END - IF '${geoproperty}'!='' - Set To Dictionary ${params} geoproperty=${geoproperty} + ${entities_length}= Get Length ${entities} + IF ${entities_length}>0 + ${entities_list}= Create List ${entities} + Set To Dictionary ${body} entities=${entities_list} + END + ${attrs_length}= Get Length ${attrs} + IF ${attrs_length}>0 Set To Dictionary ${body} attrs=${attrs} + IF '${geometry_property}'!='' + Set To Dictionary ${body} geometryProperty=${geometry_property} END ${response}= POST ... url=${url}/${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH} - ... json=${params} + ... json=${body} ... headers=${headers} ... expected_status=any Output ${response} Query Entities Via POST