diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_01.robot new file mode 100644 index 0000000000000000000000000000000000000000..1fc0f388cb38f929656da22b293921669ebc6b25 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_01.robot @@ -0,0 +1,61 @@ +*** Settings *** +Documentation If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query. + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Before Test +Suite Teardown After Test + + +*** Variables *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_payload_file_path}= subscriptions/subscription-building-entities-type-selection.jsonld +${building_id_prefix}= urn:ngsi-ld:Building: +${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify +${entity_building_filepath}= building-simple-attributes-sample.jsonld +${content_type}= application/ld+json + + +*** Test Cases *** +046_16_01 Check that a notification is sent with entity matching the entity type selection + [Documentation] If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query. + [Tags] sub-notification 5_8_6 since_v1.5.1 + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${response}= Create Entity Selecting Content Type + ... ${entity_building_filepath} + ... ${entity_id} + ... ${content_type} + Set Suite Variable ${entity_id} + + ${notification} ${headers}= Wait for notification timeout=${5} + + Should be Equal ${subscription_id} ${notification}[subscriptionId] + Dictionary Should Contain Key ${notification} data + Should Not Be Empty ${notification}[data] Notification data should not be empty + Should be Equal ${entity_id} ${notification}[data][0][id] + + +*** Keywords *** +Setup Initial Subscription + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${notification_server_send_url} + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Set Suite Variable ${subscription_id} + +Before Test + Start Local Server ${notification_server_host} ${notification_server_port} + Sleep 1s + Setup Initial Subscription + +After Test + Delete Subscription ${subscription_id} + Delete Entity by Id ${entity_id} + Stop Local Server diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_02.robot new file mode 100644 index 0000000000000000000000000000000000000000..b07e3496f07efb37c86208ee4e75a43d337cd46f --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_02.robot @@ -0,0 +1,56 @@ +*** Settings *** +Documentation If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query. + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Before Test +Suite Teardown After Test + + +*** Variables *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_payload_file_path}= subscriptions/subscription-building-entities-type-selection.jsonld +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify +${entity_vehicle_filepath}= vehicle-simple-attributes-sample.jsonld +${content_type}= application/ld+json + + +*** Test Cases *** +046_16_02 Check that a notification is not sent if the entity type does not match the entity type selection + [Documentation] If a subscription defines an entity type selection query, a notification shall not be sent if the entity type does not match the query + [Tags] sub-notification 5_8_6 since_v1.5.1 + + ${vehicle_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${response}= Create Entity Selecting Content Type + ... ${entity_vehicle_filepath} + ... ${vehicle_id} + ... ${content_type} + Set Suite Variable ${vehicle_id} + + Wait for no notification + + +*** Keywords *** +Setup Initial Subscription + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${notification_server_send_url} + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Set Suite Variable ${subscription_id} + +Before Test + Start Local Server ${notification_server_host} ${notification_server_port} + Sleep 1s + Setup Initial Subscription + +After Test + Delete Subscription ${subscription_id} + Delete Entity by Id ${vehicle_id} + Stop Local Server diff --git a/data/subscriptions/subscription-building-entities-type-selection.jsonld b/data/subscriptions/subscription-building-entities-type-selection.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..901561427aad07eb6c17174044f608901b89e200 --- /dev/null +++ b/data/subscriptions/subscription-building-entities-type-selection.jsonld @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"(Building|Tower)" + } + ], + "notificationTrigger": ["entityCreated"], + "notification":{ + "endpoint":{ + "uri":"http://my.endpoint.org/notify" + } + }, + "@context":[ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] + } \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/046_16_01.json b/doc/files/ContextInformation/Subscription/046_16_01.json new file mode 100644 index 0000000000000000000000000000000000000000..89d9df44c37c63b33dd2a40abd32ef47684d8347 --- /dev/null +++ b/doc/files/ContextInformation/Subscription/046_16_01.json @@ -0,0 +1,40 @@ +{ + "tp_id": "TP/NGSI-LD/CI/SUB/046_16_01", + "test_objective": "If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query.", + "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.5.1", + "clauses": [ + "5.8.6" + ], + "pics_selection": "", + "keywords": [ + "Setup Initial Subscription", + "Before Test", + "After Test" + ], + "teardown": "After Test", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "046_16_01 Check that a notification is sent with entity matching the entity type selection", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/046_16_01", + "doc": "If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query.", + "tags": [ + "5_8_6", + "since_v1.5.1", + "sub-notification" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the client at '${endpoint}' receives a valid Notification containing:\n Notification received After waiting '5' seconds and\n Notification received Notification data: '${notification}[subscriptionId]' equal to '${subscription_id}' and\n Notification received Notification data: '${notification}[data][0][id]' equal to '${entity_id}' and\n Notification received The dictionary `${notification}' should contain the key 'data' and\n Notification received The variable `${notification}[data]' should not be '${EMPTY}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/ld+json' and\n payload defined in file: 'building-simple-attributes-sample.jsonld'\n}", + "http_verb": "POST", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour", + "robotfile": "046_16_01" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/046_16_02.json b/doc/files/ContextInformation/Subscription/046_16_02.json new file mode 100644 index 0000000000000000000000000000000000000000..507da9a52de56098f6444967448c5a9af1449626 --- /dev/null +++ b/doc/files/ContextInformation/Subscription/046_16_02.json @@ -0,0 +1,40 @@ +{ + "tp_id": "TP/NGSI-LD/CI/SUB/046_16_02", + "test_objective": "If a subscription defines an entity type selection query, a notification shall be sent whenever an entity matches the query.", + "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.5.1", + "clauses": [ + "5.8.6" + ], + "pics_selection": "", + "keywords": [ + "Setup Initial Subscription", + "Before Test", + "After Test" + ], + "teardown": "After Test", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "046_16_02 Check that a notification is not sent if the entity type does not match the entity type selection", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/046_16_02", + "doc": "If a subscription defines an entity type selection query, a notification shall not be sent if the entity type does not match the query", + "tags": [ + "5_8_6", + "since_v1.5.1", + "sub-notification" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the client at '${endpoint}' receives a valid Notification containing:\n Notification received Waiting for no Notification data and\n Query Parameter: timeout set to '5'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/ld+json' and\n payload defined in file: 'vehicle-simple-attributes-sample.jsonld'\n}", + "http_verb": "POST", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour", + "robotfile": "046_16_02" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Subscription.py b/doc/tests/test_ContextInformation_Subscription.py index 097a4a0a71db20fe54b3f209d0f85c86a7a5fd33..404842ac693955a17b367325241c0e0316f6b272 100644 --- a/doc/tests/test_ContextInformation_Subscription.py +++ b/doc/tests/test_ContextInformation_Subscription.py @@ -203,6 +203,20 @@ class TestCISubscription(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_046_16_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/046_16_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_046_16_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_046_16_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/046_16_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_046_16_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_031_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/031_01.json'