Commit 41324cae authored by Arnaud Van der Poorten's avatar Arnaud Van der Poorten
Browse files

046_11 and 046_12

parent 3ed7fbe4
Loading
Loading
Loading
Loading
+41 −29
Original line number Diff line number Diff line
*** Settings ***
Documentation     The Notification content shall be JSON by default
Documentation     A Notification shall be sent (as mandated by each concrete binding and including any optional endpoint.info defined by clause 5.2.22) to the endpoint specified by the endpoint.uri member of the notification structure defined by clause 5.2.14


Resource          ${EXECDIR}/resources/ApiUtils.resource
@@ -7,47 +7,59 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Resource          ${EXECDIR}/resources/NotificationUtils.resource

Suite Setup       Setup Initial Subscriptions
Suite Teardown    Delete Initial Subscriptions
Suite Setup    Before Test
Suite Teardown    After Test

*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=    subscriptions/subscription-building-entities-active.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:
${entity_building_filepath}=    building-no-attributes.jsonld
${fragment_filename}=    airQualityLevel-fragment.jsonld
${notification_server_send_url}=     http://${send_notification_server_host}:${send_notification_server_port}/notify
${date_format}=  %Y-%m-%dT%H:%M:%SZ
${date_format_with_millis}=  %Y-%m-%dT%H:%M:%S.%fZ

*** Keywords ***
Setup Initial Subscriptions
    ${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}
    ${subscription_payload}=    Set Entity Id In Subscription    ${subscription_payload}    ${entity_id}
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Set Suite Variable    ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription    ${subscription_id}

Before Test
    NotificationUtils.Start Local Server    ${notification_server_host}    ${notification_server_port}

After Test
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server

*** Keywords ***
Check that a notification is only sent if statis is active
    [Arguments]      ${fragment_filename}    
    [Documentation]     The Notification content shall be JSON by default
    [Tags]    sub-notification    5_11_7
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint   ${subscription_payload_file_path}    ${subscription_id}
Add Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix} 
    Create Entity    ${entity_building_filepath}    ${entity_id}
    Set Suite Variable    ${entity_id}

    @{expected_notification_data_entities}=    Create List    Building
    Set Suite Variable    ${subscription_id}
    Create Subscription  ${subscription_id}  ${subscription_payload}  
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
Delete Initial Entity
    Delete Entity by Id    ${entity_id}

    Wait for redirected request
*** Test Cases ***
Check that TimesSent is increased by one
    [Documentation]     The notification.timesSent member shall be incremented by one.
    [Tags]    sub-notification    5_11_7    046_11

    @{expected_notification_additional_members}=    Create List    lastNotification    lastSuccess
    Check JSON Value In Response Body  json_path_expr  value_to_check    ${notification_expectation_file_path}    ${expected_notification_additional_members}
    Add Initial Entity
    Setup Initial Subscriptions

    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}

*** Keywords ***
Setup Initial Subscription
    Start Local Server
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Test Sample    ${subscription_payload_file_path}    ${subscription_id}
    Create Subscription  ${subscription_id}  ${subscription_payload}  
    Set Suite Variable    ${subscription_id}
    ${notification}=    Wait for notification    timeout=${10}
    
Delete Subscription
    Stop Local Server
    Delete Subscription      ${subscription_id}
    Dictionary Should Contain Key    ${notification}    timesSent
    Should be True    '${notification}[timesSent]    1

+43 −29
Original line number Diff line number Diff line
*** Settings ***
Documentation     The notification.lastNotification member shall be updated with a timestamp representing the current date and time. This test will check the format.
Documentation     A Notification shall be sent (as mandated by each concrete binding and including any optional endpoint.info defined by clause 5.2.22) to the endpoint specified by the endpoint.uri member of the notification structure defined by clause 5.2.14


Resource          ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Resource          ${EXECDIR}/resources/NotificationUtils.resource

Suite Setup       Setup Initial Subscriptions
Suite Teardown    Delete Initial Subscriptions
Suite Setup    Before Test
Suite Teardown    After Test

*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=    subscriptions/subscription-building-entities-active.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:
${entity_building_filepath}=    building-no-attributes.jsonld
${fragment_filename}=    airQualityLevel-fragment.jsonld
${notification_server_send_url}=     http://${send_notification_server_host}:${send_notification_server_port}/notify

*** Keywords ***
Setup Initial Subscriptions
    ${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}
    ${subscription_payload}=    Set Entity Id In Subscription    ${subscription_payload}    ${entity_id}
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Set Suite Variable    ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription    ${subscription_id}

Before Test
    NotificationUtils.Start Local Server    ${notification_server_host}    ${notification_server_port}

After Test
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server

*** Keywords ***
Check that a notification is only sent if statis is active
    [Arguments]      ${fragment_filename}    
    [Documentation]     The notification.lastNotification member shall be updated with a timestamp representing the current date and time. This test will check the format.
    [Tags]    sub-notification    5_11_7
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint   ${subscription_payload_file_path}    ${subscription_id}
Add Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix} 
    Create Entity    ${entity_building_filepath}    ${entity_id}
    Set Suite Variable    ${entity_id}

    @{expected_notification_data_entities}=    Create List    Building
    Set Suite Variable    ${subscription_id}
    Create Subscription  ${subscription_id}  ${subscription_payload}  
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
Delete Initial Entity
    Delete Entity by Id    ${entity_id}

    Wait for redirected request
*** Test Cases ***
Check that lastNotification is updated
    [Documentation]     The notification.lastNotification member shall be updated with a timestamp representing the current date and time. This test will check the format. 
    [Tags]    sub-notification    5_11_7    046_12

    Add Initial Entity
    Setup Initial Subscriptions

    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}

    Check Notification Date  ${subscription_id}      
    ${notification}=    Wait for notification    timeout=${10}
    
*** Keywords ***
Setup Initial Subscription
    Start Local Server
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Test Sample    ${subscription_payload_file_path}    ${subscription_id}
    Create Subscription  ${subscription_id}  ${subscription_payload}  
    Set Suite Variable    ${subscription_id}
    Dictionary Should Contain Key    ${notification}    lastNotification

Delete Subscription
    Stop Local Server
    Delete Subscription      ${subscription_id}
    ${is_date}=    Is Date    ${notification}[lastNotification]    ${date_format}
    ${is_date_with_millis}=    Is Date    ${notification}[lastNotification]    ${date_format_with_millis}
    Should Be True    ${is_date} or ${is_date_with_millis}