Commit 510b5be3 authored by Gert De Tant @ Sirus's avatar Gert De Tant @ Sirus
Browse files

added 46_05

parent 75b1ada8
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ Suite Teardown Delete Initial Subscriptions

*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${active_subscription_payload_file_path}=    subscriptions/subscription-building-entities-active.jsonld
${subscription_payload_file_path}=    subscriptions/subscription-building-entities-active.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:


@@ -21,11 +21,15 @@ Check that a notification is only sent if statis is active
    [Documentation]     Check that a notification is only sent if and only if the status is active
    [Tags]    sub-notification    5_11_7
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint    ${active_subscription_payload_file_path}    ${subscription_id}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint    ${subscription_payload_file_path}    ${subscription_id}
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}

    @{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}

    Set Suite Variable    ${subscription_id}
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Wait for notification  timeout=${5}
    Wait for subscription notification and validate it  ${subscription_id}  ${expected_notification_data_entities}  timeout=${5}



+3 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ Suite Teardown Delete Initial Subscriptions

*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${timeinterval_subscription_payload_file_path}= subscriptions/subscription-timeinterval-sample.jsonld
${subscription_payload_file_path}= subscriptions/subscription-timeinterval-sample.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:


@@ -21,10 +21,10 @@ Check that a notification is send 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    ${timeinterval_subscription_payload_file_path}    ${subscription_id}
    ${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 notification  timeout=${15}
    Wait for subscription notification and validate it  ${subscription_id}  ${expected_notification_data_entities}  timeout=${5}



+37 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation     If a Subscription does not define a timeInterval term, the notification shall be sent whenever there is a change in the watched Attributes. The notification message shall include all the subscribed Entities that changed and that match (as mandated by clauses 4.9 and4.10) the query and geoquery conditions

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

*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=    subscriptions/subscription-building-entities-active-query.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:
${building_filename}=    building-location-attribute.jsonld





*** Test Case ***
Check that a notification is send with all entities
    [Arguments]      ${fragment_filename}    
    [Documentation]     The notification message shall include all the subscribed Entities that changed and that match (as mandated by clauses 4.9 and4.10) the query and geoquery conditions
    [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}
    ${entity_building}   Create Entity Selecting Content Type    ${building_filename}    ${entity_id}    ${CONTENT_TYPE_LD_JSON}

    Set Suite Variable    ${subscription_id}
    Wait for subscription notification and validate it  ${subscription_id}  ${entity}  timeout=${5}




+18 −0
Original line number Diff line number Diff line
{
   "type":"Subscription",
   "isActive": true,
   "expiresAt": null,
   "entities":[
      {
         "type":"Building"
      }
   ],
   "q":"name=\"Eifel Tower\"",
   "notification":{
      "format":"keyValues",
      "endpoint":{
         "uri":"http://my.endpoint.org/notify",
         "accept":"application/json"
      }
   }
}
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
@@ -55,6 +55,35 @@ Wait for notification and validate it
    # 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 subscription notification and validate it
    [Arguments]  ${expected_subscription_id}  ${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}
   

    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
    
    Should Be Equal     '${notification_data_length}'     '${expected_notification_data_length}'
    
    # 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