diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_01.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_01.robot new file mode 100644 index 0000000000000000000000000000000000000000..80b336d476637aef0e0266001b45f004b4c58519 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_01.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Check that if the created context source registration subscription defines a timeInterval member, a cSourceNotification will be sent periodically, initially on subscription and when the time interval is reached +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registrations +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-timeInterval-sample.jsonld + +*** Test Case *** +Receive cSourceNotification Periodically And Initially On Subscription + [Documentation] Check that if the created context source registration subscription defines a timeInterval member, a cSourceNotification will be sent periodically, initially on subscription and when the time interval is reached + [Tags] mandatory + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + Set Suite Variable ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Wait for notification + # Wait for 15 seconds to check if another notification was sent + Wait for notification timeout=${15} + +*** Keywords *** +Setup Initial Context Source Registrations + Start Local Server + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${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 Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_02.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_02.robot new file mode 100644 index 0000000000000000000000000000000000000000..4846a9f554003ea08acb650943449193cadeae0c --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_02.robot @@ -0,0 +1,52 @@ +*** Settings *** +Documentation Check that if the created context source registration subscription doesn't define a timeInterval member, a cSourceNotification, with the appropriate trigger reason in the "triggerReason" member, will be sent initially on subscription and whenever there is a change of a matching Context Source Registration +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registrations +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld +${update_fragment_file_path}= csourceRegistrations/fragments/context-source-registration-update-sample.json + +*** Test Case *** +Receive cSourceNotification Initially On Subscription And Whenever There Is A Change Of A Matching Context Source Registration + [Documentation] Check that if the created context source registration subscription doesn't define a timeInterval member, a cSourceNotification, with the appropriate trigger reason in the "triggerReason" member, will be sent initially on subscription and whenever there is a change of a matching Context Source Registration + [Tags] mandatory + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + Set Suite Variable ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + + ${update_fragment}= Load Test Sample ${update_fragment_file_path} + Update Context Source Registration ${context_source_registration_id} ${update_fragment} + + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} updated + +*** Keywords *** +Setup Initial Context Source Registrations + Start Local Server + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${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 Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_03.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_03.robot new file mode 100644 index 0000000000000000000000000000000000000000..7ad2693f419970643a7e5286965919766b732cd4 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_03.robot @@ -0,0 +1,48 @@ +*** Settings *** +Documentation Check that instead of providing the original context source registration, implementations should return context source registration information relevant for the subscription, in particular only matching RegistrationInfo elements +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-building-and-bus-entities-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld + +*** Test Case *** +Receive cSourceNotification With Relevant Information + [Documentation] Check that instead of providing the original context source registration, implementations should return context source registration information relevant for the subscription, in particular only matching RegistrationInfo elements + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + @{expected_notification_data_entities}= Create List Building + + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching ${expected_notification_data_entities} + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_04.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_04.robot new file mode 100644 index 0000000000000000000000000000000000000000..aac6a6c386d0a31cb69913016afe84fbbdd4eab4 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_04.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation The structure of the csource notification message shall be as mandated by clause 5.3.2 +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld + +*** Test Case *** +Receive cSourceNotification With Compliant Structure + [Documentation] The structure of the csource notification message shall be as mandated by clause 5.3.2 + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_05.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_05.robot new file mode 100644 index 0000000000000000000000000000000000000000..f562b6132a6a253839e9415c6957fde3d22b216c --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_05.robot @@ -0,0 +1,49 @@ +*** Settings *** +Documentation Check that if a cSourceNotification is sent successfully to the "endpoint" member, the "notification.timesSent" member shall be incremented by one and the "notification.lastSuccess" and "notification.lastNotification" members shall be updated with the current timestamp and the status of the context source registration subscription shall be updated to "ok" +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld +${notification_expectation_file_path}= notifications/expectations/1-timesSent-ok.json + +*** Test Case *** +If A cSourceNotification Is Successfully Sent The Notification Member Shall Be Updated + [Documentation] Check that if a cSourceNotification is sent successfully to the "endpoint" member, the "notification.timesSent" member shall be incremented by one and the "notification.lastSuccess" and "notification.lastNotification" members shall be updated with the current timestamp and the status of the context source registration subscription shall be updated to "ok" + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + Wait for notification + + Retrieve Context Source Registration Subscription ${subscription_id} + @{expected_notification_additional_members}= Create List lastNotification lastSuccess + Check NotificationParams ${notification_expectation_file_path} ${expected_notification_additional_members} + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_06.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_06.robot new file mode 100644 index 0000000000000000000000000000000000000000..187bde8471378138907adbcdaf06b89b1685fc18 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_06.robot @@ -0,0 +1,48 @@ +*** Settings *** +Documentation Check that if a cSourceNotification is not sent successfully, the "notification.timesSent" member shall be incremented by one and the notification.lastFailure" and "notification.lastNotification" members shall be updated with the current timestamp and the status of the context source registration subscription shall be updated to "failed" +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-unreachable-endpoint-sample.jsonld +${notification_expectation_file_path}= notifications/expectations/0-timesSent-failed.json + +*** Test Case *** +If A cSourceNotification Is Not Successfully Sent The Notification Member Shall Be Updated + [Documentation] Check that if a cSourceNotification is not sent successfully, the "notification.timesSent" member shall be incremented by one and the notification.lastFailure" and "notification.lastNotification" members shall be updated with the current timestamp and the status of the context source registration subscription shall be updated to "failed" + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + Wait for no notification + Retrieve Context Source Registration Subscription ${subscription_id} + @{expected_notification_additional_members}= Create List lastNotification lastFailure + Check NotificationParams ${notification_expectation_file_path} ${expected_notification_additional_members} + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_07.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_07.robot new file mode 100644 index 0000000000000000000000000000000000000000..09c9173719a3ac82a784e9e4156e49e3a6a9a178 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_07.robot @@ -0,0 +1,53 @@ +*** Settings *** +Documentation Check that a cSourceNotification shall only be sent if and only if the status of the corresponding subscription is active not paused nor expired +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Test Template Do Not Receive cSourceNotification If Subscription Status Is Not Active +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld + +*** Test Cases *** FILEPATH +PausedSubscription csourceSubscriptions/fragments/subscription-isActive-update-sample.json +ExpiredSubscription csourceSubscriptions/fragments/subscription-expiresAt-update-sample.json + +*** Keywords *** +Do Not Receive cSourceNotification If Subscription Status Is Not Active + [Arguments] ${filepath} + [Documentation] Check that a cSourceNotification shall only be sent if and only if the status of the corresponding subscription is active not paused nor expired + [Tags] mandatory + + ${subscription_update_fragment}= Load Test Sample ${filepath} + Update Context Source Registration Subscription ${subscription_id} ${subscription_update_fragment} + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + Wait for no notification + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_08.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_08.robot new file mode 100644 index 0000000000000000000000000000000000000000..800f0a9f6e9cd069b760419043409418de40683f --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_08.robot @@ -0,0 +1,48 @@ +*** Settings *** +Documentation Check if a context source registration subscription does not define a temporalQ member, a CsourceNotification will be triggered from matching context source registrations for context sources providing latest information +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registrations And Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld +${update_fragment_file_path}= csourceRegistrations/fragments/context-source-registration-update-sample.json + +*** Test Case *** +Receive cSourceNotification For Matching Context Source Registrations Providing Latest Information + [Documentation] Check if a context source registration subscription does not define a temporalQ member, a CsourceNotification will be triggered from matching context source registrations for context sources providing latest information + [Tags] mandatory + + ${update_fragment}= Load Test Sample ${update_fragment_file_path} + Update Context Source Registration ${context_source_registration_id} ${update_fragment} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} updated + +*** Keywords *** +Setup Initial Context Source Registrations And Subscriptions + Start Local Server + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration ${context_source_registration_payload} + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${context_source_registration_id} + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_09.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_09.robot new file mode 100644 index 0000000000000000000000000000000000000000..bd0794afe2798e5e70da8fd2e45e55ee27a95d8f --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_09.robot @@ -0,0 +1,48 @@ +*** Settings *** +Documentation Check if a context source registration subscription defines an entities member, a CsourceNotification will be triggered from context source registrations with information member matching the described entities +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registrations And Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld +${update_fragment_file_path}= csourceRegistrations/fragments/context-source-registration-update-information-sample.json + +*** Test Case *** +Receive cSourceNotification For No Longer Matching Context Source Registrations Providing Latest Information + [Documentation] Check if a context source registration subscription defines an entities member, a CsourceNotification will be triggered from context source registrations with information member matching the described entities + [Tags] mandatory + + ${update_fragment}= Load Test Sample ${update_fragment_file_path} + Update Context Source Registration ${context_source_registration_id} ${update_fragment} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} noLongerMatching + +*** Keywords *** +Setup Initial Context Source Registrations And Subscriptions + Start Local Server + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration ${context_source_registration_payload} + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${context_source_registration_id} + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_10.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_10.robot new file mode 100644 index 0000000000000000000000000000000000000000..37f11385c65fe97b873676e13a5918a7c533a405 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_10.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Check if a context source registration subscription defines temporalQ member with timeproperty observedAt, the temporal query is matched against the observationInterval of matching context source registrations +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-observationInterval-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-temporalQ-observedAt-sample.jsonld + +*** Test Case *** +Receive cSourceNotification For Matching Context Source Registrations On Observation Interval + [Documentation] Check if a context source registration subscription defines temporalQ member with timeproperty observedAt, the temporal query is matched against the observationInterval of matching context source registrations + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_11.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_11.robot new file mode 100644 index 0000000000000000000000000000000000000000..81487f69600c1e191c09bec02374f691fef316ba --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_11.robot @@ -0,0 +1,48 @@ +*** Settings *** +Documentation Check if a context source registration subscription defines temporalQ member with timeproperty createdAt or modifiedAt, the temporal query is matched against the managementInterval of matching context source registrations +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Test Template Receive cSourceNotification For Matching Context Source Registrations On Management Interval +Suite Setup Start Local Server +Suite Teardown Delete Created Context Source Registrations + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-managementInterval-sample.jsonld + +*** Test Cases *** FILEPATH +CreatedAt csourceSubscriptions/subscription-temporalQ-createdAt-sample.jsonld +ModifiedAt csourceSubscriptions/subscription-temporalQ-modifiedAt-sample.jsonld + +*** Keywords *** +Receive cSourceNotification For Matching Context Source Registrations On Management Interval + [Arguments] ${filepath} + [Documentation] Check if a context source registration subscription defines temporalQ member with timeproperty createdAt or modifiedAt, the temporal query is matched against the managementInterval of matching context source registrations + [Tags] mandatory + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${filepath} ${subscription_id} + Create Context Source Registration Subscription ${subscription_payload} + Set Suite Variable ${subscription_id} + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + + # Moved here since each test case creates a subscription + [Teardown] Delete Context Source Registration Subscription ${subscription_id} + +Delete Created Context Source Registrations + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_12.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_12.robot new file mode 100644 index 0000000000000000000000000000000000000000..5c63941f7dbb117cb711a43dc9f57b8f31e1d28e --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_12.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Check if a context source registrations subscription defines entities member and watchedAttributes member, a CsourceNotification will be triggered from context source registrations with information member matching the described entities and attributes +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-detailed-information-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-watchedAttributes-sample.jsonld + +*** Test Case *** +Receive cSourceNotification For Matching Context Source Registrations On Watched Attributes + [Documentation] Check if a context source registrations subscription defines entities member and watchedAttributes member, a CsourceNotification will be triggered from context source registrations with information member matching the described entities and attributes + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_13.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_13.robot new file mode 100644 index 0000000000000000000000000000000000000000..3da7df0c47f0f8e76bd01bfe28ae0547dc9b6d6e --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_13.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Check if a context source registrations subscription does not define watchedAttributes member, a CsourceNotification will be triggered from context source registrations with information member matching all attributes of the described entities +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-detailed-information-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld + +*** Test Case *** +Receive cSourceNotification For Matching Context Source Registrations On Any watchedAttribute + [Documentation] Check if a context source registrations subscription does not define watchedAttributes member, a CsourceNotification will be triggered from context source registrations with information member matching all attributes of the described entities + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_14.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_14.robot new file mode 100644 index 0000000000000000000000000000000000000000..e269b57dbb77217010486148a6c314acda8f390f --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_14.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Check if a context source registrations subscription defines a geoQ member, a CsourceNotification will be triggered from matching context source registrations with a matching location member +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-location-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-geoQ-sample.jsonld + +*** Test Case *** +Receive cSourceNotification For Matching Context Source Registrations On Location + [Documentation] Check if a context source registrations subscription defines a geoQ member, a CsourceNotification will be triggered from matching context source registrations with a matching location member + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_15.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_15.robot new file mode 100644 index 0000000000000000000000000000000000000000..9527579f32d3caea8c7b5a9d14fc9a5d386543a3 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_15.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Check if a context source registrations subscription does not define a geoproperty in the geoQ member, a CsourceNotification will be triggered from matching context source registrations with a matching location member +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Setup Initial Context Source Registration Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-location-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-geoQ-without-geoproperty-sample.jsonld + +*** Test Case *** +Receive cSourceNotification For Matching Context Source Registrations On Location As Default + [Documentation] Check if a context source registrations subscription does not define a geoproperty in the geoQ member, a CsourceNotification will be triggered from matching context source registrations with a matching location member + [Tags] mandatory + + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + Set Suite Variable ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + @{expected_context_source_registration_ids}= Create List ${context_source_registration_id} + Wait for notification and validate it ${subscription_id} ${expected_context_source_registration_ids} newlyMatching + +*** Keywords *** +Setup Initial Context Source Registration Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + + Create Context Source Registration Subscription ${subscription_payload} + + Set Suite Variable ${subscription_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration ${context_source_registration_id} + Delete Context Source Registration Subscription ${subscription_id} diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_16.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_16.robot new file mode 100644 index 0000000000000000000000000000000000000000..8c5b3f151e6745e152aafa46154f7af8aa9f6f9c --- /dev/null +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/NotificationBehaviour/037_16.robot @@ -0,0 +1,59 @@ +*** Settings *** +Documentation Check if you update a context source registration subscription, a CsourceNotification will be sent with all currently matching context source registrations +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Test Template Receive cSourceNotification For Newly Matching Context Source Registrations +Suite Setup Setup Initial Context Source Registrations And Subscriptions +Suite Teardown Delete Created Context Source Registrations And Subscriptions + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${first_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-vehicle-entities-sample.jsonld +${second_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-bus-entities-sample.jsonld +${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld + +*** Test Cases *** FILEPATH NOTIFICATION_CSR_IDS +MatchFirstContextSourceRegistration csourceSubscriptions/fragments/subscription-vehicle-entities-sample.json ${first_context_source_registration_id} +MatchSecondContextSourceRegistration csourceSubscriptions/fragments/subscription-bus-entities-sample.json ${second_context_source_registration_id} +MatchBothContextSourceRegistrations csourceSubscriptions/fragments/subscription-vehicle-and-bus-entities-sample.json ${first_context_source_registration_id} ${second_context_source_registration_id} + +*** Keywords *** +Receive cSourceNotification For Newly Matching Context Source Registrations + [Arguments] ${filepath} @{notification_csr_ids} + [Documentation] Check if you update a context source registration subscription, a CsourceNotification will be sent with all currently matching context source registrations + [Tags] mandatory + + ${subscription_update_fragment}= Load Test Sample ${filepath} + Update Context Source Registration Subscription ${subscription_id} ${subscription_update_fragment} + + Wait for notification and validate it ${subscription_id} ${notification_csr_ids} newlyMatching + +Setup Initial Context Source Registrations And Subscriptions + Start Local Server + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${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} + + ${subscription_payload}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + ${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} + + Create Context Source Registration Subscription ${subscription_payload} + Create Context Source Registration ${first_context_source_registration_payload} + Create Context Source Registration ${second_context_source_registration_payload} + + Set Suite Variable ${subscription_id} + Set Suite Variable ${first_context_source_registration_id} + Set Suite Variable ${second_context_source_registration_id} + +Delete Created Context Source Registrations And Subscriptions + Stop Local Server + + Delete Context Source Registration Subscription ${subscription_id} + Delete Context Source Registration ${first_context_source_registration_id} + Delete Context Source Registration ${second_context_source_registration_id} diff --git a/data/csourceRegistrations/context-source-registration-building-and-bus-entities-sample.jsonld b/data/csourceRegistrations/context-source-registration-building-and-bus-entities-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..ce7e8b3a44c4539962811a4904474003efe39c40 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-building-and-bus-entities-sample.jsonld @@ -0,0 +1,25 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + }, + { + "entities":[ + { + "type":"Bus" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-bus-entities-sample.jsonld b/data/csourceRegistrations/context-source-registration-bus-entities-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..fccc6705676086664f38de9aca7b0d3cbcddd3e6 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-bus-entities-sample.jsonld @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Bus" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-detailed-information-sample.jsonld b/data/csourceRegistrations/context-source-registration-detailed-information-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..90753052a664971ad5e9c75a8c0569755e4c31ab --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-detailed-information-sample.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ], + "propertyNames":["name", "subCategory"], + "relationshipNames":["locatedAt"] + } + ], + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-location-sample.jsonld b/data/csourceRegistrations/context-source-registration-location-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..3d4599eca037397b5a4ab38d3d9f870c5d9eb156 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-location-sample.jsonld @@ -0,0 +1,25 @@ +{ + "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", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-managementInterval-sample.jsonld b/data/csourceRegistrations/context-source-registration-managementInterval-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..a3785ed20c4319a265581e3ec4bb8f972b738942 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-managementInterval-sample.jsonld @@ -0,0 +1,22 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "managementInterval":{ + "startAt":"2020-08-01T22:07:00Z", + "endAt":"2021-08-01T21:07:00Z" + }, + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-observationInterval-sample.jsonld b/data/csourceRegistrations/context-source-registration-observationInterval-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..e08c3fbece2d7892e76be377e3c47558135683a3 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-observationInterval-sample.jsonld @@ -0,0 +1,22 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "observationInterval":{ + "startAt":"2020-08-01T22:07:00Z", + "endAt":"2021-08-01T21:07:00Z" + }, + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-sample.jsonld b/data/csourceRegistrations/context-source-registration-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..aee825684220d4bff509f4daf09a82f3ad73833d --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-sample.jsonld @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-vehicle-entities-sample.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-entities-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..177d2319c1fcd17498114c4a4d9e47d5f4eb5697 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-entities-sample.jsonld @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Vehicle" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026", + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/fragments/context-source-registration-update-information-sample.json b/data/csourceRegistrations/fragments/context-source-registration-update-information-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..5d6df96b98bf152d7226af568df810fb0036a46c --- /dev/null +++ b/data/csourceRegistrations/fragments/context-source-registration-update-information-sample.json @@ -0,0 +1,11 @@ +{ + "information":[ + { + "entities":[ + { + "type":"NewType" + } + ] + } + ] +} \ No newline at end of file diff --git a/data/csourceRegistrations/fragments/context-source-registration-update-sample.json b/data/csourceRegistrations/fragments/context-source-registration-update-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..133cc317c86912ac0e848648b14ca74175e64bf4 --- /dev/null +++ b/data/csourceRegistrations/fragments/context-source-registration-update-sample.json @@ -0,0 +1,3 @@ +{ + "endpoint":"http://my.new.csource.org:1026" +} \ No newline at end of file diff --git a/data/csourceSubscriptions/fragments/subscription-bus-entities-sample.json b/data/csourceSubscriptions/fragments/subscription-bus-entities-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..97bb80eed5a0a30644f69249e4bfe51ec7e36bc9 --- /dev/null +++ b/data/csourceSubscriptions/fragments/subscription-bus-entities-sample.json @@ -0,0 +1,7 @@ +{ + "entities":[ + { + "type":"Bus" + } + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/fragments/subscription-expiresAt-update-sample.json b/data/csourceSubscriptions/fragments/subscription-expiresAt-update-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..237d218065b6eea14c6b1c5117eb3baee3bcaf1d --- /dev/null +++ b/data/csourceSubscriptions/fragments/subscription-expiresAt-update-sample.json @@ -0,0 +1,3 @@ +{ + "expiresAt": "2020-08-01T22:07:00Z" +} \ No newline at end of file diff --git a/data/csourceSubscriptions/fragments/subscription-isActive-update-sample.json b/data/csourceSubscriptions/fragments/subscription-isActive-update-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..b432cbaef9391ee3b78deea727e71149c635b5f1 --- /dev/null +++ b/data/csourceSubscriptions/fragments/subscription-isActive-update-sample.json @@ -0,0 +1,3 @@ +{ + "isActive": false +} \ No newline at end of file diff --git a/data/csourceSubscriptions/fragments/subscription-vehicle-and-bus-entities-sample.json b/data/csourceSubscriptions/fragments/subscription-vehicle-and-bus-entities-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..6040ffb660d4d851c4e992b49c82c9cb8048f855 --- /dev/null +++ b/data/csourceSubscriptions/fragments/subscription-vehicle-and-bus-entities-sample.json @@ -0,0 +1,10 @@ +{ + "entities":[ + { + "type":"Vehicle" + }, + { + "type":"Bus" + } + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/fragments/subscription-vehicle-entities-sample.json b/data/csourceSubscriptions/fragments/subscription-vehicle-entities-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..ff01dca79e195f50eb1efc707d46582403216d29 --- /dev/null +++ b/data/csourceSubscriptions/fragments/subscription-vehicle-entities-sample.json @@ -0,0 +1,7 @@ +{ + "entities":[ + { + "type":"Vehicle" + } + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-geoQ-sample.jsonld b/data/csourceSubscriptions/subscription-geoQ-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..3dd0bc74e5c6845cb1a3a423b31e757d9ec054fc --- /dev/null +++ b/data/csourceSubscriptions/subscription-geoQ-sample.jsonld @@ -0,0 +1,26 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "geoQ":{ + "georel":"near;maxDistance==2000", + "geometry":"Point", + "coordinates":[-8.52,41.2], + "geoproperty": "location" + }, + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-geoQ-without-geoproperty-sample.jsonld b/data/csourceSubscriptions/subscription-geoQ-without-geoproperty-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..0e664bd62669ebaacf645e05e451a3627e0d666e --- /dev/null +++ b/data/csourceSubscriptions/subscription-geoQ-without-geoproperty-sample.jsonld @@ -0,0 +1,25 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "geoQ":{ + "georel":"near;maxDistance==2000", + "geometry":"Point", + "coordinates":[-8.52,41.2] + }, + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-temporalQ-createdAt-sample.jsonld b/data/csourceSubscriptions/subscription-temporalQ-createdAt-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..7265fc1d175dc763275cbb4a42adbea8ec8658fb --- /dev/null +++ b/data/csourceSubscriptions/subscription-temporalQ-createdAt-sample.jsonld @@ -0,0 +1,25 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "temporalQ": { + "timerel": "after", + "timeAt": "2020-06-01T22:07:00Z", + "timeproperty": "createdAt" + }, + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-temporalQ-modifiedAt-sample.jsonld b/data/csourceSubscriptions/subscription-temporalQ-modifiedAt-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..ef21a2b161bac1798c4c9f083d451d01fe60b4a2 --- /dev/null +++ b/data/csourceSubscriptions/subscription-temporalQ-modifiedAt-sample.jsonld @@ -0,0 +1,25 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "temporalQ": { + "timerel": "after", + "timeAt": "2020-06-01T22:07:00Z", + "timeproperty": "modifiedAt" + }, + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-temporalQ-observedAt-sample.jsonld b/data/csourceSubscriptions/subscription-temporalQ-observedAt-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..87a23d6f45ea0226507a6beefd1bc827ab9a66d3 --- /dev/null +++ b/data/csourceSubscriptions/subscription-temporalQ-observedAt-sample.jsonld @@ -0,0 +1,25 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "temporalQ": { + "timerel": "after", + "timeAt": "2020-06-01T22:07:00Z", + "timeproperty": "observedAt" + }, + "@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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-timeInterval-sample.jsonld b/data/csourceSubscriptions/subscription-timeInterval-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..1e5eff514fad584119f6bc4d0bed1de0db0465a0 --- /dev/null +++ b/data/csourceSubscriptions/subscription-timeInterval-sample.jsonld @@ -0,0 +1,21 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "timeInterval": 10, + "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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-unreachable-endpoint-sample.jsonld b/data/csourceSubscriptions/subscription-unreachable-endpoint-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..aac999b6202388b8902fbdf98ed398cb5ebccd43 --- /dev/null +++ b/data/csourceSubscriptions/subscription-unreachable-endpoint-sample.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://unreachable.endpoint/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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/csourceSubscriptions/subscription-watchedAttributes-sample.jsonld b/data/csourceSubscriptions/subscription-watchedAttributes-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..1bca07696a7c3e94d832032365b322284747cd39 --- /dev/null +++ b/data/csourceSubscriptions/subscription-watchedAttributes-sample.jsonld @@ -0,0 +1,21 @@ +{ + "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", + "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" + ] +} \ No newline at end of file diff --git a/data/notifications/expectations/1-timesSent-failed.json b/data/notifications/expectations/1-timesSent-failed.json new file mode 100644 index 0000000000000000000000000000000000000000..27b2d40f6ff4dcd854ea8b8556b0dfd558cd9415 --- /dev/null +++ b/data/notifications/expectations/1-timesSent-failed.json @@ -0,0 +1,9 @@ +{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + }, + "status":"failed", + "timesSent":1 +} \ No newline at end of file diff --git a/data/notifications/expectations/1-timesSent-ok.json b/data/notifications/expectations/1-timesSent-ok.json new file mode 100644 index 0000000000000000000000000000000000000000..2e61a8ba00a42c65d3f9eb0c9b69aeaa1b9b5428 --- /dev/null +++ b/data/notifications/expectations/1-timesSent-ok.json @@ -0,0 +1,9 @@ +{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + }, + "status":"ok", + "timesSent":1 +} \ No newline at end of file diff --git a/libraries/dateTimeUtils.py b/libraries/dateTimeUtils.py new file mode 100644 index 0000000000000000000000000000000000000000..d22264c89a02166260c23779a3179e98e6b95f07 --- /dev/null +++ b/libraries/dateTimeUtils.py @@ -0,0 +1,13 @@ +import datetime + + +def is_date(date, format): + """Function exposed as a keyword to check whether the string can be interpreted as a date of given format + :param date: string to check for date + :param format: date format + """ + try: + datetime.datetime.strptime(date, format) + return True + except ValueError: + return False diff --git a/requirements.txt b/requirements.txt index a0b255562ebcf4edeccb0e3d8a9c41b872276682..c62307cedd643faa74c332f653167ee50db2ff0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ robotframework-jsonschemalibrary==1.0 robotframework-jsonlibrary==0.3.1 robotframework-requests==0.8.0 deepdiff==5.2.1 +robotframework-httpctrl==0.1.6 diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 0c4ec21f750aaf49ac1a3bae5e9829ae158ab81d..9d069ef58cdb3b1d6ac734d56de608469f4c1f3f 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -336,6 +336,35 @@ Delete Temporal Representation Of Entity Output request Output response +Create Context Source Registration + [Arguments] ${context_source_registration_payload} + + &{headers}= Create Dictionary Content-Type=application/ld+json + ${response}= POST ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH} body=${context_source_registration_payload} headers=${headers} + ${request}= Output request + Output response + + Set Suite Variable ${request} + Set Suite Variable ${response} + +Update Context Source Registration + [Arguments] ${context_source_registration_id} ${update_fragment} + + ${response}= PATCH ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}/${context_source_registration_id} body=${update_fragment} + Output request + Output response + + Set Test Variable ${response} + +Delete Context Source Registration + [Arguments] ${context_source_registration_id} + + ${response}= DELETE ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}/${context_source_registration_id} + Output request + Output response + + Set Suite Variable ${response} + Create Context Source Registration Subscription [Arguments] ${subscription_payload} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 6236f3f1f6079d135567695973f72b1598d6bfd9..89ca3ddba61ba5219f27e8bc5b6bbd74ed3fbb62 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -3,6 +3,7 @@ Library ${EXECDIR}/libraries/assertionUtils.py *** Variable *** ${instance_id_regex_expr}= root\\[.*\\]\\['instanceId'\\] +${notification_timestamps_regex_expr}= root\\['last.*'\\] *** Keywords *** Check Response Status Code @@ -156,4 +157,15 @@ Should Be Present In Json List Check Result Contains [Arguments] ${source} ${parameter} ${value} - Should Be Present In Json List ${source} ${parameter} ${value} \ No newline at end of file + Should Be Present In Json List ${source} ${parameter} ${value} + +Check NotificationParams + [Arguments] ${filename} ${expected_additional_members} + + ${expected_notification}= Load Json From File ${EXECDIR}/data/${filename} + ${comparaison_result}= Compare Dictionaries Ignoring Keys ${response['body']['notification']} ${expected_notification} ${notification_timestamps_regex_expr} + Should Be True ${comparaison_result} msg=NotificationParams Comparaison Failed + + FOR ${expected_additional_member} IN @{expected_additional_members} + Should Not Be Empty ${response['body']['notification']['${expected_additional_member}']} + END diff --git a/resources/NotificationUtils.resource b/resources/NotificationUtils.resource new file mode 100644 index 0000000000000000000000000000000000000000..e9749abb87d6fc628d87752e3c5f11d128eadf07 --- /dev/null +++ b/resources/NotificationUtils.resource @@ -0,0 +1,79 @@ +*** Settings *** +Documentation Check Notification Behaviour +Library BuiltIn +Library Collections +Library HttpCtrl.Server +Library ${EXECDIR}/libraries/assertionUtils.py +Library ${EXECDIR}/libraries/dateTimeUtils.py + +*** Variable *** +${notification_type}= ContextSource Notfication +${date_format}= %Y-%m-%dT%H:%M:%SZ + +*** Keywords *** +Start Local Server + #Initialize HTTP Client And Server + Start Server ${notification_server_host} ${notification_server_port} + +Wait for notification + [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 + +Wait for notification and validate it + [Arguments] ${expected_subscription_id} ${expected_context_source_registration_ids} ${expected_trigger_reason} ${expected_notification_data_entities}=${EMPTY} ${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 + + ${notification_payload}= Get Request Body + ${notification} Evaluate json.loads('''${notification_payload}''') json + ${notification_data_length}= Get length ${notification}[data] + ${expected_notification_data_entities_length}= Get length ${expected_notification_data_entities} + ${expected_notification_data_length}= Get length ${expected_context_source_registration_ids} + + log ${notification} + Should Be Equal ${notification}[type] ${notification_type} + Should Be Equal ${notification}[subscriptionId] ${expected_subscription_id} + ${is_date}= Is Date ${notification}[notifiedAt] ${date_format} + Should Be True ${is_date} + ${index}= Set Variable 0 + FOR ${expected_context_source_registration_id} IN @{expected_context_source_registration_ids} + List Should Contain Value ${expected_context_source_registration_ids} ${notification}[data][${index}][@id] + ${index}= Evaluate ${index} + 1 + END + Should Be Equal '${notification_data_length}' '${expected_notification_data_length}' + Should Be Equal ${notification}[triggerReason] ${expected_trigger_reason} + + # TODO Currently we check entities information of the first CSR returned in the notification, find a way to check them all + Run Keyword If ${expected_notification_data_entities_length}>0 Check Notification Data Entities ${notification}[data][0][information] ${expected_notification_data_entities} + +Wait for no notification + [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 No Request ${timeout} + +Check Notification Data Entities + [Arguments] ${notification_data_information} ${expected_notification_data_entities} + + ${notification_data_entities}= Create List + ${index}= Set Variable 0 + FOR ${registration_information} IN @{notification_data_information} + Append To List ${notification_data_entities} ${registration_information}[entities][0][type][0] + END + + Lists Should Be Equal ${expected_notification_data_entities} ${notification_data_entities} ignore_order=True + +Stop Local Server + #Terminate HTTP Server + Stop Server diff --git a/resources/variables.py b/resources/variables.py index 3b9e617a6e6abcb6815f18384ad0ee3fc278f344..8cbd37d43375ca0399ee3694d8d352f68ef02d65 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,7 +1,9 @@ def get_variables(arg=None): variables = { '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' + '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 } return variables \ No newline at end of file