diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot new file mode 100644 index 0000000000000000000000000000000000000000..05bdf75fb702afc4d118e74a900a5577088b6bef --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot @@ -0,0 +1,42 @@ +*** Settings *** +Documentation Check that you can query the temporal evolution of entities matching the given NGSI-LD Context Source filter +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Suite Setup Create Initial Context Source Registration +Suite Teardown Delete Initial Context Source Registration + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-observationInterval-sample.jsonld +${context_source_url}= http://${context_source_host}:${context_source_port} + +*** Test Case *** +Query the temporal evolution of entities matching the given NGSI-LD context source filter + [Documentation] Check that you can query the temporal evolution of entities matching the given NGSI-LD Context Source filter + [Tags] mandatory + + @{entity_types_to_be_retrieved}= Create List Building + + Query Temporal Representation Of Entities entity_types=${entity_types_to_be_retrieved} csf=endpoint=="${context_source_url}" timerel=after timeAt=2020-07-01T12:05:00Z context=${ngsild_test_suite_context} + + Wait for redirected request + Check Response Status Code Set To 200 + +*** Keywords *** +Create Initial Context Source Registration + Start Context Source Mock Server + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Context Source Registration Sample With Reachable Context Source ${context_source_registration_payload_file_path} ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + Set Suite Variable ${context_source_registration_id} + +Delete Initial Context Source Registration + Stop Context Source Mock Server + + Delete Context Source Registration ${context_source_registration_id} diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 1a69029a268ac8cdda352dbaab0839df3edd7f5f..7a31f5543fc85bfa156e6abbdc33236994e4f691 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -369,7 +369,7 @@ Retrieve Temporal Representation Of Entity Set Test Variable ${response} Query Temporal Representation Of Entities - [Arguments] ${context}=${EMPTY} ${entity_types}=${EMPTY} ${entity_ids}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${ngsild_query}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${limit}=${EMPTY} ${lastN}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${entity_types}=${EMPTY} ${entity_ids}=${EMPTY} ${entity_id_pattern}=${EMPTY} ${ngsild_query}=${EMPTY} ${csf}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${attrs}=${EMPTY} ${limit}=${EMPTY} ${lastN}=${EMPTY} ${entity_types_length} = Get Length ${entity_types} ${entity_ids_length} = Get Length ${entity_ids} ${attrs_length} = Get Length ${attrs} @@ -384,6 +384,7 @@ Query Temporal Representation Of Entities Run Keyword If '${lastN}'!='' Set To Dictionary ${params} lastN=${lastN} Run Keyword If '${entity_id_pattern}'!='' Set To Dictionary ${params} idPattern=${entity_id_pattern} Run Keyword If '${ngsild_query}'!='' Set To Dictionary ${params} q=${ngsild_query} + Run Keyword If '${csf}'!='' Set To Dictionary ${params} csf=${csf} Run Keyword If '${georel}'!='' Set To Dictionary ${params} georel=${georel} Run Keyword If '${geometry}'!='' Set To Dictionary ${params} geometry=${geometry} Run Keyword If '${coordinates}'!='' Set To Dictionary ${params} coordinates=${coordinates} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 0349eb62986c6f6f2a53aeb2dd7a13a835e4ffb3..cda0beb8879979b3ea239703fbb9ce009edf61a2 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -135,7 +135,7 @@ Check Response Body Containing List Containing Subscription elements ${comparison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${subscription_payload} ${EMPTY} Should Be True ${comparison_result} msg=Subscription Comparison Failed -# Since response body can be a json object if it contains one subscription +# Since response body can be a json object if it contains one element # A check on the response body type is needed Check Response Body Containing Number Of Entities [Arguments] ${expected_entity_type} ${expected_length} diff --git a/resources/JsonUtils.resource b/resources/JsonUtils.resource index c0827f792bb3c3671a05cfc94ca5e8672c856a88..07767d1d49ae159b3ca00590c2585d52493a5ad7 100644 --- a/resources/JsonUtils.resource +++ b/resources/JsonUtils.resource @@ -6,6 +6,7 @@ Library JSONLibrary *** Variable *** ${date_format}= %Y-%m-%dT%H:%M:%SZ ${notification_server_url}= http://${notification_server_host}:${notification_server_port}/notify +${context_source_url}= http://${context_source_host}:${context_source_port} *** Keywords *** Load Entity @@ -34,6 +35,14 @@ Load Subscription Sample With Reachable Endpoint [return] ${subscription} +Load Context Source Registration Sample With Reachable Context Source + [Arguments] ${context_source_registration_file_path} ${context_source_registration_id}=${EMPTY} ${context_source_endpoint_uri}=${context_source_url} + + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_file_path} ${context_source_registration_id} + ${context_source_registration}= Update Value To Json ${context_source_registration_payload} $..endpoint ${context_source_endpoint_uri} + + [return] ${context_source_registration} + Remove Entity Type [Arguments] ${entity} diff --git a/resources/MockServerUtils.resource b/resources/MockServerUtils.resource new file mode 100644 index 0000000000000000000000000000000000000000..9aa766e2976d5a59b46c9fc0f7278a23a5009a3b --- /dev/null +++ b/resources/MockServerUtils.resource @@ -0,0 +1,21 @@ +*** Settings *** +Documentation Mock http server for context sources +Library HttpCtrl.Server + +*** Keywords *** +Start Context Source Mock Server + #Initialize HTTP Client And Server + Start Server 0.0.0.0 8086 + +Wait for redirected request + [Arguments] ${timeout}=${5} + #HTTP server receives it and checks incoming request for correctness + #.. "Wait For Request" + #.... This call is blocked until HTTP request arrives or timeout. + #.... Further detaills: https://annoviko.github.io/robotframework-httpctrl/server.html#Wait%20For%20Request + Wait For Request ${timeout} + Reply By 200 + +Stop Context Source Mock Server + #Terminate HTTP Server + Stop Server diff --git a/resources/variables.py b/resources/variables.py index 8cbd37d43375ca0399ee3694d8d352f68ef02d65..4890d76bb8c52741ae930e8eee2d5183e59b4e9b 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -3,7 +3,9 @@ def get_variables(arg=None): 'url': 'https://broker-ngsi-ld.demeter.ubiwhere.com/ngsi-ld/v1', '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', 'notification_server_host': '0.0.0.0', - 'notification_server_port': 8085 + 'notification_server_port': 8085, + 'context_source_host': '0.0.0.0', + 'context_source_port': 8086 } return variables \ No newline at end of file