diff --git a/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_01.robot new file mode 100644 index 0000000000000000000000000000000000000000..4507b2dfb879626017d44027b500f8cede1e93f9 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_01.robot @@ -0,0 +1,45 @@ +*** Settings *** +Documentation Check that you can query a list of subscriptions +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Subscriptions +Suite Teardown Delete Initial Subscriptions + +*** Variable *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${first_subscription_payload_file_path}= subscriptions/subscription-sample.jsonld +${second_subscription_payload_file_path}= subscriptions/subscription-watchedAttributes-sample.jsonld +${third_subscription_payload_file_path}= subscriptions/subscription-inactive-sample.jsonld +${expectation_file_path}= subscriptions/expectations/subscriptions-031-01-expectation.json + +*** Test Case *** +Query Subscriptions + [Documentation] Check that you can query a list of subscriptions + [Tags] mandatory + + Query Subscriptions context=${ngsild_test_suite_context} + + @{subscription_ids}= Create List ${first_subscription_id} ${second_subscription_id} ${third_subscription_id} + Check Response Status Code Set To 200 + Check Response Body Containing List Containing Subscription elements ${expectation_file_path} ${subscription_ids} + +*** Keywords *** +Setup Initial Subscriptions + ${first_subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${second_subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${third_subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + + Create Subscription ${first_subscription_id} ${first_subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + Create Subscription ${second_subscription_id} ${second_subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + Create Subscription ${third_subscription_id} ${third_subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + Set Suite Variable ${first_subscription_id} + Set Suite Variable ${second_subscription_id} + Set Suite Variable ${third_subscription_id} + +Delete Initial Subscriptions + Delete Subscription ${first_subscription_id} + Delete Subscription ${second_subscription_id} + Delete Subscription ${third_subscription_id} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_02.robot new file mode 100644 index 0000000000000000000000000000000000000000..15078a312d20af1153013d8faf7450676dde87a0 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_02.robot @@ -0,0 +1,50 @@ +*** Settings *** +Documentation Check that you can query a list of subscriptions: Pagination logic shall be in place +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Query Subscriptions With Limit And Page Parameters +Suite Setup Setup Initial Subscriptions +Suite Teardown Delete Initial Subscriptions + +*** Variable *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${first_subscription_payload_file_path}= subscriptions/subscription-sample.jsonld +${second_subscription_payload_file_path}= subscriptions/subscription-watchedAttributes-sample.jsonld +${third_subscription_payload_file_path}= subscriptions/subscription-inactive-sample.jsonld + +*** Test Cases *** LIMIT PAGE EXPECTED_SUBSCRIPTION_NUMBER PREV_LINK NEXT_LINK +Query Second Subscription ${1} ${2} ${1} ;rel="prev";type="application/ld+json" ;rel="next";type="application/ld+json" +Query Last Subscription ${2} ${2} ${1} ;rel="prev";type="application/ld+json" ${EMPTY} +Query All Subscriptions ${15} ${1} ${3} ${EMPTY} ${EMPTY} + +*** Keywords *** +Query Subscriptions With Limit And Page Parameters + [Arguments] ${limit} ${page} ${expectation_subscription_number} ${prev_link} ${next_link} + [Documentation] Check that you can query a list of subscriptions: Pagination logic shall be in place + [Tags] mandatory + + Query Subscriptions context=${ngsild_test_suite_context} limit=${limit} page=${page} + + Check Response Status Code Set To 200 + Check Response Body Containing Number Of Entities Subscription ${expectation_subscription_number} + Check Pagination Prev And Next Headers ${prev_link} ${next_link} + +Setup Initial Subscriptions + ${first_subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${second_subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${third_subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + + Create Subscription ${first_subscription_id} ${first_subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + Create Subscription ${second_subscription_id} ${second_subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + Create Subscription ${third_subscription_id} ${third_subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + Set Suite Variable ${first_subscription_id} + Set Suite Variable ${second_subscription_id} + Set Suite Variable ${third_subscription_id} + +Delete Initial Subscriptions + Delete Subscription ${first_subscription_id} + Delete Subscription ${second_subscription_id} + Delete Subscription ${third_subscription_id} diff --git a/data/subscriptions/expectations/subscriptions-031-01-expectation.json b/data/subscriptions/expectations/subscriptions-031-01-expectation.json new file mode 100644 index 0000000000000000000000000000000000000000..cd952e1f2127a1c3b4a10801d313ae494a99fd7e --- /dev/null +++ b/data/subscriptions/expectations/subscriptions-031-01-expectation.json @@ -0,0 +1,57 @@ +[ + { + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "status": "active" + }, + { + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "watchedAttributes":[ + "name", + "subCategory" + ], + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "status": "active" + }, + { + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "status": "paused" + } +] \ No newline at end of file diff --git a/data/subscriptions/subscription-watchedAttributes-sample.jsonld b/data/subscriptions/subscription-watchedAttributes-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..de343a44a405181d74cebd2fd8983969fd69795f --- /dev/null +++ b/data/subscriptions/subscription-watchedAttributes-sample.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "watchedAttributes": ["name", "subCategory"], + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "@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" + ] +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 3a024e6ecfc09e236730fd476614b58609608a77..51895df334d3dad5e8a37d7b1affdb5a16fcb8bb 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -693,16 +693,20 @@ Delete Subscription [return] ${response} Query Subscriptions - [Arguments] ${limit}=${EMPTY} ${accept}=${EMPTY} + [Arguments] ${context}=${EMPTY} ${limit}=${EMPTY} ${page}=${EMPTY} ${accept}=${EMPTY} + &{headers}= Create Dictionary &{params}= Create Dictionary - Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + 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 '${limit}'!='' Set To Dictionary ${params} limit=${limit} + Run Keyword If '${page}'!='' Set To Dictionary ${params} page=${page} + Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} - ${response}= GET ${SUBSCRIPTION_ENDPOINT_PATH} headers=${headers} query=${params} + ${response}= GET ${SUBSCRIPTION_ENDPOINT_PATH} headers=${headers} query=${params} Output request Output response - [return] ${response} + + Set Test Variable ${response} Retrieve Subscription [Arguments] ${id} ${accept}=${EMPTY} ${context}=${EMPTY}