From e9e523c4b6dc9641370a4eb7e3d050a87fe01af9 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Tue, 19 Dec 2023 14:19:26 +0100 Subject: [PATCH 1/2] feat(021_14): add TC to query temporal evolution of entities with simplified representation --- .../021_14.robot | 69 +++++++++++++++++ ...-representation-021-14-01-expectation.json | 70 ++++++++++++++++++ ...-representation-021-14-02-expectation.json | 74 +++++++++++++++++++ doc/analysis/requests.py | 6 +- .../test_ContextInformation_Consumption.py | 7 ++ ...oralContextInformationConsumption.resource | 4 + 6 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot create mode 100644 data/temporalEntities/expectations/vehicles-temporal-representation-021-14-01-expectation.json create mode 100644 data/temporalEntities/expectations/vehicles-temporal-representation-021-14-02-expectation.json diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot new file mode 100644 index 00000000..a7d78f44 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot @@ -0,0 +1,69 @@ +*** Settings *** +Documentation Check that you can query the temporal evolution of entities with the simplified representation + +Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entities +Test Teardown Delete Initial Entities +Test Template Query the temporal evolution of entities + + +*** Variables *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${bus_id_prefix}= urn:ngsi-ld:Bus: +${first_vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.jsonld +${second_vehicle_payload_file}= 2020-09-vehicule-temporal-representation-sample.jsonld +${bus_payload_file}= 2020-08-bus-temporal-representation-sample.jsonld + + +*** Test Cases *** TIMEREL TIMEAT EXPECTATION_FILE +021_14_01 After + [Tags] te-query 5_7_4 + after 2020-08-01T12:04:00Z vehicles-temporal-representation-021-14-01-expectation.json +021_14_02 Before + [Tags] te-query 5_7_4 + before 2020-09-01T13:06:00Z vehicles-temporal-representation-021-14-02-expectation.json + + +*** Keywords *** +Query the temporal evolution of entities + [Documentation] Check that you can query the temporal evolution of entities with the simplified representation + [Arguments] ${timerel} ${timeat} ${expectation_file} + ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle + ${response}= Query Temporal Representation Of Entities + ... entity_types=${entity_types_to_be_retrieved} + ... timerel=${timerel} + ... timeAt=${timeat} + ... context=${ngsild_test_suite_context} + ... options=temporalValues + @{temporal_entities_representation_ids}= Create List + ... ${first_temporal_entity_representation_id} + ... ${second_temporal_entity_representation_id} + Check Response Status Code 200 ${response.status_code} + Check Response Body Containing List Containing EntityTemporal elements + ... ${expectation_file} + ... ${temporal_entities_representation_ids} + ... ${response.json()} + +Setup Initial Entities + ${first_temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + ${second_temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + ${third_temporal_entity_representation_id}= Generate Random Entity Id ${bus_id_prefix} + Create Temporal Representation Of Entity + ... ${first_vehicle_payload_file} + ... ${first_temporal_entity_representation_id} + Create Temporal Representation Of Entity + ... ${second_vehicle_payload_file} + ... ${second_temporal_entity_representation_id} + Create Temporal Representation Of Entity ${bus_payload_file} ${third_temporal_entity_representation_id} + Set Test Variable ${first_temporal_entity_representation_id} + Set Test Variable ${second_temporal_entity_representation_id} + Set Test Variable ${third_temporal_entity_representation_id} + +Delete Initial Entities + Delete Temporal Representation Of Entity ${first_temporal_entity_representation_id} + Delete Temporal Representation Of Entity ${second_temporal_entity_representation_id} + Delete Temporal Representation Of Entity ${third_temporal_entity_representation_id} diff --git a/data/temporalEntities/expectations/vehicles-temporal-representation-021-14-01-expectation.json b/data/temporalEntities/expectations/vehicles-temporal-representation-021-14-01-expectation.json new file mode 100644 index 00000000..229b21fe --- /dev/null +++ b/data/temporalEntities/expectations/vehicles-temporal-representation-021-14-01-expectation.json @@ -0,0 +1,70 @@ +[ + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "values": [ + [ + 80.0, + "2020-08-01T12:05:00Z" + ], + [ + 100.0, + "2020-08-01T12:07:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "values": [ + [ + 53.0, + "2020-08-01T13:05:00Z" + ], + [ + 40.0, + "2020-08-01T14:07:00Z" + ] + ] + } + }, + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "values": [ + [ + 120.0, + "2020-09-01T12:03:00Z" + ], + [ + 80.0, + "2020-09-01T12:05:00Z" + ], + [ + 100.0, + "2020-09-01T12:07:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "values": [ + [ + 67.0, + "2020-09-01T12:03:00Z" + ], + [ + 53.0, + "2020-09-01T13:05:00Z" + ], + [ + 40.0, + "2020-09-01T14:07:00Z" + ] + ] + } + } +] diff --git a/data/temporalEntities/expectations/vehicles-temporal-representation-021-14-02-expectation.json b/data/temporalEntities/expectations/vehicles-temporal-representation-021-14-02-expectation.json new file mode 100644 index 00000000..6b0c8547 --- /dev/null +++ b/data/temporalEntities/expectations/vehicles-temporal-representation-021-14-02-expectation.json @@ -0,0 +1,74 @@ +[ + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "values": [ + [ + 120.0, + "2020-08-01T12:03:00Z" + ], + [ + 80.0, + "2020-08-01T12:05:00Z" + ], + [ + 100.0, + "2020-08-01T12:07:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "values": [ + [ + 67.0, + "2020-08-01T12:03:00Z" + ], + [ + 53.0, + "2020-08-01T13:05:00Z" + ], + [ + 40.0, + "2020-08-01T14:07:00Z" + ] + ] + } + }, + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "values": [ + [ + 120.0, + "2020-09-01T12:03:00Z" + ], + [ + 80.0, + "2020-09-01T12:05:00Z" + ], + [ + 100.0, + "2020-09-01T12:07:00Z" + ] + ] + }, + "fuelLevel": { + "type": "Property", + "values": [ + [ + 67.0, + "2020-09-01T12:03:00Z" + ], + [ + 53.0, + "2020-09-01T13:05:00Z" + ] + ] + } + } +] \ No newline at end of file diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 96f2933c..cb28add2 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -62,7 +62,7 @@ class Requests: 'params': ['context', 'entity_types', 'entity_ids', 'entity_id_pattern', 'ngsild_query', 'csf', 'georel', 'geometry', 'coordinates', 'geoproperty', 'timerel', 'timeAt', - 'attrs', 'limit', 'lastN', 'accept'] + 'attrs', 'limit', 'lastN', 'accept', 'options'] }, 'Query Temporal Representation Of Entities Via Post': { 'positions': [], @@ -1025,7 +1025,7 @@ class Requests: expected_parameters = ['context', 'entity_types', 'entity_ids', 'entity_id_pattern', 'ngsild_query', 'csf', 'georel', 'geometry', 'coordinates', 'geoproperty', 'timerel', 'timeAt', - 'attrs', 'limit', 'lastN', 'accept'] + 'attrs', 'limit', 'lastN', 'accept', 'options'] result = [x for x in kwargs if x not in expected_parameters] response = "Query Temporal Representation of Entities" @@ -1064,6 +1064,8 @@ 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 'options': + response = f"{response} and\n Query Parameter: options set to '{value}'" # If an exact match is not confirmed, this last case will be used if provided case _: diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py index 8f059be8..c58fc67c 100644 --- a/doc/tests/test_ContextInformation_Consumption.py +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -378,6 +378,13 @@ class TestCIConsumptions(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_021_14(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/021_14.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_021_14.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_020_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/020_01.json' diff --git a/resources/ApiUtils/TemporalContextInformationConsumption.resource b/resources/ApiUtils/TemporalContextInformationConsumption.resource index e806f085..983a2be2 100755 --- a/resources/ApiUtils/TemporalContextInformationConsumption.resource +++ b/resources/ApiUtils/TemporalContextInformationConsumption.resource @@ -37,6 +37,7 @@ Query Temporal Representation Of Entities ... ${limit}=${EMPTY} ... ${lastN}=${EMPTY} ... ${accept}=${EMPTY} + ... ${options}=${EMPTY} ${entity_types_length}= Get Length ${entity_types} ${entity_ids_length}= Get Length ${entity_ids} ${attrs_length}= Get Length ${attrs} @@ -78,6 +79,9 @@ Query Temporal Representation Of Entities Set To Dictionary ${params} geoproperty=${geoproperty} END IF '${limit}'!='' Set To Dictionary ${params} limit=${limit} + IF '${options}'!='' + Set To Dictionary ${params} options=${options} + END ${response}= GET ... url=${temporal_api_url}/${TEMPORAL_ENTITIES_ENDPOINT_PATH} -- GitLab From f19c419d2926fcb839ca923adbcc662eacd7154d Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sun, 17 Mar 2024 18:01:46 +0100 Subject: [PATCH 2/2] fix: formatting and missing generated JSON doc file --- .../021_14.robot | 4 +- .../Consumption/021_14.json | 51 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 doc/files/ContextInformation/Consumption/021_14.json diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot index a7d78f44..d18dd087 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot @@ -58,7 +58,9 @@ Setup Initial Entities Create Temporal Representation Of Entity ... ${second_vehicle_payload_file} ... ${second_temporal_entity_representation_id} - Create Temporal Representation Of Entity ${bus_payload_file} ${third_temporal_entity_representation_id} + Create Temporal Representation Of Entity + ... ${bus_payload_file} + ... ${third_temporal_entity_representation_id} Set Test Variable ${first_temporal_entity_representation_id} Set Test Variable ${second_temporal_entity_representation_id} Set Test Variable ${third_temporal_entity_representation_id} diff --git a/doc/files/ContextInformation/Consumption/021_14.json b/doc/files/ContextInformation/Consumption/021_14.json new file mode 100644 index 00000000..1b8d0f30 --- /dev/null +++ b/doc/files/ContextInformation/Consumption/021_14.json @@ -0,0 +1,51 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Cons/TE/021_14", + "test_objective": "Check that you can query the temporal evolution of entities with the simplified representation", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_4", + "keywords": [], + "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": "021_14_01 After", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/021_14_01", + "doc": "Check that you can query the temporal evolution of entities with the simplified representation", + "tags": [ + "5_7_4", + "te-query" + ], + "setup": "Setup Initial Entities", + "teardown": "Delete Initial Entities", + "template": "Query the temporal evolution of entities", + "then": "then {\n the SUT sends a valid Response for the operations:\n Query Temporal Representation Of Entities with Response Status Code set to 200 and\n Query Temporal Representation Of Entities with Request response body containing a list that contains Entity Temporal Elements\n compared with file 'vehicles-temporal-representation-021-14-01-expectation.json'\n and using the list of entity ids define in '${temporal_entities_representation_ids}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'GET'\n Query Temporal Representation of Entities and\n Query Parameter: entity_types set to '${entity_types_to_be_retrieved}' and\n Query Parameter: timerel set to 'after' and\n Query Parameter: timeAt set to '2020-08-01T12:04:00Z' 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' and\n Query Parameter: options set to 'temporalValues'\n}", + "http_verb": "GET", + "endpoint": "temporal/entities" + }, + { + "name": "021_14_02 Before", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/021_14_02", + "doc": "Check that you can query the temporal evolution of entities with the simplified representation", + "tags": [ + "5_7_4", + "te-query" + ], + "setup": "Setup Initial Entities", + "teardown": "Delete Initial Entities", + "template": "Query the temporal evolution of entities", + "then": "then {\n the SUT sends a valid Response for the operations:\n Query Temporal Representation Of Entities with Response Status Code set to 200 and\n Query Temporal Representation Of Entities with Request response body containing a list that contains Entity Temporal Elements\n compared with file 'vehicles-temporal-representation-021-14-02-expectation.json'\n and using the list of entity ids define in '${temporal_entities_representation_ids}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'GET'\n Query Temporal Representation of Entities and\n Query Parameter: entity_types set to '${entity_types_to_be_retrieved}' and\n Query Parameter: timerel set to 'before' and\n Query Parameter: timeAt set to '2020-09-01T13:06:00Z' 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' and\n Query Parameter: options set to 'temporalValues'\n}", + "http_verb": "GET", + "endpoint": "temporal/entities" + } + ], + "permutations": [ + "then", + "when" + ], + "robotpath": "ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities", + "robotfile": "021_14" +} \ No newline at end of file -- GitLab