diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16.robot new file mode 100644 index 0000000000000000000000000000000000000000..97abcfef13f7372b848a4dba63f1234204f0a9e7 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation The system generated attributes are included in the response payload body of a notification if sysAttrs parameter is set to true. + +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-with-true-sysAttrs-parameter-sample.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${notification_server_send_url} http://${notification_server_host}:${notification_server_port}/notify + + +*** Test Cases *** +046_16_01 Check that the response payload body contains the system generated attributes if sysAttrs parameter is set to true + [Documentation] The system generated attributes are included in the response payload body of a notification if sysAttrs parameter is set to true. + [Tags] sub-notification 5_8_6 + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + ${notification} ${headers}= Wait for notification timeout=${10} + + ${notification_payload}= Get Request Body + + ${notification}= Evaluate json.loads('''${notification_payload}''') json + + Dictionary Should Contain Key ${notification}[data][0] createdAt + Dictionary Should Contain Key ${notification}[data][0] modifiedAt + + +*** Keywords *** +Before Test + Start Local Server ${notification_server_host} ${notification_server_port} + Setup Initial Subscriptions + +Setup Initial Subscriptions + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${notification_server_send_url} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + Set Suite Variable ${entity_id} + Set Suite Variable ${subscription_id} + + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Stop Local Server + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_17.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_17.robot new file mode 100644 index 0000000000000000000000000000000000000000..d23e878109f43db673649e28f0ec07f8d59ea192 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_17.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation The system generated attributes are not included in the response payload body of a notification if sysAttrs parameter is set to false. + +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-with-false-sysAttrs-parameter-sample.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${notification_server_send_url} http://${notification_server_host}:${notification_server_port}/notify + + +*** Test Cases *** +046_17_01 Check that the response payload body does not contain the system generated attributes if sysAttrs parameter is set to false + [Documentation] The system generated attributes are not included in the response payload body of a notification if sysAttrs parameter is set to false. + [Tags] sub-notification 5_8_6 + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + ${notification} ${headers}= Wait for notification timeout=${10} + + ${notification_payload}= Get Request Body + + ${notification}= Evaluate json.loads('''${notification_payload}''') json + + Dictionary Should Not Contain Key ${notification}[data][0] createdAt + Dictionary Should Not Contain Key ${notification}[data][0] modifiedAt + + +*** Keywords *** +Before Test + Start Local Server ${notification_server_host} ${notification_server_port} + Setup Initial Subscriptions + +Setup Initial Subscriptions + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${notification_server_send_url} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + Set Suite Variable ${entity_id} + Set Suite Variable ${subscription_id} + + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Stop Local Server + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/data/subscriptions/subscription-with-false-sysAttrs-parameter-sample.jsonld b/data/subscriptions/subscription-with-false-sysAttrs-parameter-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..899b618262f26301e9f185041872f1bf380b94d4 --- /dev/null +++ b/data/subscriptions/subscription-with-false-sysAttrs-parameter-sample.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + }, + "sysAttrs" : false + }, + "@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/data/subscriptions/subscription-with-true-sysAttrs-parameter-sample.jsonld b/data/subscriptions/subscription-with-true-sysAttrs-parameter-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..5083ad0137dce397d177058b06ea1827d434cd6a --- /dev/null +++ b/data/subscriptions/subscription-with-true-sysAttrs-parameter-sample.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + }, + "sysAttrs" : true + }, + "@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/tests/test_ContextInformation_Subscription.py b/doc/tests/test_ContextInformation_Subscription.py index 215414cad4237214446a3b1b3bc8491f664eac3f..43275775c8aeb04fd18dceec7655e86ff1b5f2c8 100644 --- a/doc/tests/test_ContextInformation_Subscription.py +++ b/doc/tests/test_ContextInformation_Subscription.py @@ -189,6 +189,20 @@ class TestCISubscription(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_046_16(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_16.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/046_16.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_046_16.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_046_17(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_17.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/046_17.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_046_17.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'