From 2bcb83f833a27fb4be4a927a4f726d051ff92bf7 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Tue, 19 Dec 2023 17:52:13 +0100 Subject: [PATCH 1/2] feat(020_11): add TC for aggregated temporal representation of an entity --- .../020_11.robot | 58 +++++++++++ ...-representation-020-11-01-expectation.json | 34 +++++++ ...-representation-020-11-02-expectation.json | 24 +++++ ...-representation-020-11-03-expectation.json | 58 +++++++++++ ...-representation-020-11-04-expectation.json | 38 +++++++ doc/analysis/requests.py | 12 ++- .../Consumption/020_11.json | 98 +++++++++++++++++++ .../test_ContextInformation_Consumption.py | 7 ++ ...oralContextInformationConsumption.resource | 8 ++ 9 files changed, 333 insertions(+), 4 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-11-01-expectation.json create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-11-02-expectation.json create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-11-03-expectation.json create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-11-04-expectation.json create mode 100644 doc/files/ContextInformation/Consumption/020_11.json diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot new file mode 100644 index 00000000..1e62d5f4 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot @@ -0,0 +1,58 @@ +*** Settings *** +Documentation Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation + +Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Create Temporal Entity +Suite Teardown Delete Initial Temporal Entity +Test Template Retrieve the temporal evolution of an entity with the aggregated temporal representation + + +*** Variables *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.jsonld + + +*** Test Cases *** AGGRMETHODS AGGRPERIODDURATION ATTRS VEHICLE_EXPECTATION_FILE +020_11_01 One aggregate method aggregated by one hour duration + [Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1 + avg PT1H ${EMPTY} vehicle-temporal-representation-020-11-01-expectation.json +020_11_02 One aggregate method aggregated by one hour duration asking for one attribute + [Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1 + avg PT1H fuelLevel vehicle-temporal-representation-020-11-02-expectation.json +020_11_03 Multiple aggregate methods aggregated by one hour duration + [Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1 + avg,max PT1H ${EMPTY} vehicle-temporal-representation-020-11-03-expectation.json +020_11_04 Multiple aggregate methods aggregated by one day duration + [Tags] te-retrieve 5_7_3 4_5_19 since_v1.4.1 + min,max P1D ${EMPTY} vehicle-temporal-representation-020-11-04-expectation.json + + +*** Keywords *** +Retrieve the temporal evolution of an entity with the aggregated temporal representation + [Documentation] Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation + [Arguments] ${aggrmethods} ${aggrperiodduration} ${attrs} ${vehicle_expectation_file} + @{options}= Create List aggregatedValues + ${response}= Retrieve Temporal Representation Of Entity + ... temporal_entity_representation_id=${temporal_entity_representation_id} + ... attrs=${attrs} + ... options=${options} + ... aggrMethods=${aggrmethods} + ... aggrPeriodDuration=${aggrperiodduration} + ... context=${ngsild_test_suite_context} + Check Response Status Code 200 ${response.status_code} + Check Response Body Containing EntityTemporal element + ... ${vehicle_expectation_file} + ... ${temporal_entity_representation_id} + ... ${response.json()} + +Create Temporal Entity + ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + Create Temporal Representation Of Entity ${vehicle_payload_file} ${temporal_entity_representation_id} + Set Suite Variable ${temporal_entity_representation_id} + +Delete Initial Temporal Entity + Delete Temporal Representation Of Entity ${temporal_entity_representation_id} diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-01-expectation.json b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-01-expectation.json new file mode 100644 index 00000000..19629740 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-01-expectation.json @@ -0,0 +1,34 @@ +{ + "id": "urn:ngsi-ld:Vehicle:4656271219750725", + "type": "Vehicle", + "speed": { + "type": "Property", + "avg": [ + [ + 100.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "avg": [ + [ + 67.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ], + [ + 53.0, + "2020-08-01T13:03:00Z", + "2020-08-01T14:03:00Z" + ], + [ + 40.0, + "2020-08-01T14:03:00Z", + "2020-08-01T15:03:00Z" + ] + ] + } +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-02-expectation.json b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-02-expectation.json new file mode 100644 index 00000000..fdb466ba --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-02-expectation.json @@ -0,0 +1,24 @@ +{ + "id": "urn:ngsi-ld:Vehicle:4656271219750725", + "type": "Vehicle", + "fuelLevel": { + "type": "Property", + "avg": [ + [ + 67.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ], + [ + 53.0, + "2020-08-01T13:03:00Z", + "2020-08-01T14:03:00Z" + ], + [ + 40.0, + "2020-08-01T14:03:00Z", + "2020-08-01T15:03:00Z" + ] + ] + } +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-03-expectation.json b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-03-expectation.json new file mode 100644 index 00000000..fbc17f76 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-03-expectation.json @@ -0,0 +1,58 @@ +{ + "id": "urn:ngsi-ld:Vehicle:4656271219750725", + "type": "Vehicle", + "speed": { + "type": "Property", + "avg": [ + [ + 100.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ] + ], + "max": [ + [ + 120.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "avg": [ + [ + 67.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ], + [ + 53.0, + "2020-08-01T13:03:00Z", + "2020-08-01T14:03:00Z" + ], + [ + 40.0, + "2020-08-01T14:03:00Z", + "2020-08-01T15:03:00Z" + ] + ], + "max": [ + [ + 67.0, + "2020-08-01T12:03:00Z", + "2020-08-01T13:03:00Z" + ], + [ + 53.0, + "2020-08-01T13:03:00Z", + "2020-08-01T14:03:00Z" + ], + [ + 40.0, + "2020-08-01T14:03:00Z", + "2020-08-01T15:03:00Z" + ] + ] + } +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-04-expectation.json b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-04-expectation.json new file mode 100644 index 00000000..94c8f089 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-04-expectation.json @@ -0,0 +1,38 @@ +{ + "id": "urn:ngsi-ld:Vehicle:7599642734962554", + "type": "Vehicle", + "speed": { + "type": "Property", + "min": [ + [ + 80.0, + "2020-08-01T12:03:00Z", + "2020-08-02T12:03:00Z" + ] + ], + "max": [ + [ + 120.0, + "2020-08-01T12:03:00Z", + "2020-08-02T12:03:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "min": [ + [ + 40.0, + "2020-08-01T12:03:00Z", + "2020-08-02T12:03:00Z" + ] + ], + "max": [ + [ + 67.0, + "2020-08-01T12:03:00Z", + "2020-08-02T12:03:00Z" + ] + ] + } +} \ No newline at end of file diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 798f0bb9..ba1d1441 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -95,8 +95,8 @@ class Requests: 'Retrieve Temporal Representation Of Entity': { 'positions': [], 'params': ['temporal_entity_representation_id', 'attrs', 'options', - 'context', 'timerel', 'timeAt', - 'endTimeAt', 'lastN', 'accept'] + 'context', 'timerel', 'timeAt', 'endTimeAt', 'lastN', 'accept', + 'aggrMethods', 'aggrPeriodDuration'] }, 'Delete Entity by Id': { 'positions': [0], @@ -1079,8 +1079,8 @@ class Requests: @staticmethod def retrieve_temporal_representation_of_entity(kwargs) -> str: expected_parameters = ['temporal_entity_representation_id', 'attrs', 'options', - 'context', 'timerel', 'timeAt', - 'endTimeAt', 'lastN', 'accept'] + 'context', 'timerel', 'timeAt', 'endTimeAt', 'lastN', 'accept', + 'aggrMethods', 'aggrPeriodDuration'] result = [x for x in kwargs if x not in expected_parameters] response = "Retrieve Temporal Representation of Entity" for key, value in kwargs.items(): @@ -1104,6 +1104,10 @@ class Requests: response = f"{response} and\n Query Parameter: lastN set to '{value}'" case 'accept': response = f"{response} and\n Query Parameter: accept set to '{value}'" + case 'aggrMethods': + response = f"{response} and\n Query Parameter: aggrMethods set to '{value}'" + case 'aggrPeriodDuration': + response = f"{response} and\n Query Parameter: aggrPeriodDuration set to '{value}'" # If an exact match is not confirmed, this last case will be used if provided case _: raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are " diff --git a/doc/files/ContextInformation/Consumption/020_11.json b/doc/files/ContextInformation/Consumption/020_11.json new file mode 100644 index 00000000..a591326a --- /dev/null +++ b/doc/files/ContextInformation/Consumption/020_11.json @@ -0,0 +1,98 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Cons/TE/020_11", + "test_objective": "Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation", + "reference": "ETSI GS CIM 009 V1.3.1 [], clauses 4.5.19, 5.7.3", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "4.5.19", + "5.7.3" + ], + "pics_selection": "", + "keywords": [ + "Create Temporal Entity", + "Delete Initial Temporal Entity" + ], + "teardown": "Delete Initial Temporal Entity", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "020_11_01 One aggregate method aggregated by one hour duration", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/020_11_01", + "doc": "Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation", + "tags": [ + "4_5_19", + "5_7_3", + "since_v1.4.1", + "te-retrieve" + ], + "setup": null, + "teardown": null, + "template": "Retrieve the temporal evolution of an entity with the aggregated temporal representation", + "then": "then {\n the SUT sends a valid Response for the operations:\n Retrieve Temporal Representation Of Entity with Response Status Code set to 200 and\n Retrieve Temporal Representation Of Entity with Response Body containing EntityTemporal element containing attribute instances in the time range specified by the NGSI-LD temporal query:\n * the payload is defined in the file set to 'vehicle-temporal-representation-020-11-01-expectation.json'\n * the id was changed to '${temporal_entity_representation_id}'\n * response body to be checked set to '${response.json()}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities/{temporal_entity_representation_id}'\n method set to 'GET'\n Retrieve Temporal Representation of Entity and\n Query Parameter: id set to '${temporal_entity_representation_id}' and\n Query Parameter: attrs set to '${EMPTY}' and\n Query Parameter: options set to '${options}' and\n Query Parameter: aggrMethods set to 'avg' and\n Query Parameter: aggrPeriodDuration set to 'PT1H' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "GET", + "endpoint": "temporal/entities/{temporal_entity_representation_id}" + }, + { + "name": "020_11_02 One aggregate method aggregated by one hour duration asking for one attribute", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/020_11_02", + "doc": "Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation", + "tags": [ + "4_5_19", + "5_7_3", + "since_v1.4.1", + "te-retrieve" + ], + "setup": null, + "teardown": null, + "template": "Retrieve the temporal evolution of an entity with the aggregated temporal representation", + "then": "then {\n the SUT sends a valid Response for the operations:\n Retrieve Temporal Representation Of Entity with Response Status Code set to 200 and\n Retrieve Temporal Representation Of Entity with Response Body containing EntityTemporal element containing attribute instances in the time range specified by the NGSI-LD temporal query:\n * the payload is defined in the file set to 'vehicle-temporal-representation-020-11-02-expectation.json'\n * the id was changed to '${temporal_entity_representation_id}'\n * response body to be checked set to '${response.json()}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities/{temporal_entity_representation_id}'\n method set to 'GET'\n Retrieve Temporal Representation of Entity and\n Query Parameter: id set to '${temporal_entity_representation_id}' and\n Query Parameter: attrs set to 'fuelLevel' and\n Query Parameter: options set to '${options}' and\n Query Parameter: aggrMethods set to 'avg' and\n Query Parameter: aggrPeriodDuration set to 'PT1H' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "GET", + "endpoint": "temporal/entities/{temporal_entity_representation_id}" + }, + { + "name": "020_11_03 Multiple aggregate methods aggregated by one hour duration", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/020_11_03", + "doc": "Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation", + "tags": [ + "4_5_19", + "5_7_3", + "since_v1.4.1", + "te-retrieve" + ], + "setup": null, + "teardown": null, + "template": "Retrieve the temporal evolution of an entity with the aggregated temporal representation", + "then": "then {\n the SUT sends a valid Response for the operations:\n Retrieve Temporal Representation Of Entity with Response Status Code set to 200 and\n Retrieve Temporal Representation Of Entity with Response Body containing EntityTemporal element containing attribute instances in the time range specified by the NGSI-LD temporal query:\n * the payload is defined in the file set to 'vehicle-temporal-representation-020-11-03-expectation.json'\n * the id was changed to '${temporal_entity_representation_id}'\n * response body to be checked set to '${response.json()}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities/{temporal_entity_representation_id}'\n method set to 'GET'\n Retrieve Temporal Representation of Entity and\n Query Parameter: id set to '${temporal_entity_representation_id}' and\n Query Parameter: attrs set to '${EMPTY}' and\n Query Parameter: options set to '${options}' and\n Query Parameter: aggrMethods set to 'avg,max' and\n Query Parameter: aggrPeriodDuration set to 'PT1H' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "GET", + "endpoint": "temporal/entities/{temporal_entity_representation_id}" + }, + { + "name": "020_11_04 Multiple aggregate methods aggregated by one day duration", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/020_11_04", + "doc": "Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation", + "tags": [ + "4_5_19", + "5_7_3", + "since_v1.4.1", + "te-retrieve" + ], + "setup": null, + "teardown": null, + "template": "Retrieve the temporal evolution of an entity with the aggregated temporal representation", + "then": "then {\n the SUT sends a valid Response for the operations:\n Retrieve Temporal Representation Of Entity with Response Status Code set to 200 and\n Retrieve Temporal Representation Of Entity with Response Body containing EntityTemporal element containing attribute instances in the time range specified by the NGSI-LD temporal query:\n * the payload is defined in the file set to 'vehicle-temporal-representation-020-11-04-expectation.json'\n * the id was changed to '${temporal_entity_representation_id}'\n * response body to be checked set to '${response.json()}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities/{temporal_entity_representation_id}'\n method set to 'GET'\n Retrieve Temporal Representation of Entity and\n Query Parameter: id set to '${temporal_entity_representation_id}' and\n Query Parameter: attrs set to '${EMPTY}' and\n Query Parameter: options set to '${options}' and\n Query Parameter: aggrMethods set to 'min,max' and\n Query Parameter: aggrPeriodDuration set to 'P1D' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "GET", + "endpoint": "temporal/entities/{temporal_entity_representation_id}" + } + ], + "permutations": [ + "then", + "when" + ], + "robotpath": "ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity", + "robotfile": "020_11" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py index 533026a1..a4ba1041 100644 --- a/doc/tests/test_ContextInformation_Consumption.py +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -469,6 +469,13 @@ class TestCIConsumptions(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_020_11(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/020_11.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_020_11.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_020_12(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_12.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/020_12.json' diff --git a/resources/ApiUtils/TemporalContextInformationConsumption.resource b/resources/ApiUtils/TemporalContextInformationConsumption.resource index 983a2be2..4da46170 100755 --- a/resources/ApiUtils/TemporalContextInformationConsumption.resource +++ b/resources/ApiUtils/TemporalContextInformationConsumption.resource @@ -188,6 +188,8 @@ Retrieve Temporal Representation Of Entity ... ${endTimeAt}=${EMPTY} ... ${lastN}=${EMPTY} ... ${accept}=${EMPTY} + ... ${aggrMethods}=${EMPTY} + ... ${aggrPeriodDuration}=${EMPTY} ${attrs_length}= Get Length ${attrs} ${options_length}= Get Length ${options} &{headers}= Create Dictionary @@ -211,6 +213,12 @@ Retrieve Temporal Representation Of Entity Set To Dictionary ${params} endTimeAt=${endTimeAt} END IF '${lastN}'!='' Set To Dictionary ${params} lastN=${lastN} + IF '${aggrMethods}'!='' + Set To Dictionary ${params} aggrMethods=${aggrMethods} + END + IF '${aggrPeriodDuration}'!='' + Set To Dictionary ${params} aggrPeriodDuration=${aggrPeriodDuration} + END ${response}= GET ... url=${temporal_api_url}/${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id} -- GitLab From 5b31c137c67bd0f390ef874452d4a86d29161ced Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 23 Mar 2024 09:08:54 +0100 Subject: [PATCH 2/2] update doc --- doc/files/ContextInformation/Consumption/020_11.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/files/ContextInformation/Consumption/020_11.json b/doc/files/ContextInformation/Consumption/020_11.json index a591326a..340890f8 100644 --- a/doc/files/ContextInformation/Consumption/020_11.json +++ b/doc/files/ContextInformation/Consumption/020_11.json @@ -1,15 +1,16 @@ { "tp_id": "TP/NGSI-LD/CI/Cons/TE/020_11", "test_objective": "Check that you can retrieve the temporal evolution of an entity with the aggregated temporal representation", - "reference": "ETSI GS CIM 009 V1.3.1 [], clauses 4.5.19, 5.7.3", + "reference": "ETSI GS CIM 009 V1.4.1 [], clauses 4.5.19, 5.7.3", "config_id": "", - "parent_release": "v1.3.1", + "parent_release": "v1.4.1", "clauses": [ "4.5.19", "5.7.3" ], "pics_selection": "", "keywords": [ + "Retrieve the temporal evolution of an entity with the aggregated temporal representation", "Create Temporal Entity", "Delete Initial Temporal Entity" ], -- GitLab