Commit 70e9de46 authored by Arnaud Van der Poorten's avatar Arnaud Van der Poorten
Browse files

046_03

parent 1358dcc8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ Check that a notification is send on the timeinterval
    [Tags]    sub-notification    5_11_7
    
    Add Initial Entity
    Sleep    2
    Setup Initial Subscriptions

    ${notification}=    Wait for notification  timeout=${15}
+37 −14
Original line number Diff line number Diff line
@@ -4,34 +4,57 @@ 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-timeInterval-sample.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:
${expected_notification_data_entities}=    TODO

*** Test Case ***
Check that a notification is sent with all entities
    [Documentation]     A notification with all all subscribed Entities will be included if query or geoquery are not defined.
    [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}
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${subscription_id}
    Wait for subscription notification and validate it  ${subscription_id}  ${expected_notification_data_entities}  timeout=${5}
${notification_server_send_url}=     http://${send_notification_server_host}:${send_notification_server_port}/notify
${entity_building_filepath}=    building-simple-attributes-sample.jsonld

*** Keywords ***
Setup Initial Subscriptions
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    Create Subscription    ${subscription_id}    ${subscription_payload_file_path}    ${CONTENT_TYPE_LD_JSON}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint    ${subscription_payload_file_path}    ${subscription_id}    ${notification_server_send_url}
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Set Suite Variable    ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription    ${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}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}

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

After Test
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server

*** Test Case ***
Check that a notification is sent with all entities
    [Documentation]     A notification with all all subscribed Entities will be included if query or geoquery are not defined.
    [Tags]    sub-notification    5_11_7
    
    Add Initial Entity
    Setup Initial Subscriptions
    
    ${notification}=    Wait for notification    ${5}
    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Dictionary Should Contain Key    ${notification}    data
    Should Not Be Empty    ${notification}[data]    Notification data should not be empty
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    Should be True    '${notification}[data][0][https://ngsi-ld-test-suite/context#airQualityLevel][value]'=='4.0' or '${notification}[data][0][https://ngsi-ld-test-suite/context#airQualityLevel][value]'=='4'
    Should be Equal    Building1    ${notification}[data][0][name][value]