diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot new file mode 100644 index 0000000000000000000000000000000000000000..6a1b5a26780009d1303b8442d168b9a0d9ab21cc --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot @@ -0,0 +1,60 @@ +*** Settings *** +Documentation Check that you can update the types on an entity + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Create Initial Entity +Test Teardown Delete Initial Entity +Test Template Append Types to an Entity + + +*** Variables *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${entity_filename}= building-minimal-sample.json + + +*** Test Cases *** FRAGMENT_FILENAME EXPECTATION_FILENAME +011_06_01 AppendOneType + type-vehicle-fragment.json building-minimal-with-two-types.json +011_06_02 AppendTwoTypes + types-vehicle-car-fragment.json building-minimal-with-three-types.json +011_06_03 AppendExistingType + type-building-fragment.json building-minimal-compacted-expectation.json +011_06_04 AppendOneTypeAndOneExisting + type-vehicle-building-fragment.json building-minimal-with-two-types.json + + +*** Keywords *** +Append Types to an Entity + [Documentation] Check that type is appended if it is not yet in the target entity + [Tags] ea-append 5_6_2 4_16 since_v1.5.1 + [Arguments] ${type_fragment_filename} ${expectation_filename} + + ${response}= Update Entity Attributes + ... ${entity_id} + ... ${type_fragment_filename} + ... ${CONTENT_TYPE_LD_JSON} + + Check Response Status Code 204 ${response.status_code} + ${response}= Retrieve Entity by Id + ... ${entity_id} + ... accept=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} + Check Updated Resource Set To ${entity_expectation_payload} ${response.json()} + +Create Initial Entity + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Test Variable ${entity_id} + ${response}= Create Entity Selecting Content Type + ... ${entity_filename} + ... ${entity_id} + ... ${CONTENT_TYPE_JSON} + ... ${ngsild_test_suite_context} + Check Response Status Code 201 ${response.status_code} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/data/entities/expectations/building-minimal-with-three-types.json b/data/entities/expectations/building-minimal-with-three-types.json new file mode 100644 index 0000000000000000000000000000000000000000..5ced7334997efa41f629678a53042df9e6c4333f --- /dev/null +++ b/data/entities/expectations/building-minimal-with-three-types.json @@ -0,0 +1,4 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": ["Building", "Vehicle", "Car"] +} \ No newline at end of file diff --git a/data/entities/expectations/building-minimal-with-two-types.json b/data/entities/expectations/building-minimal-with-two-types.json new file mode 100644 index 0000000000000000000000000000000000000000..3782f4c4d75ef50326de106c6af6b7b0d5496424 --- /dev/null +++ b/data/entities/expectations/building-minimal-with-two-types.json @@ -0,0 +1,4 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": ["Building", "Vehicle"] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/type-building-fragment.json b/data/entities/fragmentEntities/type-building-fragment.json new file mode 100644 index 0000000000000000000000000000000000000000..aa8f90d1d303414c984875e3a1089c0a2e4cb131 --- /dev/null +++ b/data/entities/fragmentEntities/type-building-fragment.json @@ -0,0 +1,6 @@ +{ + "type": "Building", + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/type-vehicle-building-fragment.json b/data/entities/fragmentEntities/type-vehicle-building-fragment.json new file mode 100644 index 0000000000000000000000000000000000000000..6665997beaf5e84159f2e35f9aa9987b286c469f --- /dev/null +++ b/data/entities/fragmentEntities/type-vehicle-building-fragment.json @@ -0,0 +1,6 @@ +{ + "type": ["Building", "Vehicle"], + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/type-vehicle-fragment.json b/data/entities/fragmentEntities/type-vehicle-fragment.json new file mode 100644 index 0000000000000000000000000000000000000000..e405afcc50cd5fba781bbfccf3cfec19a913fc5b --- /dev/null +++ b/data/entities/fragmentEntities/type-vehicle-fragment.json @@ -0,0 +1,6 @@ +{ + "type": "Vehicle", + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/types-vehicle-car-fragment.json b/data/entities/fragmentEntities/types-vehicle-car-fragment.json new file mode 100644 index 0000000000000000000000000000000000000000..fde75e0f690ec04e38274133498868b6a0655f34 --- /dev/null +++ b/data/entities/fragmentEntities/types-vehicle-car-fragment.json @@ -0,0 +1,6 @@ +{ + "type": ["Vehicle", "Car"], + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/011_06.json b/doc/files/ContextInformation/Provision/011_06.json new file mode 100644 index 0000000000000000000000000000000000000000..b31fbadf69dbcf72f2528e6863d79759bd0819c2 --- /dev/null +++ b/doc/files/ContextInformation/Provision/011_06.json @@ -0,0 +1,42 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/EA/011_06", + "test_objective": "Check that you can update the types on an entity", + "reference": "ETSI GS CIM 009 V1.5.1 [], clauses 4.16, 5.6.2", + "config_id": "", + "parent_release": "v1.5.1", + "clauses": [ + "4.16", + "5.6.2" + ], + "pics_selection": "", + "keywords": [ + "Create Initial Entity", + "Delete Initial Entity" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing an initial Entity ${entity} \n with an id set to ${entityId} \n}", + "test_cases": [ + { + "name": "011_06_01 Append type to an entity", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/011_06_01", + "doc": "Check that type is appended if it is not yet in the target entity", + "tags": [ + "4_16", + "5_6_2", + "ea-append", + "since_v1.5.1" + ], + "setup": "Create Initial Entity", + "teardown": "Delete Initial Entity", + "template": null, + "then": "then {\n the SUT sends a valid Response for the operations:\n Update Entity Attributes with Response Status Code set to 204 and\n Update Entity Attributes with Check Updated Entity and\n Query Parameter: 'ignored_keys' set to '${None}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/'\n method set to 'GET'\n Request Retrieve Entity by Id and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: accept set to 'application/json' and\n Query Parameter: context set to 'https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld'\n}", + "http_verb": "GET", + "endpoint": "" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes", + "robotfile": "011_06", + "error_while_autogenerating": "no error" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py index 679e9ed66503911d9ed1b27a96f3fe27f5c5e35b..eb503a0f0612d9b1d7cc60a71272d14f06f8ce9c 100644 --- a/doc/tests/test_ContextInformation_Provision.py +++ b/doc/tests/test_ContextInformation_Provision.py @@ -469,6 +469,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_011_06(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/011_06.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_011_06.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_007_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/TemporalEntity/CreateTemporalRepresentationOfEntity/007_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/007_01.json'