From dcc41a57a807886c45262bc670f72e0fb78d5c35 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Tue, 16 Mar 2021 16:45:28 +0100 Subject: [PATCH] feat: add missing tc for query context source registrations --- .../037_10.robot | 52 +++++++++++++++++ ...e-registrations-037-10-01-expectation.json | 37 ++++++++++++ ...e-registrations-037-10-02-expectation.json | 23 ++++++++ ...e-registrations-037-10-03-expectation.json | 58 +++++++++++++++++++ resources/ApiUtils.resource | 3 +- 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_10.robot create mode 100644 data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json create mode 100644 data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json create mode 100644 data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json diff --git a/TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_10.robot b/TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_10.robot new file mode 100644 index 00000000..94076c1f --- /dev/null +++ b/TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_10.robot @@ -0,0 +1,52 @@ +*** Settings *** +Documentation Check that you can query context source registrations. If present, the conditions specified by the context source query match the respective Context Source Properties +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Query Context Source Registration With Query Params +Suite Setup Setup Initial Context Source Registrations +Suite Teardown Delete Created Context Source Registrations + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${first_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${second_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-detailed-information-sample.jsonld +${third_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-location-sample.jsonld + +*** Test Cases *** QUERY_PARAM_NAME QUERY_PARAM_VALUE EXPECTATION_FILE_PATH EXPECTED_CONTEXT_SOURCE_REGISTRATION_IDS +With list of Entity Ids id ${first_context_source_registration_id},${third_context_source_registration_id} csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json ${first_context_source_registration_id} ${third_context_source_registration_id} +With NGSI-LD Query q location.type=="GeoProperty" csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json ${third_context_source_registration_id} +With Context Source Filter csf endpoint=="http://my.csource.org:1026" csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json ${first_context_source_registration_id} ${second_context_source_registration_id} ${third_context_source_registration_id} + +*** Keywords *** +Query Context Source Registration With Query Params + [Arguments] ${query_param_name} ${query_param_value} ${expectation_file_path} @{expected_context_source_registration_ids} + [Documentation] Check that you can query context source registrations. If present, the conditions specified by the context source query match the respective Context Source Properties + [Tags] mandatory + + Query Context Source Registrations context=${ngsild_test_suite_context} ${query_param_name}=${query_param_value} + + Check Response Status Code Set To 200 + Check Response Body Containing List Containing Context Source Registrations elements ${expectation_file_path} ${expected_context_source_registration_ids} + +Setup Initial Context Source Registrations + ${first_context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${second_context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${third_context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${first_context_source_registration_payload}= Load Test Sample ${first_context_source_registration_payload_file_path} ${first_context_source_registration_id} + ${second_context_source_registration_payload}= Load Test Sample ${second_context_source_registration_payload_file_path} ${second_context_source_registration_id} + ${third_context_source_registration_payload}= Load Test Sample ${third_context_source_registration_payload_file_path} ${third_context_source_registration_id} + + Create Context Source Registration ${first_context_source_registration_payload} + Create Context Source Registration ${second_context_source_registration_payload} + Create Context Source Registration ${third_context_source_registration_payload} + + Set Suite Variable ${first_context_source_registration_id} + Set Suite Variable ${second_context_source_registration_id} + Set Suite Variable ${third_context_source_registration_id} + +Delete Created Context Source Registrations + Delete Context Source Registration ${first_context_source_registration_id} + Delete Context Source Registration ${second_context_source_registration_id} + Delete Context Source Registration ${third_context_source_registration_id} diff --git a/data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json b/data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json new file mode 100644 index 00000000..25b886f0 --- /dev/null +++ b/data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json @@ -0,0 +1,37 @@ +[ + { + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026" + }, + { + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "location":{ + "type":"GeoProperty", + "value":{ + "type":"Point", + "coordinates":[-8.521,41.2] + } + }, + "endpoint":"http://my.csource.org:1026" + } +] \ No newline at end of file diff --git a/data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json b/data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json new file mode 100644 index 00000000..c462e3a6 --- /dev/null +++ b/data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json @@ -0,0 +1,23 @@ +[ + { + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "location":{ + "type":"GeoProperty", + "value":{ + "type":"Point", + "coordinates":[-8.521,41.2] + } + }, + "endpoint":"http://my.csource.org:1026" + } +] \ No newline at end of file diff --git a/data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json b/data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json new file mode 100644 index 00000000..0d7f5b3c --- /dev/null +++ b/data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json @@ -0,0 +1,58 @@ +[ + { + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026" + }, + { + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ], + "propertyNames":[ + "name", + "subCategory" + ], + "relationshipNames":[ + "locatedAt" + ] + } + ], + "endpoint":"http://my.csource.org:1026" + }, + { + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "location":{ + "type":"GeoProperty", + "value":{ + "type":"Point", + "coordinates":[-8.521,41.2] + } + }, + "endpoint":"http://my.csource.org:1026" + } +] \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index b1243bca..28af5b77 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -547,7 +547,7 @@ Update Context Source Registration Set Test Variable ${response} Query Context Source Registrations - [Arguments] ${context}=${EMPTY} ${id}=${EMPTY} ${type}=${EMPTY} ${attrs}=${EMPTY} ${q}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timeproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} ${accept}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${id}=${EMPTY} ${type}=${EMPTY} ${attrs}=${EMPTY} ${q}=${EMPTY} ${csf}=${EMPTY} ${georel}=${EMPTY} ${geometry}=${EMPTY} ${coordinates}=${EMPTY} ${geoproperty}=${EMPTY} ${timeproperty}=${EMPTY} ${timerel}=${EMPTY} ${timeAt}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} &{headers}= Create Dictionary &{params}= Create Dictionary @@ -557,6 +557,7 @@ Query Context Source Registrations Run Keyword If '${type}'!='' Set To Dictionary ${params} type=${type} Run Keyword If '${attrs}'!='' Set To Dictionary ${params} attrs=${attrs} Run Keyword If '${q}'!='' Set To Dictionary ${params} q=${q} + 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} -- GitLab