From 5d7f6d9711dc0dbad660ff8369f5087eda36d5a9 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Thu, 11 Mar 2021 18:47:47 +0000 Subject: [PATCH] reviewed query entities tests --- .../Consumption/Entity/019_01_04.robot | 4 +-- .../Consumption/Entity/019_02_02.robot | 5 +-- .../Consumption/Entity/019_02_03.robot | 4 +-- .../Consumption/Entity/019_04.robot | 2 +- .../Consumption/Entity/019_05.robot | 2 +- .../Consumption/Entity/019_06.robot | 2 +- .../Provision/EntityAttributes/010_01.robot | 36 +++++++++++++------ .../Provision/EntityAttributes/010_02.robot | 8 ++--- ...l-datasetid-different-type-fragment.jsonld | 5 +-- resources/ApiUtils.resource | 9 +++++ 10 files changed, 49 insertions(+), 28 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_01_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_01_04.robot index bc6823c2..907b16f2 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_01_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_01_04.robot @@ -26,10 +26,10 @@ Query several entities based on attribute names Check Response Status Code 201 ${response['status']} ${attributes_to_be_retrieved}= Catenate SEPARATOR=, ${attribute_airqualitylevel} ${attribute_subcategory} - ${entities_ids_to_be_retrieved}= Catenate SEPARATOR=, ${first_entity_id} + @{entities_ids_to_be_compared}= Create List ${first_entity_id} ${response}= Query Entities attrs=${attributes_to_be_retrieved} Check Response Status Code 200 ${response['status']} - Check Response Body Containing List Containing Entity elements ${expectation_filename} ${entities_ids_to_be_retrieved} ${response['body']} + Check Response Body Containing List Containing Entity elements ${expectation_filename} ${entities_ids_to_be_compared} ${response['body']} [Teardown] Delete Entities ${first_entity_id} ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_02.robot index f2aec860..f6af3e50 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_02.robot @@ -16,7 +16,6 @@ ${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 *** 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 @@ -36,11 +35,9 @@ Query several entities via POST Interaction based on the entities types ${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']} - @{entities_ids_to_be_retrieved}= Catenate SEPARATOR=, ${building_entity_id} ${vehicle_entity_id} Check Response Body Containing List Containing Entity elements ${expectation_filename} ${entity_types_to_be_compared} ${response['body']} - [Teardown] Delete Entities ${building_entity_id} ${vehicle_entity_id} ${parking_entity_id} - + [Teardown] Delete Entities ${building_entity_id} ${vehicle_entity_id} ${parking_entity_id} *** Keywords *** Delete Entities diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_03.robot index 9b5e746c..438c15b9 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_02_03.robot @@ -24,15 +24,13 @@ Query several entities via POST Interaction based on the given id pattern Check Response Status Code 201 ${response['status']} @{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}= Create List ${entity_type} + ${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']} Check Response Body Containing List Containing Entity elements ${expectation_filename} ${entities_ids_to_be_compared} ${response['body']} [Teardown] Delete Entities ${first_entity_id} ${second_entity_id} - *** Keywords *** Delete Entities [Arguments] ${first_entity_id} ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_04.robot index 27d45e27..514da40c 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_04.robot @@ -28,7 +28,7 @@ Query entities in a simplified representation @{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}= Create List ${entity_type} + ${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} options=${options_parameter} Check Response Status Code 200 ${response['status']} Check Response Body Containing List Containing Entity elements ${expectation_filename} ${entities_ids_to_be_compared} ${response['body']} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_05.robot index 0a32c62e..a48764cb 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_05.robot @@ -28,7 +28,7 @@ Get an entity by id that can be returned in a geoJSON format @{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}= Create List ${entity_type} + ${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']} Check Response Body Containing List Containing Entity elements ${expectation_filename} ${entities_ids_to_be_compared} ${response['body']} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_06.robot index d23a8401..625df83a 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_06.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/019_06.robot @@ -27,7 +27,7 @@ Query entities specifying a maximum number of results Check Response Status Code 201 ${response['status']} ${entities_ids_to_be_retrieved}= Catenate SEPARATOR=, ${first_entity_id} ${second_entity_id} ${third_entity_id} - @{entity_types_to_be_retrieved}= Create List ${entity_type} + ${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} limit=${limit} Check Response Status Code 200 ${response['status']} @{entities_ids_to_be_compared}= Create List ${first_entity_id} ${second_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_01.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_01.robot index 759b23ab..2945ae8e 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_01.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_01.robot @@ -4,21 +4,37 @@ Resource ${EXECDIR}/resources/ApiUtils.resource Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource -Test Template Append Attributes - *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: ${filename}= vehicle-speed-two-datasetid-sample.jsonld -*** Test Cases *** STATUS_CODE OVERWRITE FRAGMENT_FILENAME EXPECTATION_FILENAME -010_01_01_Append entity attributes 204 ${EMPTY} vehicle-attribute-to-add-fragment.jsonld ${EMPTY} -010_01_02_Append entity attributes 207 noOverwrite vehicle-attribute-to-add-fragment.jsonld add-attribute-expectation.jsonld -010_01_03_Append entity attributes 204 ${EMPTY} vehicle-speed-different-datasetid-fragment.jsonld ${EMPTY} -010_01_04_Append entity attributes 204 noOverwrite vehicle-speed-different-datasetid-fragment.jsonld ${EMPTY} +*** Test Cases *** +010_01_01_Append entity attributes + Append Attributes Without Params 204 vehicle-attribute-to-add-fragment.jsonld +010_01_02_Append entity attributes + Append Attributes With Params 207 vehicle-attribute-to-add-fragment.jsonld add-attribute-expectation.jsonld +010_01_03_Append entity attributes + Append Attributes Without Params 204 vehicle-speed-different-datasetid-fragment.jsonld +010_01_04_Append entity attributes + Append Attributes With Params 204 vehicle-speed-different-datasetid-fragment.jsonld ${EMPTY} *** Keywords *** -Append Attributes - [Arguments] ${status_code} ${overwrite} ${fragment_filename} ${expectation_filename} +Append Attributes Without Params + [Arguments] ${status_code} ${fragment_filename} + [Documentation] Check that you can append entity attributes + [Tags] /entities/{entityId}/attrs/ 5_6_3 + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Append Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} + +Append Attributes With Params + [Arguments] ${status_code} ${fragment_filename} ${expectation_filename} [Documentation] Check that you can append entity attributes [Tags] /entities/{entityId}/attrs/ 5_6_3 @@ -26,7 +42,7 @@ Append Attributes ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${response['status']} - ${response}= Append Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${overwrite} + ${response}= Append Entity Attributes With Parameters ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} noOverwrite Check Response Status Code ${status_code} ${response['status']} Run Keyword If "${expectation_filename}"!="${EMPTY}" Check Response Body Content ${expectation_filename} ${response['body']} diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_02.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_02.robot index 3564e43f..67bb6c34 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_02.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010_02.robot @@ -12,10 +12,10 @@ ${status_code}= 400 ${invalid_fragment_filename}= invalid-fragment.jsonld *** Test Cases *** -#010_02_01_Append entity attributes if the entity Id is not present -# Append Attributes ${EMPTY} -#010_02_02_Append entity attributes if the Entity Id is not a valid URI -# Append Attributes thisisaninvaliduri +010_02_01_Append entity attributes if the entity Id is not present + Append Attributes ${EMPTY} +010_02_02_Append entity attributes if the Entity Id is not a valid URI + Append Attributes thisisaninvaliduri 010_02_03_Append entity attributes with invalid entity fragments Append entity attributes with invalid entity fragments diff --git a/data/entities/fragmentEntities/vehicle-speed-equal-datasetid-different-type-fragment.jsonld b/data/entities/fragmentEntities/vehicle-speed-equal-datasetid-different-type-fragment.jsonld index e104e4d0..e865fd84 100644 --- a/data/entities/fragmentEntities/vehicle-speed-equal-datasetid-different-type-fragment.jsonld +++ b/data/entities/fragmentEntities/vehicle-speed-equal-datasetid-different-type-fragment.jsonld @@ -8,6 +8,7 @@ }, "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" }, - "@context": - "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld" + "@context": [ + "https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld" + ] } \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 74de3e93..42a29b9b 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -125,6 +125,15 @@ Create Entity Selecting Content Type [return] ${request} ${response} Append Entity Attributes + [Arguments] ${id} ${fragment_filename} ${content_type} + &{headers}= Create Dictionary Content-Type=${content_type} + ${fragment_payload}= Load Json From File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} + ${response}= POST ${ENTITIES_ENDPOINT_PATH}${id}/attrs/ body=${fragment_payload} headers=${headers} + Output request + Output response + [return] ${response} + +Append Entity Attributes With Parameters [Arguments] ${id} ${fragment_filename} ${content_type} ${options} &{headers}= Create Dictionary Content-Type=${content_type} ${fragment_payload}= Load Json From File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} -- GitLab