diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot new file mode 100644 index 0000000000000000000000000000000000000000..07c5f142d1f0baed105574b46329eac0b94a5397 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot @@ -0,0 +1,65 @@ +*** Settings *** +Documentation Verify that, when one has an exclusive registration on a Context Broker, one is able to replace a target entity attribute and the change is forwarded to the Context Source + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Create Entity And Registration On The Context Broker And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_attribute_filename} fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld + +*** Test Cases *** +D009_01_exc Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an exclusive registration + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_19 6_3_18 + + ${attribute_payload}= Load Entity ${entity_attribute_filename} ${entity_id} + Set Stub Reply PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute_payload} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Request Count PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${entity_id} local=true + Check Response Status Code 201 ${response.status_code} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ... mode=exclusive + ... endpoint=/broker1 + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + + Start Context Source Mock Server + +Delete Created Entity And Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Entity by Id ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot new file mode 100644 index 0000000000000000000000000000000000000000..8ea2f3265fa492db67975f9867b1823ccfa522a0 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot @@ -0,0 +1,67 @@ +*** Settings *** +Documentation Verify that, when one has an inclusive registration on a Context Broker, one is able to replace a target entity and the change is forwarded to the Context Source + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Create Entity And Registration On The Context Broker And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_attribute_filename} fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D009_01_inc Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an inclusive registration + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_19 6_3_18 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${old_attribute}= Get From Dictionary ${response.json()} speed + + ${attribute_payload}= Load Entity ${entity_attribute_filename} ${entity_id} + Set Stub Reply PUT /ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute_payload} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${new_attribute}= Get From Dictionary ${response.json()} speed + Should Not Be Equal ${old_attribute} ${new_attribute} + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${entity_id} + Check Response Status Code 201 ${response.status_code} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + + Start Context Source Mock Server + +Delete Created Entity And Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Entity by Id ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot new file mode 100644 index 0000000000000000000000000000000000000000..a85571a3d21847ead69b8ce1b2809bcdf406ff15 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot @@ -0,0 +1,79 @@ +*** Settings *** +Documentation Verify that, when one has two redirect registrations on a Context Broker, one is able to replace a target entity on both the Context Sources + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_attribute_filename} fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D009_01_red Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Sources thanks to the redirect registrations + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_19 6_3_18 + + Set Stub Reply POST /broker1/ngsi-ld/v1/entities 201 ${entity_id} + Set Stub Reply POST /broker2/ngsi-ld/v1/entities 201 ${entity_id} + + ${attribute_payload}= Load Entity ${entity_attribute_filename} ${entity_id} + Set Stub Reply PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + Set Stub Reply PUT /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute_payload} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Request Count PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed + Should Be Equal ${stub_count} 1 + ${stub_count}= Get Stub Request Count PUT /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/speed + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${entity_id} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ... mode=redirect + ... endpoint=/broker1 + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + + ${registration_id2}= Generate Random CSR Id + Set Suite Variable ${registration_id2} + ${registration_payload2}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ... mode=redirect + ... endpoint=/broker2 + ${response}= Create Context Source Registration With Return ${registration_payload2} + Check Response Status Code 201 ${response.status_code} + + Start Context Source Mock Server + +Delete Created Entity And Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Context Source Registration ${registration_id2} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json b/data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json new file mode 100644 index 0000000000000000000000000000000000000000..fc7e320006bd9acf15defe527ab8d096503cf8f2 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json @@ -0,0 +1,10 @@ +{ + "speed": { + "type": "Property", + "value": 99, + "source": { + "type": "Property", + "value": "Speedometer" + } + } +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D009_01_exc.json b/doc/files/DistributedOperations/Provision/D009_01_exc.json new file mode 100644 index 0000000000000000000000000000000000000000..47882986c1255f4c5f21d2eedbb971d6e313e91d --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D009_01_exc.json @@ -0,0 +1,45 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_exc", + "test_objective": "Verify that, when one has an exclusive registration on a Context Broker, one is able to replace a target entity attribute and the change is forwarded to the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.19, 6.3.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.19", + "6.3.18" + ], + "pics_selection": "", + "keywords": [ + "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "Delete Created Entity And Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing an initial Entity ${entity} on the Context Broker\n with an id set to ${entity_id}\n and payload set to ${entity_payload_filename}\n and the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D009_01_exc Replace Entity Attribute", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_exc", + "doc": "Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an exclusive registration", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_19", + "6_3_18", + "cf_06", + "dist-ops", + "proxy-exclusive", + "since_v1.6.1" + ], + "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "D009_01_exc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D009_01_inc.json b/doc/files/DistributedOperations/Provision/D009_01_inc.json new file mode 100644 index 0000000000000000000000000000000000000000..5b23a69837bc72b2bfbb387f967af001bafc529b --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D009_01_inc.json @@ -0,0 +1,45 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_inc", + "test_objective": "Verify that, when one has an inclusive registration on a Context Broker, one is able to replace a target entity and the change is forwarded to the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.19, 6.3.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.19", + "6.3.18" + ], + "pics_selection": "", + "keywords": [ + "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "Delete Created Entity And Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing an initial Entity ${entity} on the Context Broker\n with an id set to ${entity_id}\n and payload set to ${entity_payload_filename}\n and the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D009_01_inc Replace Entity Attribute", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_inc", + "doc": "Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an inclusive registration", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_19", + "6_3_18", + "additive-inclusive", + "cf_06", + "dist-ops", + "since_v1.6.1" + ], + "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "GET", + "endpoint": "entities/{id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "D009_01_inc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D009_01_red.json b/doc/files/DistributedOperations/Provision/D009_01_red.json new file mode 100644 index 0000000000000000000000000000000000000000..5fcfe1ad0efcc4accdcdb603ec0972046ce925cd --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D009_01_red.json @@ -0,0 +1,45 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_red", + "test_objective": "Verify that, when one has two redirect registrations on a Context Broker, one is able to replace a target entity on both the Context Sources", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.19, 6.3.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.19", + "6.3.18" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Created Entity And Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D009_01_red Replace Entity Attribute", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_red", + "doc": "Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Sources thanks to the redirect registrations", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_19", + "6_3_18", + "cf_06", + "dist-ops", + "proxy-redirect", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "D009_01_red" +} \ No newline at end of file