diff --git a/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities/005_05.robot b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities/005_05.robot new file mode 100644 index 0000000000000000000000000000000000000000..bab8ffbd27d07088532b815085cc7528d669d099 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities/005_05.robot @@ -0,0 +1,59 @@ +*** Settings *** +Documentation Check that you can update types of entities in a batch update operation + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entities +Test Teardown Delete Initial Entities +Test Template Batch Update Entity Scenarios + + +*** Variables *** +${building_id_prefix}= urn:ngsi-ld:Building: +${entity_payload_filename}= building-minimal-sample.jsonld + + +*** Test Cases *** FILENAME UPDATE_FRAGMENT_FILENAME +005_05_01 EntityWithNewType + [Tags] be-update 5_6_9 4_16 + building-minimal-with-new-type.jsonld fragmentEntities/building-two-types-fragment.jsonld + + +*** Keywords *** +Batch Update Entity Scenarios + [Documentation] Check that you can update types of entities in a batch update operation + [Arguments] ${filename} ${update_fragment_filename} + ${first_entity}= Load Entity ${filename} ${first_entity_id} + ${second_entity}= Load Entity ${filename} ${second_entity_id} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_entity} ${second_entity} + ${response}= Batch Update Entities @{entities_to_be_updated} + Check Response Status Code 204 ${response.status_code} + ${first_created_entity}= Load Test Sample entities/${entity_payload_filename} ${first_entity_id} + ${second_created_entity}= Load Test Sample entities/${entity_payload_filename} ${second_entity_id} + ${update_fragment}= Load Test Sample entities/${update_fragment_filename} + ${first_updated_entity}= Upsert Element In Entity ${first_created_entity} ${update_fragment} + ${second_updated_entity}= Upsert Element In Entity ${second_created_entity} ${update_fragment} + @{updated_entities}= Create List ${first_updated_entity} ${second_updated_entity} + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} + ${response1}= Query Entities + ... entity_ids=${expected_entities_ids} + ... entity_types=Building + ... context=${ngsild_test_suite_context} + ... accept=${CONTENT_TYPE_LD_JSON} + Check Updated Resources Set To ${updated_entities} ${response1.json()} + +Setup Initial Entities + ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${second_entity_id}= Generate Random Entity Id ${building_id_prefix} + Create Entity ${entity_payload_filename} ${first_entity_id} + Create Entity ${entity_payload_filename} ${second_entity_id} + Set Test Variable ${first_entity_id} + Set Test Variable ${second_entity_id} + +Delete Initial Entities + @{entities_ids_to_be_deleted}= Create List ${first_entity_id} ${second_entity_id} + Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} diff --git a/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_08.robot b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_08.robot new file mode 100644 index 0000000000000000000000000000000000000000..655f495a6b1f4f946c1d2649c0d46d95a0c28bb8 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_08.robot @@ -0,0 +1,52 @@ +*** Settings *** +Documentation Check that you can upsert a batch of existing entities with new types and they will be replaced + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entities +Test Teardown Delete Initial Entities +Test Template Batch Upsert Existing Entities Scenarios + + +*** Variables *** +${building_id_prefix}= urn:ngsi-ld:Building: + + +*** Test Cases *** FILENAME +004_08_01 EntityWithNewTypes + [Tags] be-upsert 5_6_8 4_16 + building-minimal-with-new-types.jsonld + + +*** Keywords *** +Batch Upsert Existing Entities Scenarios + [Documentation] Check that you can upsert a batch of existing entities with new types + [Arguments] ${filename} + ${first_existing_entity}= Load Entity ${filename} ${first_existing_entity_id} + ${second_existing_entity}= Load Entity ${filename} ${second_existing_entity_id} + @{entities_to_be_upserted}= Create List ${first_existing_entity} ${second_existing_entity} + ${response}= Batch Upsert Entities @{entities_to_be_upserted} + Check Response Status Code 204 ${response.status_code} + @{upserted_entities_ids}= Create List ${first_existing_entity_id} ${second_existing_entity_id} + ${expected_updated_entities_ids}= Catenate SEPARATOR=, @{upserted_entities_ids} + ${response1}= Query Entities + ... entity_ids=${expected_updated_entities_ids} + ... entity_types=Building + ... context=${ngsild_test_suite_context} + ... accept=${CONTENT_TYPE_LD_JSON} + Check Updated Resources Set To ${entities_to_be_upserted} ${response1.json()} + +Setup Initial Entities + ${first_existing_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${second_existing_entity_id}= Generate Random Entity Id ${building_id_prefix} + Create Entity building-minimal-sample.jsonld ${first_existing_entity_id} + Create Entity building-minimal-sample.jsonld ${second_existing_entity_id} + Set Test Variable ${first_existing_entity_id} + Set Test Variable ${second_existing_entity_id} + +Delete Initial Entities + @{entities_ids_to_be_deleted}= Create List ${first_existing_entity_id} ${second_existing_entity_id} + Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} diff --git a/data/entities/building-minimal-with-new-type.jsonld b/data/entities/building-minimal-with-new-type.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..f039cafacbddcab196ee4ab028748a6d34aa3849 --- /dev/null +++ b/data/entities/building-minimal-with-new-type.jsonld @@ -0,0 +1,7 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "Vehicle", + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} diff --git a/data/entities/building-minimal-with-new-types.jsonld b/data/entities/building-minimal-with-new-types.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..608bbcc7611eb7e790ec305947e50278277c2173 --- /dev/null +++ b/data/entities/building-minimal-with-new-types.jsonld @@ -0,0 +1,7 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": ["Building" ,"Vehicle"], + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} diff --git a/data/entities/fragmentEntities/building-two-types-fragment.jsonld b/data/entities/fragmentEntities/building-two-types-fragment.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..34237f84946de8abd89d7f0b37dc1376a1802663 --- /dev/null +++ b/data/entities/fragmentEntities/building-two-types-fragment.jsonld @@ -0,0 +1,3 @@ +{ + "type": ["Building", "Vehicle"] +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/004_08.json b/doc/files/ContextInformation/Provision/004_08.json new file mode 100644 index 0000000000000000000000000000000000000000..ea8975d742ec241f9494f9f9575bc3550725a2f4 --- /dev/null +++ b/doc/files/ContextInformation/Provision/004_08.json @@ -0,0 +1,41 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/BE/004_08", + "test_objective": "Check that you can upsert a batch of existing entities with new types and they will be replaced", + "reference": "ETSI GS CIM 009 V1.3.1 [], clauses 4.16, 5.6.8", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "4.16", + "5.6.8" + ], + "pics_selection": "", + "keywords": [ + "Batch Upsert Existing Entities Scenarios", + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n and containing a list of entities\n}", + "test_cases": [ + { + "name": "004_08_01 EntityWithNewTypes", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/004_08_01", + "doc": "Check that you can upsert a batch of existing entities with new types", + "tags": [ + "4_16", + "5_6_8", + "be-upsert" + ], + "setup": "Setup Initial Entities", + "teardown": "Delete Initial Entities", + "template": "Batch Upsert Existing Entities Scenarios", + "then": "then {\n the SUT sends a valid Response for the operations:\n Batch Upsert Entities with Response Status Code set to 204 and\n Query Entities with Updated Entities set to '${entities_to_be_upserted}' valid entities\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/upsert?options=${update_option}'\n method set to 'POST'\n Request batch upsert operation over entity from filename '@{entities_to_be_upserted}' with update_option set to 'replace' and Content-Type set to 'application/ld+json'\n}", + "http_verb": "POST", + "endpoint": "entityOperations/upsert?options=${update_option}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities", + "robotfile": "004_08" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/005_05.json b/doc/files/ContextInformation/Provision/005_05.json new file mode 100644 index 0000000000000000000000000000000000000000..1920bb69d07eec2cce375c52f76071dc1ab82307 --- /dev/null +++ b/doc/files/ContextInformation/Provision/005_05.json @@ -0,0 +1,41 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/BE/005_05", + "test_objective": "Check that you can update types of entities in a batch update operation", + "reference": "ETSI GS CIM 009 V1.3.1 [], clauses 4.16, 5.6.9", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "4.16", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Batch Update Entity Scenarios", + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n and containing a list of entities\n}", + "test_cases": [ + { + "name": "005_05_01 EntityWithNewType", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/005_05_01", + "doc": "Check that you can update types of entities in a batch update operation", + "tags": [ + "4_16", + "5_6_9", + "be-update" + ], + "setup": "Setup Initial Entities", + "teardown": "Delete Initial Entities", + "template": "Batch Update Entity Scenarios", + "then": "then {\n the SUT sends a valid Response for the operations:\n Batch Update Entities with Response Status Code set to 204 and\n Query Entities with Updated Entities set to '${updated_entities}' valid entities\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/update?${params_as_string}'\n method set to 'POST'\n Request batch update operation over entity from filename '@{entities_to_be_updated}' with overwrite_option set to '${EMPTY}' and Content-Type set to 'application/ld+json'\n}", + "http_verb": "POST", + "endpoint": "entityOperations/update?${params_as_string}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities", + "robotfile": "005_05" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py index e9970bd6d22f0da6308771a226791f0cd0a8e93b..679e9ed66503911d9ed1b27a96f3fe27f5c5e35b 100644 --- a/doc/tests/test_ContextInformation_Provision.py +++ b/doc/tests/test_ContextInformation_Provision.py @@ -168,6 +168,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_005_05(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities/005_05.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/005_05.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_005_05.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_004_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/004_01.json' @@ -217,6 +224,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_004_08(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_08.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/004_08.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_004_08.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_001_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/001_01.json'