From 76e35065a386f9d0c7a1af7ba745534b62236dae Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Tue, 19 Jan 2021 17:07:00 +0000 Subject: [PATCH] added append, update entity attributes and partial update entity attributes suites --- .../Provision/Entities/CreateEntity/001.robot | 8 ++-- .../Provision/Entities/CreateEntity/002.robot | 13 +++--- .../Provision/Entities/CreateEntity/003.robot | 5 +-- .../Provision/Entities/DeleteEntity/005.robot | 2 +- .../Provision/EntityAttributes/001.robot | 13 +++--- .../Provision/EntityAttributes/002.robot | 11 ++--- .../Provision/EntityAttributes/002_03.robot | 6 +-- .../Provision/EntityAttributes/003.robot | 2 +- .../Provision/EntityAttributes/004.robot | 13 +++--- .../Provision/EntityAttributes/005_03.robot | 6 +-- .../Provision/EntityAttributes/006.robot | 4 +- .../Provision/EntityAttributes/007.robot | 33 ++++++++++++++ .../Provision/EntityAttributes/008.robot | 42 ++++++++++++++++++ .../Provision/EntityAttributes/009.robot | 43 +++++++++++++++++++ ...ibutes-sample-append-expectation-01.jsonld | 38 +--------------- ...ibutes-sample-append-expectation-02.jsonld | 36 +++++----------- .../vehicle-fragment-all-empty-sample.jsonld | 2 + ...gment-attribute-name-missing-sample.jsonld | 19 ++++++++ ...fragment-different-datasetid-sample.jsonld | 4 +- ...cle-fragment-empty-datasetid-sample.jsonld | 14 ++++++ ...ual-datasetid-different-type-sample.jsonld | 15 +++++++ ...cle-fragment-equal-datasetid-sample.jsonld | 15 +++++++ ...e-fragment-invalid-datasetid-sample.jsonld | 15 +++++++ ...icle-fragment-same-datasetid-sample.jsonld | 4 +- resources/ApiUtils.resource | 17 ++++++-- resources/AssertionUtils.resource | 10 ++++- 26 files changed, 277 insertions(+), 113 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/007.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/008.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/009.robot create mode 100644 data/entities/fragmentEntities/vehicle-fragment-all-empty-sample.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-fragment-attribute-name-missing-sample.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-fragment-empty-datasetid-sample.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-different-type-sample.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-sample.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-fragment-invalid-datasetid-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot index 721c3d99..6fa0cd12 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot @@ -9,20 +9,18 @@ Test Template Create Entity Scenarios *** Variable *** ${building_id_prefix}= urn:ngsi-ld:Building: -*** Test Cases *** FILENAME CONTENT_TYPE +*** Test Cases *** FILENAME CONTENT_TYPE 001_01_MinimalEntity building-minimal-without-context-sample.jsonld application/json 001_02_EntityWithSimpleProperties building-simple-attributes-sample.jsonld application/ld+json 001_03_EntityWithRelationshipsProperties building-relationship-of-property-sample.jsonld application/ld+json -#001_04_EntityWithNoContext building-minimal-without-context-sample.jsonld application/ld+json +001_04_EntityWithNoContext building-minimal-without-context-sample.jsonld application/ld+json 001_05_EntityWithLocationAttribute building-location-attribute.jsonld application/ld+json - - *** Keywords *** Create Entity Scenarios [Arguments] ${filename} ${content_type} [Documentation] Check that you can create an entity - [Tags] mandatory entityOperations + [Tags] mandatory ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot index 8885ef5d..e552177c 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot @@ -5,18 +5,19 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource Test Template Create Entity With Invalid Request Scenarios -*** Test Cases *** FILENAME PROBLEM_TYPE EXPECTED_CODE -002_01_InvalidJson invalid-json-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST} 406 -002_02_EmptyJson empty-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA} 400 +*** Test Cases *** FILENAME +002_01_InvalidJson invalid-json-sample.jsonld +002_02_EmptyJson empty-sample.jsonld +002_03_EntityWithNoContext building-minimal-without-context-sample.jsonld *** Keywords *** Create Entity With Invalid Request Scenarios - [Arguments] ${filename} ${problem_type} ${expected_code} + [Arguments] ${filename} [Documentation] Check that you cannot create an entity with an invalid request [Tags] mandatory Request Entity From File ${filename} - Check RL Response Status Code Set To Expected Code ${expected_code} - Check RL Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${problem_type} + Check RL Response Status Code Set To Expected Code 400 + Check RL Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} Check RL Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot index 1357d60d..7b18be4f 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check that you cannot create an entity with and existing id +Documentation Check that you cannot create an entity with an existing id Resource ${EXECDIR}/resources/ApiUtils.resource Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource @@ -11,14 +11,13 @@ ${content_type}= application/ld+json *** Test Case *** Create one valid entity and one invalid entity - [Documentation] Check that you cannot create an entity with and existing id + [Documentation] Check that you cannot create an entity with an existing id [Tags] mandatory ${entity_id}= Generate Random Entity Id ${building_id_prefix} ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} Check Response Status Code 201 ${response['status']} - #creating entity with the same id ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} Check Response Status Code 409 ${response['status']} Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_ALREADY_EXISTS} diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot index 1e23d929..1a0ee934 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot @@ -20,7 +20,7 @@ ${entity_id_not_valid}= thisisaninvaliduri Delete Entity Scenarios [Arguments] ${entity_id} ${expected_status_code} ${problem_type} [Documentation] Check that you cannot delete an entity with invalid/missing id - [Tags] mandatory failing + [Tags] mandatory ${response}= Delete Entity by Id Returning Response ${entity_id} Check Response Status Code ${expected_status_code} ${response['status']} diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot index bcecbd8e..12d0fb6d 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot @@ -8,16 +8,17 @@ Test Template Append Attributes *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-datasetid-attributes-sample.jsonld -*** Test Cases *** STATUS_CODE OVERWRITE FILENAME FRAGMENT_FILENAME EXPECTATION_FILENAME -001_01_Append entity attributes 204 ${EMPTY} vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-same-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-01.jsonld -001_02_Append entity attributes 207 noOverwrite vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-same-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-02.jsonld -001_03_Append entity attributes 204 ${EMPTY} vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-different-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld -001_04_Append entity attributes 204 noOverwrite vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-different-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld +*** Test Cases *** STATUS_CODE OVERWRITE FRAGMENT_FILENAME EXPECTATION_FILENAME +001_01_Append entity attributes 204 ${EMPTY} vehicle-fragment-same-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-01.jsonld +001_02_Append entity attributes 207 noOverwrite vehicle-fragment-same-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-02.jsonld +001_03_Append entity attributes 204 ${EMPTY} vehicle-fragment-different-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld +001_04_Append entity attributes 204 noOverwrite vehicle-fragment-different-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld *** Keywords *** Append Attributes - [Arguments] ${status_code} ${overwrite} ${filename} ${fragment_filename} ${expectation_filename} + [Arguments] ${status_code} ${overwrite} ${fragment_filename} ${expectation_filename} [Documentation] Check that you can append entity attributes [Tags] mandatory failing diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002.robot index 01733412..66fa4348 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002.robot @@ -9,15 +9,16 @@ Test Template Append Attributes *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: ${filename}= vehicle-datasetid-attributes-sample.jsonld -${fragment_filename}= vehicle-fragment-datasetid-sample-01-02.jsonld +${fragment_filename}= vehicle-fragment-same-datasetid-sample.jsonld +${status_code}= 400 -*** Test Cases *** STATUS_CODE ENTITY_INVALID_ID -002_01_Append entity attributes if the entity Id is not present 400 ${EMPTY} -002_02_Append entity attributes if the Entity Id is not a valid URI 400 thisisaninvaliduri +*** Test Cases *** ENTITY_INVALID_ID +002_01_Append entity attributes if the entity Id is not present ${EMPTY} +002_02_Append entity attributes if the Entity Id is not a valid URI thisisaninvaliduri *** Keywords *** Append Attributes - [Arguments] ${status_code} ${entity_invalid_id} + [Arguments] ${entity_invalid_id} [Documentation] Check that you cannot append entity attributes with invalid/missing id or invalid request body [Tags] mandatory failing diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002_03.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002_03.robot index 3124540f..864d9dbb 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002_03.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/002_03.robot @@ -19,8 +19,8 @@ Append entity attributes with invalid entity fragments Check Response Status Code 201 ${response['status']} ${response}= Append Entity Attributes Using Session ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${EMPTY} - Check Response Status Code 400 ${response} - Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} - Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + Check Response Status Code ${response} + Check Response Body Type When Using Session Request ${response.json()} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Title When Using Session Request ${response.json()} [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/003.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/003.robot index 49e3a993..7553785b 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/003.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/003.robot @@ -6,7 +6,7 @@ Resource ${EXECDIR}/resources/JsonUtils.resource *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: -${fragment_filename}= vehicle-fragment-datasetid-sample-01-02.jsonld +${fragment_filename}= vehicle-fragment-same-datasetid-sample.jsonld *** Test Cases *** 003_Append entity attributes when the entity id is not known to the system diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot index be96764a..4a2dc46d 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot @@ -8,16 +8,17 @@ Test Template Update Attributes *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-two-datasetid-attributes-sample.jsonld -*** Test Cases *** STATUS_CODE FILENAME FRAGMENT_FILENAME EXPECTATION_FILENAME -004_01_Check that you can update existing attributes with no datasetId 204 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-01.jsonld vehicle-two-datasetid-attributes-sample-expectation-01.jsonld -004_02_Check that you can update existing attributes with the datasetId 204 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-02.jsonld vehicle-two-datasetid-attributes-sample-expectation-01.jsonld -004_03_Check that you can update only some attributes while others failed 207 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-03.jsonld vehicle-two-datasetid-attributes-sample-expectation-03.jsonld -004_04_Check that you cannot change the type of the attribute 204 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-04.jsonld vehicle-two-datasetid-attributes-sample-expectation-04.jsonld +*** Test Cases *** STATUS_CODE FRAGMENT_FILENAME EXPECTATION_FILENAME +004_01_Check that you can update existing attributes with no datasetId 204 vehicle-two-datasetid-attributes-sample-01.jsonld vehicle-two-datasetid-attributes-sample-expectation-01.jsonld +004_02_Check that you can update existing attributes with the datasetId 204 vehicle-two-datasetid-attributes-sample-02.jsonld vehicle-two-datasetid-attributes-sample-expectation-01.jsonld +004_03_Check that you can update only some attributes while others failed 207 vehicle-two-datasetid-attributes-sample-03.jsonld vehicle-two-datasetid-attributes-sample-expectation-03.jsonld +004_04_Check that you cannot change the type of the attribute 204 vehicle-two-datasetid-attributes-sample-04.jsonld vehicle-two-datasetid-attributes-sample-expectation-04.jsonld *** Keywords *** Update Attributes - [Arguments] ${status_code} ${filename} ${fragment_filename} ${expectation_filename} + [Arguments] ${status_code} ${fragment_filename} ${expectation_filename} [Documentation] Check that you can update entity attributes [Tags] mandatory failing diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot index c6e1a0a4..b64ac927 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot @@ -19,8 +19,8 @@ Update entity attributes with invalid entity fragments Check Response Status Code 201 ${response['status']} ${response}= Update Entity Attributes Using Session ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${EMPTY} - Check Response Status Code 400 ${response} - Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} - Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + Check Response Status Code ${response} + Check Response Body Type When Using Session Request ${response.json()} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Title When Using Session Request ${response.json()} [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot index d372e29d..6b1bea6a 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot @@ -9,9 +9,9 @@ ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: ${fragment_filename}= vehicle-two-datasetid-attributes-sample-01.jsonld *** Test Cases *** -003_Update entity attributes when the entity id is not known to the system +006_Update entity attributes when the entity id is not known to the system [Documentation] Check that you cannot update entity attributes if the entity id or attributes are not known to the system - [Tags] mandatory failing + [Tags] mandatory ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/007.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/007.robot new file mode 100644 index 00000000..ea2fb14a --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/007.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Check that you can perform a partial update on an entity attribute +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Update Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-datasetid-attributes-sample.jsonld +${attribute_id}= speed +${status_code}= 204 + +*** Test Cases *** FRAGMENT_FILENAME +007_01_Check that you can partially update an attribute vehicle-fragment-empty-datasetid-sample.jsonld +007_02_CCheck that you can partially update an attribute by specifying the datasetId vehicle-fragment-equal-datasetid-sample.jsonld + +*** Keywords *** +Update Attributes + [Arguments] ${fragment_filename} + [Documentation] Check that you can perform a partial update on an entity attribute + [Tags] mandatory failing + + ${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}= Partial Update Entity Attributes ${entity_id} ${attribute_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${status_code} ${response['status']} + #TODO: check body response is empty + + [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/008.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/008.robot new file mode 100644 index 00000000..8f9f0238 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/008.robot @@ -0,0 +1,42 @@ +*** Settings *** +Documentation Check that you cannot perform a partial update on an entity attribute with invalid/missing ids +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Test Template Update Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-two-datasetid-attributes-sample.jsonld +${status_code}= 400 + +*** Test Cases *** ENTITY_ID ATTRIBUTE_ID FRAGMENT_FILENAME +008_01_Make a partial attribute update if the Entity Id is not present ${EMPTY} speed vehicle-fragment-equal-datasetid-sample.jsonld +008_02_Make a partial attribute update if the Entity Id is not a valid URI thisisaninvaliduri speed vehicle-fragment-equal-datasetid-sample.jsonld +008_03_Make a partial attribute update if the Attribute Name is not present ${valid_entity_id} speed vehicle-fragment-attribute-name-missing-sample.jsonld +008_04_Make a partial attribute update if the Attribute Id is invalid ${valid_entity_id} invalid vehicle-fragment-equal-datasetid-sample.jsonld +008_05_Make a partial attribute update if the Attribute type does not match ${valid_entity_id} speed vehicle-fragment-equal-datasetid-different-type-sample.jsonld +008_06_Make a partial attribute update if the entity fragment is empty ${valid_entity_id} speed vehicle-fragment-all-empty-sample.jsonld + +*** Keywords *** +Update Attributes + [Arguments] ${entity_id} ${attribute_id} ${fragment_filename} + [Documentation] Check that you cannot perform a partial update on an entity attribute with invalid/missing ids + [Tags] mandatory failing + + ${init_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${init_entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Partial Update Entity Attributes ${entity_id} ${attribute_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Entity by Id Returning Response ${init_entity_id} + +Setup Initial Entities + ${valid_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Suite Variable ${valid_entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/009.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/009.robot new file mode 100644 index 00000000..807efc9d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/009.robot @@ -0,0 +1,43 @@ +*** Settings *** +Documentation Check that you cannot perform a partial update on an entity attribute if the entity id or attribute is not known to the system +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Test Template Partial Update Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-datasetid-attributes-sample.jsonld +${fragment_filename}= vehicle-two-datasetid-attributes-sample-01.jsonld +${status_code}= 404 +${attribute_id}= speed + +*** Test Cases *** ENTITY_ID FRAGMENT_FILENAME +009_01_Partial update when the Entity Id is not known to the system ${not_found_entity_id} vehicle-fragment-same-datasetid-sample.jsonld +009_02_Partial update when no default instance and no datasetId specified ${valid_entity_id} vehicle-fragment-invalid-datasetid-sample.jsonld +009_03_Partial update when no instance with the datasetId specified ${valid_entity_id} vehicle-fragment-empty-datasetid-sample.jsonld +009_04_Partial update when no instance with the attrId specified ${valid_entity_id} vehicle-fragment-attribute-name-missing-sample.jsonld + +*** Keywords *** +Partial Update Attributes + [Arguments] ${entity_id} ${fragment_filename} + [Documentation] Check that you cannot perform a partial update on an entity attribute if the entity id or attribute is not known to the system + [Tags] mandatory failing + + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${valid_entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Partial Update Entity Attributes ${entity_id} ${attribute_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Entity by Id Returning Response ${valid_entity_id} + +Setup Initial Entities + ${valid_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Suite Variable ${valid_entity_id} + ${not_found_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Suite Variable ${not_found_entity_id} \ No newline at end of file diff --git a/data/entities/expectations/vehicle-attributes-sample-append-expectation-01.jsonld b/data/entities/expectations/vehicle-attributes-sample-append-expectation-01.jsonld index 60bd3de9..544b7b4d 100644 --- a/data/entities/expectations/vehicle-attributes-sample-append-expectation-01.jsonld +++ b/data/entities/expectations/vehicle-attributes-sample-append-expectation-01.jsonld @@ -1,39 +1,3 @@ { - "id": "urn:ngsi-ld:Vehicle:randomUUID", - "type": "Vehicle", - "brandName": { - "type": "Property", - "value": "BMW" - }, - "isParked": { - "type": "Relationship", - "object": "urn:ngsi-ld:OffStreetParking:Downtown1", - "observedAt": "2017-07-29T12:00:04Z", - "providedBy": { - "type": "Relationship", - "object": "urn:ngsi-ld:Person:Bob" - } - }, - "speed": [{ - "type": "Property", - "value": 56, - "source": { - "type": "Property", - "value": "Speedometer" - }, - "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" - }, - { - "type": "Property", - "value": 54.5, - "source": { - "type": "Property", - "value": "GPS" - }, - "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" - }], - "@context": [ - "https://fiware.github.io/data-models/context.jsonld", - "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" - ] + } \ No newline at end of file diff --git a/data/entities/expectations/vehicle-attributes-sample-append-expectation-02.jsonld b/data/entities/expectations/vehicle-attributes-sample-append-expectation-02.jsonld index e29f4875..ff230172 100644 --- a/data/entities/expectations/vehicle-attributes-sample-append-expectation-02.jsonld +++ b/data/entities/expectations/vehicle-attributes-sample-append-expectation-02.jsonld @@ -1,30 +1,14 @@ { - "id": "urn:ngsi-ld:Vehicle:randomUUID", - "type": "Vehicle", - "brandName": { - "type": "Property", - "value": "Mercedes" - }, - "isParked": { - "type": "Relationship", - "object": "urn:ngsi-ld:OffStreetParking:Downtown1", - "observedAt": "2017-07-29T12:00:04Z", - "providedBy": { - "type": "Relationship", - "object": "urn:ngsi-ld:Person:Bob" + "https://uri.etsi.org/ngsi-ld/default-context/attribute_to_be_added": [ + { + "@type": [ + "https://uri.etsi.org/ngsi-ld/Property" + ], + "https://uri.etsi.org/ngsi-ld/hasValue": [ + { + "@value": 23 + } + ] } - }, - "speed": { - "type": "Property", - "value": 56, - "source": { - "type": "Property", - "value": "Speedometer" - }, - "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" - }, - "@context": [ - "https://fiware.github.io/data-models/context.jsonld", - "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" ] } \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-all-empty-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-all-empty-sample.jsonld new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-fragment-all-empty-sample.jsonld @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-attribute-name-missing-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-attribute-name-missing-sample.jsonld new file mode 100644 index 00000000..10e3efd8 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-fragment-attribute-name-missing-sample.jsonld @@ -0,0 +1,19 @@ +{ + "speed2": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + "brandName": { + "type": "Property", + "value": "BMW" + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-different-datasetid-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-different-datasetid-sample.jsonld index 3bc23013..43e60c4c 100644 --- a/data/entities/fragmentEntities/vehicle-fragment-different-datasetid-sample.jsonld +++ b/data/entities/fragmentEntities/vehicle-fragment-different-datasetid-sample.jsonld @@ -8,9 +8,9 @@ }, "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed2" }, - "brandName": { + "attribute_to_be_added": { "type": "Property", - "value": "BMW" + "value": 23 }, "@context": [ "https://fiware.github.io/data-models/context.jsonld", diff --git a/data/entities/fragmentEntities/vehicle-fragment-empty-datasetid-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-empty-datasetid-sample.jsonld new file mode 100644 index 00000000..2d30b46e --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-fragment-empty-datasetid-sample.jsonld @@ -0,0 +1,14 @@ +{ + "speed": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-different-type-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-different-type-sample.jsonld new file mode 100644 index 00000000..05e676e6 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-different-type-sample.jsonld @@ -0,0 +1,15 @@ +{ + "speed": { + "type": "different_type", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-sample.jsonld new file mode 100644 index 00000000..6a85b902 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-fragment-equal-datasetid-sample.jsonld @@ -0,0 +1,15 @@ +{ + "speed": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-invalid-datasetid-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-invalid-datasetid-sample.jsonld new file mode 100644 index 00000000..b3776989 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-fragment-invalid-datasetid-sample.jsonld @@ -0,0 +1,15 @@ +{ + "speed": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "" + }, + "@context": [ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-fragment-same-datasetid-sample.jsonld b/data/entities/fragmentEntities/vehicle-fragment-same-datasetid-sample.jsonld index 4aa9726c..86872a11 100644 --- a/data/entities/fragmentEntities/vehicle-fragment-same-datasetid-sample.jsonld +++ b/data/entities/fragmentEntities/vehicle-fragment-same-datasetid-sample.jsonld @@ -8,9 +8,9 @@ }, "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" }, - "brandName": { + "attribute_to_be_added": { "type": "Property", - "value": "BMW" + "value": 23 }, "@context": [ "https://fiware.github.io/data-models/context.jsonld", diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index facc21d5..3740921c 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -20,10 +20,10 @@ ${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH} temporal/entityOperations ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+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 -${ERROR_TYPE_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound -${ERROR_TYPE_ALREADY_EXISTS} https://uri.etsi.org/ngsi-ld/errors/AlreadyExists +${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData +${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest +${ERROR_TYPE_RESOURCE_NOT_FOUND} http://uri.etsi.org/ngsi-ld/errors/ResourceNotFound +${ERROR_TYPE_ALREADY_EXISTS} http://uri.etsi.org/ngsi-ld/errors/AlreadyExists ${response} @@ -179,6 +179,15 @@ Update Entity Attributes Output response [return] ${response} +Partial Update Entity Attributes + [Arguments] ${entityId} ${attributeId} ${fragment_filename} ${content_type} + &{headers}= Create Dictionary Content-Type=${content_type} + ${fragment_payload}= Load Json From File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} + ${response}= PATCH ${ENTITIES_ENDPOINT_PATH}${entityId}/attrs/${attributeId} body=${fragment_payload} headers=${headers} + Output request + Output response + [return] ${response} + Create Entity [Arguments] ${filename} ${entity_id} ${entity_payload}= Load Json From File ${EXECDIR}/data/entities/${filename} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index e1ee2db9..b368ff36 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -35,7 +35,7 @@ Check Response Body Content Check Response Headers Containing URI set to [Arguments] ${expected_path} ${expected_entity_id} ${response} - Should Be Equal ${expected_path}${expected_entity_id} ${response['headers']['Location']} ignore_order=True + Should Be Equal ${expected_path}${expected_entity_id} ${response['headers']['location']} ignore_order=True Check Response Body Containing an Attribute set to [Arguments] ${expected_attribute_name} @@ -94,10 +94,18 @@ Check Response Body Containing List Containing EntityTemporal elements ${comparaison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${temporal_entities_representation_payload} ${instance_id_regex_expr} Should Be True ${comparaison_result} msg=EntityTemporal List Comparaison Failed +Check Response Body Type When Using Session Request + [Arguments] ${response} ${type} + Should Be Equal ${response['type']} ${type} + Check Response Body Containing ProblemDetails Element Containing Type Element set to [Arguments] ${response} ${type} Should Be Equal ${response['body']['type']} ${type} +Check Response Body Title When Using Session Request + [Arguments] ${response} + Should Not Be Empty ${response['title']} + Check Response Body Containing ProblemDetails Element Containing Title Element [Arguments] ${response} Should Not Be Empty ${response['body']['title']} -- GitLab