From f5f7c685ce9edcf5bdd10ef40994e33c80109b6f Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Wed, 9 Dec 2020 17:56:27 +0100 Subject: [PATCH 01/10] feat: add 020_01 020_02 20_03 TPs --- .../020_01.robot | 30 ++++++++++++ .../020_02.robot | 30 ++++++++++++ .../020_03.robot | 29 +++++++++++ ...cule-temporal-representation-sample.jsonld | 48 +++++++++++++++++++ resources/ApiUtils.resource | 25 ++++++++++ resources/AssertionUtils.resource | 11 +++++ resources/variables.py | 3 +- 7 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot create mode 100644 data/temporalEntities/vehicule-temporal-representation-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot new file mode 100644 index 00000000..f016390f --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot @@ -0,0 +1,30 @@ +*** Settings *** +Documentation Check that you can retrieve the temporal evolution of an entity +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: + +*** Test Case *** +Retrieve the temporal evolution of an entity + [Documentation] Check that you can retrieve the temporal evolution of an entity + [Tags] mandatory + + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} + + @{expected_temporal_attributes}= Create List fuelLevel speed + + Check Response Status Code Set To 200 + Check Response Body Containing EntityTemporal element ${expected_temporal_attributes} + + #TODO Call Delete Temporal Representation Of Entity + +*** Keywords *** +Setup Initial Entities + ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + Create Temporal Representation Of Entity vehicule-temporal-representation-sample.jsonld ${temporal_entity_representation_id} + Set Suite Variable ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot new file mode 100644 index 00000000..a719e995 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot @@ -0,0 +1,30 @@ +*** Settings *** +Documentation Check that you can retrieve the temporal evolution of an entity using a context +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: + +*** Test Case *** +Retrieve the temporal evolution of an entity using a context + [Documentation] Check that you can retrieve the temporal evolution of an entity using a context + [Tags] mandatory + + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} context=${fiware_context} + + @{expected_temporal_attributes}= Create List speed fuelLevel + + Check Response Status Code Set To 200 + Check Response Body Containing EntityTemporal element ${expected_temporal_attributes} + + #TODO Call Delete Temporal Representation Of Entity + +*** Keywords *** +Setup Initial Entities + ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + Create Temporal Representation Of Entity vehicule-temporal-representation-sample.jsonld ${temporal_entity_representation_id} + Set Suite Variable ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot new file mode 100644 index 00000000..7d36558e --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot @@ -0,0 +1,29 @@ +*** Settings *** +Documentation Check that you can retrieve the temporal evolution of certain attributes of an entity +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: + +*** Test Case *** +Retrieve the temporal evolution of certain attributes of an entity + [Documentation] Check that you can retrieve the temporal evolution of certain attributes of an entity + [Tags] mandatory + + @{temporal_attributes_to_be_retrieved}= Create List fuelLevel + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} attrs=${temporal_attributes_to_be_retrieved} context=${fiware_context} + + Check Response Status Code Set To 200 + Check Response Body Containing EntityTemporal element ${temporal_attributes_to_be_retrieved} + + #TODO Call Delete Temporal Representation Of Entity + +*** Keywords *** +Setup Initial Entities + ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} + Create Temporal Representation Of Entity vehicule-temporal-representation-sample.jsonld ${temporal_entity_representation_id} + Set Suite Variable ${temporal_entity_representation_id} diff --git a/data/temporalEntities/vehicule-temporal-representation-sample.jsonld b/data/temporalEntities/vehicule-temporal-representation-sample.jsonld new file mode 100644 index 00000000..4823e1b2 --- /dev/null +++ b/data/temporalEntities/vehicule-temporal-representation-sample.jsonld @@ -0,0 +1,48 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":[ + { + "type":"Property", + "value":"Volvo" + } + ], + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2018-08-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2018-08-01T12:07:00Z" + } + ], + "fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2018-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2018-08-01T14:07:00Z" + } + ], + "@context":[ + "https://fiware.github.io/data-models/context.jsonld", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 934ca4a4..2dc9d5e1 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -12,6 +12,7 @@ ${BATCH_UPSERT_ENDPOINT_PATH} entityOperations/upsert ${BATCH_UPDATE_ENDPOINT_PATH} entityOperations/update ${BATCH_DELETE_ENDPOINT_PATH} entityOperations/delete ${ENTITIES_ENDPOINT_PATH} entities +${TEMPORAL_ENTITIES_ENDPOINT_PATH} temporal/entities ${response} &{BATCH_OPERATION_ENDPOINT_MAPPING} create=${BATCH_CREATE_ENDPOINT_PATH} upsert=${BATCH_UPSERT_ENDPOINT_PATH} update=${BATCH_UPDATE_ENDPOINT_PATH} delete=${BATCH_DELETE_ENDPOINT_PATH} @@ -96,3 +97,27 @@ Batch Request Entities From File &{headers}= Create Dictionary Content-Type=application/ld+json ${response}= POST Request BatchRequest ${endpoint_url} data=${file_content} headers=${headers} Set Test Variable ${response} + +Create Temporal Representation Of Entity + [Arguments] ${filename} ${temporal_entity_representation_id} + ${temporal_entity_representation_payload}= Load Json From File ${EXECDIR}/data/temporalEntities/${filename} + ${temporal_entity_representation}= Update Value To Json ${temporal_entity_representation_payload} $..id ${temporal_entity_representation_id} + + &{headers}= Create Dictionary Content-Type=application/ld+json + ${response}= POST ${TEMPORAL_ENTITIES_ENDPOINT_PATH} body=${temporal_entity_representation} headers=${headers} + Output request + Output response + +Retrieve Temporal Representation Of Entity + [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${context}=${EMPTY} + ${attrs_length} = Get Length ${attrs} + &{headers}= Create Dictionary + &{params}= Create Dictionary + + Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} + + ${response}= GET ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id} headers=${headers} query=${params} + Output request + Output response + Set Test Variable ${response} \ No newline at end of file diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 324d8182..d24e7fa4 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -28,6 +28,17 @@ Check Response Body Containing Batch Operation Result Should Not Be Empty ${response_error['error']} END +Check Response Body Containing EntityTemporal element + [Arguments] ${expected_temporal_attributes} + Should Not Be Empty ${response['body']['id']} + Should Not Be Empty ${response['body']['type']} + #Should Not Be Empty ${response['body']['@context']} + + FOR ${expected_temporal_attribute} IN @{expected_temporal_attributes} + ${temporal_attribute}= Get From Dictionary ${response['body']} ${expected_temporal_attribute} + List Should Not Contain Duplicates ${temporal_attribute} + END + Check Response Body Containing Problem Details Element Containing Detail Element [Arguments] ${response_body} Should Not Be Empty ${response_body['detail']} diff --git a/resources/variables.py b/resources/variables.py index 7136ce1f..628e19a5 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,5 +1,6 @@ def get_variables(arg=None): variables = { - 'url': 'http://127.0.0.1:8082/ngsi-ld/v1' + 'url': 'http://10.5.1.214:9090/ngsi-ld/v1', + 'fiware_context': 'https://fiware.github.io/data-models/context.jsonld' } return variables -- GitLab From f8e879d88726eb2b452062c98ba22a18fd963395 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 10 Dec 2020 09:26:01 +0100 Subject: [PATCH 02/10] feat: add test for simplified temporal representation of entity --- .../020_10.robot | 31 +++++++++++++++++++ ...temporal-representation-expectation.jsonld | 15 +++++++++ resources/ApiUtils.resource | 6 ++-- resources/AssertionUtils.resource | 7 +++++ 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot create mode 100644 data/temporalEntities/expectations/vehicle-simplified-temporal-representation-expectation.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot new file mode 100644 index 00000000..31293c22 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot @@ -0,0 +1,31 @@ +*** Settings *** +Documentation Check that you can retrieve the temporal evolution of an entity with the simplified temporal representation +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= vehicule-temporal-representation-sample.jsonld +${vehicle_expectation_file}= vehicle-simplified-temporal-representation-expectation.jsonld + +*** Test Case *** +Retrieve the temporal evolution of an entity with the simplified temporal representation + [Documentation] Check that you can retrieve the temporal evolution of an entity with the simplified temporal representation + [Tags] mandatory + + @{options}= Create List temporalValues + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} options=${options} context=${fiware_context} + + Check Response Status Code Set To 200 + Check Response Body Containing simplified temporal representation of EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} + + #TODO Call Delete Temporal Representation Of Entity + +*** Keywords *** +Setup Initial Entities + ${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} diff --git a/data/temporalEntities/expectations/vehicle-simplified-temporal-representation-expectation.jsonld b/data/temporalEntities/expectations/vehicle-simplified-temporal-representation-expectation.jsonld new file mode 100644 index 00000000..6ed056e1 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-simplified-temporal-representation-expectation.jsonld @@ -0,0 +1,15 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName": "Volvo", + "speed":[ + [ 120, "2018-08-01T12:03:00Z" ], + [ 80, "2018-08-01T12:05:00Z" ], + [ 100, "2018-08-01T12:07:00Z" ] + ], + "fuelLevel":[ + [ 67, "2018-08-01T12:03:00Z" ], + [ 53, "2018-08-01T13:05:00Z" ], + [ 40, "2018-08-01T14:07:00Z" ] + ] +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 2dc9d5e1..4988385a 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -109,15 +109,17 @@ Create Temporal Representation Of Entity Output response Retrieve Temporal Representation Of Entity - [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${context}=${EMPTY} + [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${options}=${EMPTY} ${context}=${EMPTY} ${attrs_length} = Get Length ${attrs} + ${options_length} = Get Length ${options} &{headers}= Create Dictionary &{params}= Create Dictionary Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} + Run Keyword If ${options_length}>0 Set To Dictionary ${params} options=${options} ${response}= GET ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id} headers=${headers} query=${params} Output request Output response - Set Test Variable ${response} \ No newline at end of file + Set Test Variable ${response} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index d24e7fa4..fd79159c 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -39,6 +39,13 @@ Check Response Body Containing EntityTemporal element List Should Not Contain Duplicates ${temporal_attribute} END +Check Response Body Containing simplified temporal representation of EntityTemporal element + [Arguments] ${filename} ${temporal_entity_representation_id} + ${temporal_entity_representation_payload}= Load Json From File ${EXECDIR}/data/temporalEntities/expectations/${filename} + ${temporal_entity_representation}= Update Value To Json ${temporal_entity_representation_payload} $..id ${temporal_entity_representation_id} + + Dictionaries Should Be Equal ${response['body']} ${temporal_entity_representation} + Check Response Body Containing Problem Details Element Containing Detail Element [Arguments] ${response_body} Should Not Be Empty ${response_body['detail']} -- GitLab From 6510ea6e9190af897966e4fd1a07dafb0a6ba6f2 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Thu, 10 Dec 2020 16:24:51 +0100 Subject: [PATCH 03/10] feat: add a custom context for the ngsi-ld test suite --- resources/ngsi-ld-test-suite-context.jsonld | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 resources/ngsi-ld-test-suite-context.jsonld diff --git a/resources/ngsi-ld-test-suite-context.jsonld b/resources/ngsi-ld-test-suite-context.jsonld new file mode 100644 index 00000000..778923cf --- /dev/null +++ b/resources/ngsi-ld-test-suite-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "brandName": "https://ngsi-ld-test-suite/context#brandName", + "speed": "https://ngsi-ld-test-suite/context#speed", + "fuelLevel": "https://ngsi-ld-test-suite/context#fuelLevel" + } +} \ No newline at end of file -- GitLab From 26deef4d4e0280f80a033b45272d9b7e1f5e8a6f Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Thu, 10 Dec 2020 16:40:54 +0100 Subject: [PATCH 04/10] feat: use the temporary added ngsi-ld test suite context --- .../RetrieveTemporalEvolutionOfEntity/020_01.robot | 2 +- .../RetrieveTemporalEvolutionOfEntity/020_02.robot | 2 +- .../RetrieveTemporalEvolutionOfEntity/020_03.robot | 2 +- .../RetrieveTemporalEvolutionOfEntity/020_10.robot | 2 +- .../vehicule-temporal-representation-sample.jsonld | 2 +- resources/variables.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot index f016390f..b34e5300 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot @@ -16,7 +16,7 @@ Retrieve the temporal evolution of an entity Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} - @{expected_temporal_attributes}= Create List fuelLevel speed + @{expected_temporal_attributes}= Create List https://ngsi-ld-test-suite/context#speed https://ngsi-ld-test-suite/context#fuelLevel Check Response Status Code Set To 200 Check Response Body Containing EntityTemporal element ${expected_temporal_attributes} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot index a719e995..9a68c60c 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot @@ -14,7 +14,7 @@ Retrieve the temporal evolution of an entity using a context [Documentation] Check that you can retrieve the temporal evolution of an entity using a context [Tags] mandatory - Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} context=${fiware_context} + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} context=${ngsild_test_suite_context} @{expected_temporal_attributes}= Create List speed fuelLevel diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot index 7d36558e..7284c81f 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot @@ -15,7 +15,7 @@ Retrieve the temporal evolution of certain attributes of an entity [Tags] mandatory @{temporal_attributes_to_be_retrieved}= Create List fuelLevel - Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} attrs=${temporal_attributes_to_be_retrieved} context=${fiware_context} + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} attrs=${temporal_attributes_to_be_retrieved} context=${ngsild_test_suite_context} Check Response Status Code Set To 200 Check Response Body Containing EntityTemporal element ${temporal_attributes_to_be_retrieved} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot index 31293c22..a6541fbe 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot @@ -17,7 +17,7 @@ Retrieve the temporal evolution of an entity with the simplified temporal repres [Tags] mandatory @{options}= Create List temporalValues - Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} options=${options} context=${fiware_context} + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} options=${options} context=${ngsild_test_suite_context} Check Response Status Code Set To 200 Check Response Body Containing simplified temporal representation of EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} diff --git a/data/temporalEntities/vehicule-temporal-representation-sample.jsonld b/data/temporalEntities/vehicule-temporal-representation-sample.jsonld index 4823e1b2..3423d17c 100644 --- a/data/temporalEntities/vehicule-temporal-representation-sample.jsonld +++ b/data/temporalEntities/vehicule-temporal-representation-sample.jsonld @@ -42,7 +42,7 @@ } ], "@context":[ - "https://fiware.github.io/data-models/context.jsonld", + "https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld", "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" ] } \ No newline at end of file diff --git a/resources/variables.py b/resources/variables.py index 628e19a5..1917f8e8 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,6 +1,6 @@ def get_variables(arg=None): variables = { 'url': 'http://10.5.1.214:9090/ngsi-ld/v1', - 'fiware_context': 'https://fiware.github.io/data-models/context.jsonld' + 'ngsild_test_suite_context': 'https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld' } return variables -- GitLab From 81f0da8095132d248f6d3c21d861e4294d3b7276 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 11 Dec 2020 11:58:36 +0100 Subject: [PATCH 05/10] feat: improve assertions using a custom Compare Dictionaries Ignoring Keys keyword --- .../020_01.robot | 8 ++-- .../020_02.robot | 8 ++-- .../020_03.robot | 6 ++- .../020_10.robot | 2 +- ...l-representation-020-01-expectation.jsonld | 43 +++++++++++++++++++ ...l-representation-020-02-expectation.jsonld | 43 +++++++++++++++++++ ...l-representation-020-03-expectation.jsonld | 21 +++++++++ libraries/assertionUtils.py | 11 +++++ requirements.txt | 3 +- resources/AssertionUtils.resource | 21 ++++----- 10 files changed, 141 insertions(+), 25 deletions(-) create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-01-expectation.jsonld create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-02-expectation.jsonld create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-03-expectation.jsonld create mode 100644 libraries/assertionUtils.py diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot index b34e5300..9bbe02f2 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot @@ -8,6 +8,8 @@ Suite Setup Setup Initial Entities *** Variable *** ${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= vehicule-temporal-representation-sample.jsonld +${vehicle_expectation_file}= vehicle-temporal-representation-020-01-expectation.jsonld *** Test Case *** Retrieve the temporal evolution of an entity @@ -16,15 +18,13 @@ Retrieve the temporal evolution of an entity Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} - @{expected_temporal_attributes}= Create List https://ngsi-ld-test-suite/context#speed https://ngsi-ld-test-suite/context#fuelLevel - Check Response Status Code Set To 200 - Check Response Body Containing EntityTemporal element ${expected_temporal_attributes} + Check Response Body Containing EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} #TODO Call Delete Temporal Representation Of Entity *** Keywords *** Setup Initial Entities ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} - Create Temporal Representation Of Entity vehicule-temporal-representation-sample.jsonld ${temporal_entity_representation_id} + Create Temporal Representation Of Entity ${vehicle_payload_file} ${temporal_entity_representation_id} Set Suite Variable ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot index 9a68c60c..8031817d 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot @@ -8,6 +8,8 @@ Suite Setup Setup Initial Entities *** Variable *** ${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= vehicule-temporal-representation-sample.jsonld +${vehicle_expectation_file}= vehicle-temporal-representation-020-02-expectation.jsonld *** Test Case *** Retrieve the temporal evolution of an entity using a context @@ -16,15 +18,13 @@ Retrieve the temporal evolution of an entity using a context Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} context=${ngsild_test_suite_context} - @{expected_temporal_attributes}= Create List speed fuelLevel - Check Response Status Code Set To 200 - Check Response Body Containing EntityTemporal element ${expected_temporal_attributes} + Check Response Body Containing EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} #TODO Call Delete Temporal Representation Of Entity *** Keywords *** Setup Initial Entities ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} - Create Temporal Representation Of Entity vehicule-temporal-representation-sample.jsonld ${temporal_entity_representation_id} + Create Temporal Representation Of Entity ${vehicle_payload_file} ${temporal_entity_representation_id} Set Suite Variable ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot index 7284c81f..47e1f163 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot @@ -8,6 +8,8 @@ Suite Setup Setup Initial Entities *** Variable *** ${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= vehicule-temporal-representation-sample.jsonld +${vehicle_expectation_file}= vehicle-temporal-representation-020-03-expectation.jsonld *** Test Case *** Retrieve the temporal evolution of certain attributes of an entity @@ -18,12 +20,12 @@ Retrieve the temporal evolution of certain attributes of an entity Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} attrs=${temporal_attributes_to_be_retrieved} context=${ngsild_test_suite_context} Check Response Status Code Set To 200 - Check Response Body Containing EntityTemporal element ${temporal_attributes_to_be_retrieved} + Check Response Body Containing EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} #TODO Call Delete Temporal Representation Of Entity *** Keywords *** Setup Initial Entities ${temporal_entity_representation_id}= Generate Random Entity Id ${vehicule_id_prefix} - Create Temporal Representation Of Entity vehicule-temporal-representation-sample.jsonld ${temporal_entity_representation_id} + Create Temporal Representation Of Entity ${vehicle_payload_file} ${temporal_entity_representation_id} Set Suite Variable ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot index a6541fbe..8e8661d1 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot @@ -20,7 +20,7 @@ Retrieve the temporal evolution of an entity with the simplified temporal repres Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} options=${options} context=${ngsild_test_suite_context} Check Response Status Code Set To 200 - Check Response Body Containing simplified temporal representation of EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} + Check Response Body Containing EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} #TODO Call Delete Temporal Representation Of Entity diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-01-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-01-expectation.jsonld new file mode 100644 index 00000000..3671ae37 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-01-expectation.jsonld @@ -0,0 +1,43 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "https://ngsi-ld-test-suite/context#brandName":{ + "type":"Property", + "value":"Volvo" + }, + "https://ngsi-ld-test-suite/context#speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2018-08-01T12:05:00Z" + }, + + { + "type":"Property", + "value":100, + "observedAt":"2018-08-01T12:07:00Z" + } + ], + "https://ngsi-ld-test-suite/context#fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2018-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2018-08-01T14:07:00Z" + } + ] +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-02-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-02-expectation.jsonld new file mode 100644 index 00000000..ca4ca6ed --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-02-expectation.jsonld @@ -0,0 +1,43 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2018-08-01T12:05:00Z" + }, + + { + "type":"Property", + "value":100, + "observedAt":"2018-08-01T12:07:00Z" + } + ], + "fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2018-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2018-08-01T14:07:00Z" + } + ] +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-03-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-03-expectation.jsonld new file mode 100644 index 00000000..facf8b67 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-03-expectation.jsonld @@ -0,0 +1,21 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "fuelLevel":[ + { + "type":"Property", + "value":67, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":53, + "observedAt":"2018-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2018-08-01T14:07:00Z" + } + ] +} \ No newline at end of file diff --git a/libraries/assertionUtils.py b/libraries/assertionUtils.py new file mode 100644 index 00000000..f2c2b001 --- /dev/null +++ b/libraries/assertionUtils.py @@ -0,0 +1,11 @@ +from deepdiff import DeepDiff + +def compare_dictionaries_ignoring_keys(dict1, dict2, exclude_regex_paths): + """Function exposed as a keyword to compare two dictionaries + :param dict1: actual dictionary + :param dict2: expected dictionary + :param exclude_regex_paths: list of regex paths of keys to be ignored + """ + res = DeepDiff(dict1, dict2, exclude_regex_paths=[exclude_regex_paths], ignore_order=True) + print(res) + return not res \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6a311f15..66cc2975 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ robotframework==3.2.1 RESTinstance==1.0.2 robotframework-jsonschemalibrary==1.0 robotframework-jsonlibrary==0.3.1 -robotframework-requests==0.7.0 \ No newline at end of file +robotframework-requests==0.7.0 +deepdiff==5.0.2 \ No newline at end of file diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index fd79159c..c27409d5 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -1,3 +1,9 @@ +*** Settings *** +Library ${EXECDIR}/libraries/assertionUtils.py + +*** Variable *** +${instance_id_regex_expr}= root\\[.*\\]\\['instanceId'\\] + *** Keywords *** Check Response Status Code Set To [Arguments] ${expected_status} @@ -29,22 +35,11 @@ Check Response Body Containing Batch Operation Result END Check Response Body Containing EntityTemporal element - [Arguments] ${expected_temporal_attributes} - Should Not Be Empty ${response['body']['id']} - Should Not Be Empty ${response['body']['type']} - #Should Not Be Empty ${response['body']['@context']} - - FOR ${expected_temporal_attribute} IN @{expected_temporal_attributes} - ${temporal_attribute}= Get From Dictionary ${response['body']} ${expected_temporal_attribute} - List Should Not Contain Duplicates ${temporal_attribute} - END - -Check Response Body Containing simplified temporal representation of EntityTemporal element [Arguments] ${filename} ${temporal_entity_representation_id} ${temporal_entity_representation_payload}= Load Json From File ${EXECDIR}/data/temporalEntities/expectations/${filename} ${temporal_entity_representation}= Update Value To Json ${temporal_entity_representation_payload} $..id ${temporal_entity_representation_id} - - Dictionaries Should Be Equal ${response['body']} ${temporal_entity_representation} + ${comparaison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${temporal_entity_representation} ${instance_id_regex_expr} + Should Be True ${comparaison_result} msg=EntityTemporal Comparaison Failed Check Response Body Containing Problem Details Element Containing Detail Element [Arguments] ${response_body} -- GitLab From 3d31e93bdd7dda1e74521f6e37bed92e88600857 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 11 Dec 2020 12:02:53 +0100 Subject: [PATCH 06/10] feat: rename expectation file for TP 020_10 --- .../RetrieveTemporalEvolutionOfEntity/020_10.robot | 2 +- ...> vehicle-temporal-representation-020-10-expectation.jsonld} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename data/temporalEntities/expectations/{vehicle-simplified-temporal-representation-expectation.jsonld => vehicle-temporal-representation-020-10-expectation.jsonld} (100%) diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot index 8e8661d1..4c8f62bd 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot @@ -9,7 +9,7 @@ Suite Setup Setup Initial Entities *** Variable *** ${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: ${vehicle_payload_file}= vehicule-temporal-representation-sample.jsonld -${vehicle_expectation_file}= vehicle-simplified-temporal-representation-expectation.jsonld +${vehicle_expectation_file}= vehicle-temporal-representation-020-10-expectation.jsonld *** Test Case *** Retrieve the temporal evolution of an entity with the simplified temporal representation diff --git a/data/temporalEntities/expectations/vehicle-simplified-temporal-representation-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-10-expectation.jsonld similarity index 100% rename from data/temporalEntities/expectations/vehicle-simplified-temporal-representation-expectation.jsonld rename to data/temporalEntities/expectations/vehicle-temporal-representation-020-10-expectation.jsonld -- GitLab From 0e98feea45db0d9bb4736691946ce533f42c3bb2 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 11 Dec 2020 12:11:29 +0100 Subject: [PATCH 07/10] refactor: add line in EOF + update compare_dictionaries_ignoring_keys documentation --- libraries/assertionUtils.py | 4 ++-- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/assertionUtils.py b/libraries/assertionUtils.py index f2c2b001..87a56863 100644 --- a/libraries/assertionUtils.py +++ b/libraries/assertionUtils.py @@ -4,8 +4,8 @@ def compare_dictionaries_ignoring_keys(dict1, dict2, exclude_regex_paths): """Function exposed as a keyword to compare two dictionaries :param dict1: actual dictionary :param dict2: expected dictionary - :param exclude_regex_paths: list of regex paths of keys to be ignored + :param exclude_regex_paths: regex path of keys to be ignored """ res = DeepDiff(dict1, dict2, exclude_regex_paths=[exclude_regex_paths], ignore_order=True) print(res) - return not res \ No newline at end of file + return not res diff --git a/requirements.txt b/requirements.txt index 66cc2975..c82d1681 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ RESTinstance==1.0.2 robotframework-jsonschemalibrary==1.0 robotframework-jsonlibrary==0.3.1 robotframework-requests==0.7.0 -deepdiff==5.0.2 \ No newline at end of file +deepdiff==5.0.2 -- GitLab From aa8e8aab1e06ac878c0c060ec59d5901a91c2e97 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 11 Dec 2020 12:16:03 +0100 Subject: [PATCH 08/10] refactor: refactor ngsi-ld-test-suite-context.jsonld --- resources/ngsi-ld-test-suite-context.jsonld | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/ngsi-ld-test-suite-context.jsonld b/resources/ngsi-ld-test-suite-context.jsonld index 778923cf..b9f67ea2 100644 --- a/resources/ngsi-ld-test-suite-context.jsonld +++ b/resources/ngsi-ld-test-suite-context.jsonld @@ -1,7 +1,7 @@ { - "@context": { - "brandName": "https://ngsi-ld-test-suite/context#brandName", - "speed": "https://ngsi-ld-test-suite/context#speed", - "fuelLevel": "https://ngsi-ld-test-suite/context#fuelLevel" - } + "@context":{ + "brandName":"https://ngsi-ld-test-suite/context#brandName", + "speed":"https://ngsi-ld-test-suite/context#speed", + "fuelLevel":"https://ngsi-ld-test-suite/context#fuelLevel" + } } \ No newline at end of file -- GitLab From fd46483995136ae9aa2dcb05b3ccf37a1623b5a0 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 11 Dec 2020 12:22:46 +0100 Subject: [PATCH 09/10] feat: first integration --- .../020_04.robot | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot new file mode 100644 index 00000000..74c6ac45 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot @@ -0,0 +1,36 @@ +*** Settings *** +Documentation Check that you can retrieve the temporal evolution of an entity matching the given NGSI-LD temporal query +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Test Template Retrieve the temporal evolution of an entity matching the given NGSI-LD temporal query + +*** Variable *** +${vehicule_id_prefix}= urn:ngsi-ld:Vehicle: +${vehicle_payload_file}= vehicule-temporal-representation-sample.jsonld + +*** Test Cases *** TIMEREL TIME ENDTIME VEHICLE_EXPECTATION_FILE +After after 2018-08-01T13:03:00Z ${EMPTY} vehicle-temporal-representation-020-04-01-expectation.jsonld +Before before 2018-08-01T12:05:00Z ${EMPTY} vehicle-temporal-representation-020-04-02-expectation.jsonld +Between between 2018-08-01T12:00:00Z 2018-08-01T13:00:00Z vehicle-temporal-representation-020-04-03-expectation.jsonld + +*** Keywords *** +Retrieve the temporal evolution of an entity matching the given NGSI-LD temporal query + [Arguments] ${timerel} ${time} ${endTime} ${vehicle_expectation_file} + [Documentation] Check that you can retrieve the temporal evolution of an entity matching the given NGSI-LD temporal query + [Tags] mandatory + + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} timerel=${timerel} time=${time} endTime=${endTime} + + Check Response Status Code Set To 200 + Check Response Body Containing EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} + + +Setup Initial Entities + ${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} + +#TODO Call Suite Teardown \ No newline at end of file -- GitLab From f96fc52d7edf19443047ba7a957159cb5632c35a Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 11 Dec 2020 12:33:57 +0100 Subject: [PATCH 10/10] feat: add tp 020_04 --- .../020_04.robot | 2 +- ...epresentation-020-04-01-expectation.jsonld | 20 +++++++++++++ ...epresentation-020-04-02-expectation.jsonld | 25 ++++++++++++++++ ...epresentation-020-04-03-expectation.jsonld | 30 +++++++++++++++++++ resources/ApiUtils.resource | 5 +++- 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-04-01-expectation.jsonld create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-04-02-expectation.jsonld create mode 100644 data/temporalEntities/expectations/vehicle-temporal-representation-020-04-03-expectation.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot index 74c6ac45..5640f072 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_04.robot @@ -22,7 +22,7 @@ Retrieve the temporal evolution of an entity matching the given NGSI-LD temporal [Documentation] Check that you can retrieve the temporal evolution of an entity matching the given NGSI-LD temporal query [Tags] mandatory - Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} timerel=${timerel} time=${time} endTime=${endTime} + Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} timerel=${timerel} time=${time} endTime=${endTime} context=${ngsild_test_suite_context} Check Response Status Code Set To 200 Check Response Body Containing EntityTemporal element ${vehicle_expectation_file} ${temporal_entity_representation_id} diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-01-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-01-expectation.jsonld new file mode 100644 index 00000000..32bf63c0 --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-01-expectation.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "fuelLevel":[ + { + "type":"Property", + "value":53, + "observedAt":"2018-08-01T13:05:00Z" + }, + { + "type":"Property", + "value":40, + "observedAt":"2018-08-01T14:07:00Z" + } + ] +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-02-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-02-expectation.jsonld new file mode 100644 index 00000000..af46993b --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-02-expectation.jsonld @@ -0,0 +1,25 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "fuelLevel":{ + "type":"Property", + "value":67, + "observedAt":"2018-08-01T12:03:00Z" + }, + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2018-08-01T12:05:00Z" + } + ] +} \ No newline at end of file diff --git a/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-03-expectation.jsonld b/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-03-expectation.jsonld new file mode 100644 index 00000000..8c87d29e --- /dev/null +++ b/data/temporalEntities/expectations/vehicle-temporal-representation-020-04-03-expectation.jsonld @@ -0,0 +1,30 @@ +{ + "id":"urn:ngsi-ld:Vehicle:randomUUID", + "type":"Vehicle", + "brandName":{ + "type":"Property", + "value":"Volvo" + }, + "fuelLevel":{ + "type":"Property", + "value":67, + "observedAt":"2018-08-01T12:03:00Z" + }, + "speed":[ + { + "type":"Property", + "value":120, + "observedAt":"2018-08-01T12:03:00Z" + }, + { + "type":"Property", + "value":80, + "observedAt":"2018-08-01T12:05:00Z" + }, + { + "type":"Property", + "value":100, + "observedAt":"2018-08-01T12:07:00Z" + } + ] +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 4988385a..547834a9 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -109,7 +109,7 @@ Create Temporal Representation Of Entity Output response Retrieve Temporal Representation Of Entity - [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${options}=${EMPTY} ${context}=${EMPTY} + [Arguments] ${temporal_entity_representation_id} ${attrs}=${EMPTY} ${options}=${EMPTY} ${context}=${EMPTY} ${timerel}=${EMPTY} ${time}=${EMPTY} ${endTime}=${EMPTY} ${attrs_length} = Get Length ${attrs} ${options_length} = Get Length ${options} &{headers}= Create Dictionary @@ -118,6 +118,9 @@ Retrieve Temporal Representation Of Entity Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" Run Keyword If ${attrs_length}>0 Set To Dictionary ${params} attrs=${attrs} Run Keyword If ${options_length}>0 Set To Dictionary ${params} options=${options} + Run Keyword If '${timerel}'!='' Set To Dictionary ${params} timerel=${timerel} + Run Keyword If '${time}'!='' Set To Dictionary ${params} time=${time} + Run Keyword If '${endTime}'!='' Set To Dictionary ${params} endTime=${endTime} ${response}= GET ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id} headers=${headers} query=${params} Output request -- GitLab