From 86d1cee0ee42ff35ff2b789a3320d16e35302406 Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Wed, 7 Aug 2024 10:28:59 +0200 Subject: [PATCH 1/2] feat: add aggregation test for query entities --- .../021_17.robot | 81 +++++++++++++++++++ doc/analysis/requests.py | 9 ++- ...oralContextInformationConsumption.resource | 12 +++ 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot new file mode 100644 index 00000000..2998e4f3 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot @@ -0,0 +1,81 @@ +*** Settings *** +Documentation Check that one 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 Setup Initial Entities +Suite Teardown Delete Initial Entities +Test Template Retrieve the temporal evolution of an entity with the aggregated temporal representation + + +*** Variables *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${first_vehicle_payload_file}= 2020-08-vehicle-temporal-representation.jsonld +${second_vehicle_payload_file}= 2020-08-vehicle-temporal-representation.jsonld + + +*** Test Cases *** AGGRMETHODS AGGRPERIODDURATION ATTRS VEHICLE_EXPECTATION_FILE +021_17_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-021-17-01.json +021_17_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-021-17-02.json +021_17_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-021-17-03.json +021_17_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-021-17-04.json + + +*** Keywords *** +Retrieve the temporal evolution of an entity with the aggregated temporal representation + [Documentation] Check that one can retrieve the temporal evolution of an entity with the aggregated temporal representation + [Arguments] ${aggrmethods} ${aggrperiodduration} ${attrs} ${vehicle_expectation_file} + @{options}= Create List aggregatedValues + Log To Console "context" + Log To Console "context" + Log To Console "context" + Log To Console ${ngsild_test_suite_context} + + ${response}= Query Temporal Representation Of Entities + ... temporal_entity_representation_id=Vehicle + ... attrs=${attrs} + ... options=${options} + ... aggrMethods=${aggrmethods} + ... aggrPeriodDuration=${aggrperiodduration} + ... context=${ngsild_test_suite_context} + Check Response Status Code 200 ${response.status_code} + Log To Console "response" + Log To Console response + ${entities_id}= Create List + ... ${first_temporal_entity_representation_id} + ... ${second_temporal_entity_representation_id} + Check Response Body Containing List Containing EntityTemporal elements + ... ${vehicle_expectation_file} + ... ${entities_id} + ... ${response.json()} + +Setup Initial Entities + ${first_temporal_entity_representation_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${second_temporal_entity_representation_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${response}= Create Temporal Representation Of Entity + ... ${first_vehicle_payload_file} + ... ${first_temporal_entity_representation_id} + Check Response Status Code 201 ${response.status_code} + + ${response}= Create Temporal Representation Of Entity + ... ${second_vehicle_payload_file} + ... ${second_temporal_entity_representation_id} + Check Response Status Code 201 ${response.status_code} + + Set Suite Variable ${first_temporal_entity_representation_id} + Set Suite Variable ${second_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} diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 3899e01e..7e45ab71 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', 'endTimeAt', - 'attrs', 'limit', 'lastN', 'accept', 'options'] + 'attrs', 'limit', 'lastN', 'accept', 'options', 'aggrMethods', 'aggrPeriodDuration'] }, 'Query Temporal Representation Of Entities Via Post': { 'positions': [], @@ -1089,7 +1089,7 @@ class Requests: expected_parameters = ['context', 'entity_types', 'entity_ids', 'entity_id_pattern', 'ngsild_query', 'csf', 'georel', 'geometry', 'coordinates', 'geoproperty', 'timerel', 'timeAt','endTimeAt', - 'attrs', 'limit', 'lastN', 'accept', 'options'] + 'attrs', 'limit', 'lastN', 'accept', 'options','aggrMethods','aggrPeriodDuration'] result = [x for x in kwargs if x not in expected_parameters] response = "Query Temporal Representation of Entities" @@ -1133,7 +1133,10 @@ class Requests: response = f"{response} and\n Query Parameter: accept set to '{value}'" case 'options': response = f"{response} and\n Query Parameter: options 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/resources/ApiUtils/TemporalContextInformationConsumption.resource b/resources/ApiUtils/TemporalContextInformationConsumption.resource index cb32d18a..d8ec9293 100755 --- a/resources/ApiUtils/TemporalContextInformationConsumption.resource +++ b/resources/ApiUtils/TemporalContextInformationConsumption.resource @@ -39,6 +39,12 @@ Query Temporal Representation Of Entities ... ${lastN}=${EMPTY} ... ${accept}=${EMPTY} ... ${options}=${EMPTY} + ... ${aggrMethods}=${EMPTY} + ... ${aggrPeriodDuration}=${EMPTY} + Log To Console AAAAAAAAAA + Log To Console AAAAAAAAAA + Log To Console AAAAAAAAAA + Log To Console AAAAAAAAAA ${entity_types_length}= Get Length ${entity_types} ${entity_ids_length}= Get Length ${entity_ids} ${attrs_length}= Get Length ${attrs} @@ -86,6 +92,12 @@ Query Temporal Representation Of Entities IF '${options}'!='' Set To Dictionary ${params} options=${options} END + 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} -- GitLab From 27b20667f4446978782277add5d8827e03037b2c Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Wed, 20 Nov 2024 18:02:24 +0100 Subject: [PATCH 2/2] feat: working test aggregation test for temporal retrieve entities --- .../021_17.robot | 38 ++++++----------- .../020_11.robot | 8 ++-- ...tation-aggregated-avg-PT1H-fuelLevel.json} | 0 ...l-representation-aggregated-avg-PT1H.json} | 0 ...presentation-aggregated-avg-max-PT1H.json} | 0 ...epresentation-aggregated-min-max-P1D.json} | 0 ...oralContextInformationConsumption.resource | 42 ++++++++----------- 7 files changed, 33 insertions(+), 55 deletions(-) rename data/temporalEntities/expectations/{vehicle-temporal-representation-020-11-02.json => vehicle-temporal-representation-aggregated-avg-PT1H-fuelLevel.json} (100%) rename data/temporalEntities/expectations/{vehicle-temporal-representation-020-11-01.json => vehicle-temporal-representation-aggregated-avg-PT1H.json} (100%) rename data/temporalEntities/expectations/{vehicle-temporal-representation-020-11-03.json => vehicle-temporal-representation-aggregated-avg-max-PT1H.json} (100%) rename data/temporalEntities/expectations/{vehicle-temporal-representation-020-11-04.json => vehicle-temporal-representation-aggregated-min-max-P1D.json} (100%) diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot index 2998e4f3..1f5ec617 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_17.robot @@ -20,16 +20,16 @@ ${second_vehicle_payload_file}= 2020-08-vehicle-temporal-representation.json *** Test Cases *** AGGRMETHODS AGGRPERIODDURATION ATTRS VEHICLE_EXPECTATION_FILE 021_17_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-021-17-01.json + avg PT1H ${EMPTY} vehicle-temporal-representation-aggregated-avg-PT1H.json 021_17_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-021-17-02.json + avg PT1H fuelLevel vehicle-temporal-representation-aggregated-avg-PT1H-fuelLevel.json 021_17_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-021-17-03.json + avg,max PT1H ${EMPTY} vehicle-temporal-representation-aggregated-avg-max-PT1H.json 021_17_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-021-17-04.json + min,max P1D ${EMPTY} vehicle-temporal-representation-aggregated-min-max-P1D.json *** Keywords *** @@ -37,45 +37,31 @@ Retrieve the temporal evolution of an entity with the aggregated temporal repres [Documentation] Check that one can retrieve the temporal evolution of an entity with the aggregated temporal representation [Arguments] ${aggrmethods} ${aggrperiodduration} ${attrs} ${vehicle_expectation_file} @{options}= Create List aggregatedValues - Log To Console "context" - Log To Console "context" - Log To Console "context" - Log To Console ${ngsild_test_suite_context} + @{types}= Create List Vehicle ${response}= Query Temporal Representation Of Entities - ... temporal_entity_representation_id=Vehicle + ... entity_types=${types} ... attrs=${attrs} ... options=${options} ... aggrMethods=${aggrmethods} ... aggrPeriodDuration=${aggrperiodduration} ... context=${ngsild_test_suite_context} + ... timerel=after + ... timeAt=2020-01-01T12:03:00Z Check Response Status Code 200 ${response.status_code} - Log To Console "response" - Log To Console response - ${entities_id}= Create List - ... ${first_temporal_entity_representation_id} - ... ${second_temporal_entity_representation_id} - Check Response Body Containing List Containing EntityTemporal elements + + Check Response Body Containing EntityTemporal element ... ${vehicle_expectation_file} - ... ${entities_id} - ... ${response.json()} + ... ${first_temporal_entity_representation_id} + ... ${response.json()[0]} Setup Initial Entities ${first_temporal_entity_representation_id}= Generate Random Entity Id ${vehicle_id_prefix} - ${second_temporal_entity_representation_id}= Generate Random Entity Id ${vehicle_id_prefix} ${response}= Create Temporal Representation Of Entity ... ${first_vehicle_payload_file} ... ${first_temporal_entity_representation_id} Check Response Status Code 201 ${response.status_code} - - ${response}= Create Temporal Representation Of Entity - ... ${second_vehicle_payload_file} - ... ${second_temporal_entity_representation_id} - Check Response Status Code 201 ${response.status_code} - Set Suite Variable ${first_temporal_entity_representation_id} - Set Suite Variable ${second_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} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot index e0a304e4..a28cbb56 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_11.robot @@ -19,16 +19,16 @@ ${vehicle_payload_file}= 2020-08-vehicle-temporal-representation.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.json + avg PT1H ${EMPTY} vehicle-temporal-representation-aggregated-avg-PT1H.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.json + avg PT1H fuelLevel vehicle-temporal-representation-aggregated-avg-PT1H-fuelLevel.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.json + avg,max PT1H ${EMPTY} vehicle-temporal-representation-aggregated-avg-max-PT1H.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.json + min,max P1D ${EMPTY} vehicle-temporal-representation-aggregated-min-max-P1D.json *** Keywords *** diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-02.json b/data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-avg-PT1H-fuelLevel.json similarity index 100% rename from data/temporalEntities/expectations/vehicle-temporal-representation-020-11-02.json rename to data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-avg-PT1H-fuelLevel.json diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-01.json b/data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-avg-PT1H.json similarity index 100% rename from data/temporalEntities/expectations/vehicle-temporal-representation-020-11-01.json rename to data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-avg-PT1H.json diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-03.json b/data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-avg-max-PT1H.json similarity index 100% rename from data/temporalEntities/expectations/vehicle-temporal-representation-020-11-03.json rename to data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-avg-max-PT1H.json diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-11-04.json b/data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-min-max-P1D.json similarity index 100% rename from data/temporalEntities/expectations/vehicle-temporal-representation-020-11-04.json rename to data/temporalEntities/expectations/vehicle-temporal-representation-aggregated-min-max-P1D.json diff --git a/resources/ApiUtils/TemporalContextInformationConsumption.resource b/resources/ApiUtils/TemporalContextInformationConsumption.resource index d8ec9293..71ca1cfe 100755 --- a/resources/ApiUtils/TemporalContextInformationConsumption.resource +++ b/resources/ApiUtils/TemporalContextInformationConsumption.resource @@ -41,17 +41,13 @@ Query Temporal Representation Of Entities ... ${options}=${EMPTY} ... ${aggrMethods}=${EMPTY} ... ${aggrPeriodDuration}=${EMPTY} - Log To Console AAAAAAAAAA - Log To Console AAAAAAAAAA - Log To Console AAAAAAAAAA - Log To Console AAAAAAAAAA ${entity_types_length}= Get Length ${entity_types} ${entity_ids_length}= Get Length ${entity_ids} ${attrs_length}= Get Length ${attrs} &{headers}= Create Dictionary &{params}= Create Dictionary - IF '${accept}'!='' Set To Dictionary ${headers} Accept=${accept} - IF '${context}'!='' + IF $accept!='' Set To Dictionary ${headers} Accept=${accept} + IF $context!='' Set To Dictionary ... ${headers} ... Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" @@ -62,40 +58,36 @@ Query Temporal Representation Of Entities IF ${entity_ids_length}>0 Set To Dictionary ${params} id=${entity_ids} END - IF '${timerel}'!='' - Set To Dictionary ${params} timerel=${timerel} - END - IF '${timeAt}'!='' Set To Dictionary ${params} timeAt=${timeAt} - IF '${endTimeAt}'!='' + IF $timerel!='' Set To Dictionary ${params} timerel=${timerel} + IF $timeAt!='' Set To Dictionary ${params} timeAt=${timeAt} + IF $endTimeAt!='' Set To Dictionary ${params} endTimeAt=${endTimeAt} END IF ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} - IF '${lastN}'!='' Set To Dictionary ${params} lastN=${lastN} - IF '${entity_id_pattern}'!='' + IF $lastN!='' Set To Dictionary ${params} lastN=${lastN} + IF $entity_id_pattern!='' Set To Dictionary ${params} idPattern=${entity_id_pattern} END - IF '${ngsild_query}'!='' + IF $ngsild_query!='' Set To Dictionary ${params} q=${ngsild_query} END - IF '${csf}'!='' Set To Dictionary ${params} csf=${csf} - IF '${georel}'!='' Set To Dictionary ${params} georel=${georel} - IF '${geometry}'!='' + IF $csf!='' Set To Dictionary ${params} csf=${csf} + IF $georel!='' Set To Dictionary ${params} georel=${georel} + IF $geometry!='' Set To Dictionary ${params} geometry=${geometry} END - IF '${coordinates}'!='' + IF $coordinates!='' Set To Dictionary ${params} coordinates=${coordinates} END - IF '${geoproperty}'!='' + IF $geoproperty!='' Set To Dictionary ${params} geoproperty=${geoproperty} END - IF '${limit}'!='' Set To Dictionary ${params} limit=${limit} - IF '${options}'!='' - Set To Dictionary ${params} options=${options} - END - IF '${aggrMethods}'!='' + IF $limit!='' Set To Dictionary ${params} limit=${limit} + IF $options!='' Set To Dictionary ${params} options=${options} + IF $aggrMethods!='' Set To Dictionary ${params} aggrMethods=${aggrMethods} END - IF '${aggrPeriodDuration}'!='' + IF $aggrPeriodDuration!='' Set To Dictionary ${params} aggrPeriodDuration=${aggrPeriodDuration} END -- GitLab