diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot new file mode 100644 index 0000000000000000000000000000000000000000..3fa52b4eb3d33bcf2bf8ec046b8f0ab8a4ce6656 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot @@ -0,0 +1,62 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on 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 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_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_new_payload_filename} vehicle-simple-attributes-second-different.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld + +*** Test Cases *** +D008_01_exc Merge Entity On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Source. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_17 + + Set Stub Reply PATCH /broker1/ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Merge Entity + ... entity_id=${entity_id} + ... entity_filename=${entity_new_payload_filename} + ... content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} local=true + Should Not Contain ${response} speed + +*** 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 Entity by Id ${entity_id} + Delete Context Source Registration ${registration_id} diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot new file mode 100644 index 0000000000000000000000000000000000000000..c83394e6389e86294c13c155e73438cc43e784e7 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot @@ -0,0 +1,69 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the Context Source too + +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_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_new_payload_filename} vehicle-simple-attributes-second-different.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D008_01_inc Merge Entity On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the Context Source too + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_17 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${old_isparked}= Get From Dictionary ${response.json()} isParked2 + ${old_brandname}= Get From Dictionary ${response.json()} brandName + + Set Stub Reply PATCH /ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Merge Entity + ... entity_id=${entity_id} + ... entity_filename=${entity_new_payload_filename} + ... content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${new_brandname}= Get From Dictionary ${response.json()} brandName + ${new_isparked}= Get From Dictionary ${response.json()} isParked2 + Should Be Equal ${old_brandname} ${new_brandname} + Should Not Be Equal ${old_isparked} ${new_isparked} + Dictionary Should Contain Key ${response.json()} speed + +*** 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} + ... mode=inclusive + ${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 Entity by Id ${entity_id} + Delete Context Source Registration ${registration_id} diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot new file mode 100644 index 0000000000000000000000000000000000000000..17ed909dab4318ec124a9afa39c7066be62f507a --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on 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_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_new_payload_filename} vehicle-simple-attributes-second-different.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D008_01_red Merge Entity On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Source. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_17 + + Set Stub Reply PATCH /broker1/ngsi-ld/v1/entities/${entity_id} 204 + Set Stub Reply PATCH /broker2/ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Merge Entity + ... entity_id=${entity_id} + ... entity_filename=${entity_new_payload_filename} + ... content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + ${stub_count}= Get Stub Count PATCH /broker2/ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + +*** 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_payload}= Prepare Context Source Registration From File + ... ${registration_id2} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ... mode=redirect + ... endpoint=/broker2 + ${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 Context Source Registration ${registration_id2} diff --git a/data/entities/vehicle-simple-attributes-second-different.jsonld b/data/entities/vehicle-simple-attributes-second-different.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..b892e88f769de06bea9631e8297095b0ab33ede4 --- /dev/null +++ b/data/entities/vehicle-simple-attributes-second-different.jsonld @@ -0,0 +1,25 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed2" + }, + "isParked2": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown2", + "observedAt": "2019-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D008_01_exc.json b/doc/files/DistributedOperations/Provision/D008_01_exc.json new file mode 100644 index 0000000000000000000000000000000000000000..51ef44adf47f83fcc809906d180f941c42fed92a --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D008_01_exc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_exc", + "test_objective": "Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Sources.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.17", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.17" + ], + "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": "D008_01_exc Merge Entity On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_exc", + "doc": "Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Source.", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_17", + "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": "GET", + "endpoint": "entities/{id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/MergeEntity", + "robotfile": "D008_01_exc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D008_01_inc.json b/doc/files/DistributedOperations/Provision/D008_01_inc.json new file mode 100644 index 0000000000000000000000000000000000000000..a896005a390520cbb1742dafecdc3ea2aa5351cc --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D008_01_inc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_inc", + "test_objective": "Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the Context Source too", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.17", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.17" + ], + "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": "D008_01_inc Merge Entity On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_inc", + "doc": "Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the Context Source too", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_17", + "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/Entities/MergeEntity", + "robotfile": "D008_01_inc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D008_01_red.json b/doc/files/DistributedOperations/Provision/D008_01_red.json new file mode 100644 index 0000000000000000000000000000000000000000..181943ed17aa60abad9aca093d2747f26d2330bb --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D008_01_red.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_red", + "test_objective": "Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Sources.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.17", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.17" + ], + "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": "D008_01_red Merge Entity On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_red", + "doc": "Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Source.", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_17", + "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": "PATCH", + "endpoint": "entities/{entity_id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/MergeEntity", + "robotfile": "D008_01_red" +} \ No newline at end of file