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

046_09

parent 9d11df03
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -12,12 +12,9 @@ Suite Teardown After Test
*** Variable ***
*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=    subscriptions/subscription-building-entities-active.jsonld
${subscription_payload_file_path}=    subscriptions/subscription-building-entities-active.jsonld
#subscriptions/testsubscription.jsonld 
${building_id_prefix}=    urn:ngsi-ld:Building:
${building_id_prefix}=    urn:ngsi-ld:Building:
${entity_building_filepath}=    building-simple-attributes-sample.jsonld
${entity_building_filepath}=    building-simple-attributes-sample.jsonld
#testentity.jsonld
${fragment_filename}=    airQualityLevel-fragment.jsonld
${fragment_filename}=    airQualityLevel-fragment.jsonld
#testfragment.jsonld
${notification_server_send_url}=     http://${send_notification_server_host}:${send_notification_server_port}/notify
${notification_server_send_url}=     http://${send_notification_server_host}:${send_notification_server_port}/notify


*** Keywords ***
*** Keywords ***
+5 −2
Original line number Original line Diff line number Diff line
@@ -84,8 +84,11 @@ Check that a notification is sent with all attributes in simplified format
    Dictionary Should Contain Key    ${notification}    data
    Dictionary Should Contain Key    ${notification}    data
    Should Not Be Empty    ${notification}[data]    Notification data should not be empty
    Should Not Be Empty    ${notification}[data]    Notification data should not be empty
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    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]
    Should be Equal    Building1    ${notification}[data][0][name][value]
    Dictionary Should Contain Key    '${notification}[data][0]    https://ngsi-ld-test-suite/context#almostFull
    Dictionary Should Contain Key    '${notification}[data][0]    https://ngsi-ld-test-suite/context#airQualityLevel
    Dictionary Should Contain Key    '${notification}[data][0]    https://ngsi-ld-test-suite/context#subCategory
    # TODO: difference between keyValue and not
    
    
    
    


+36 −26
Original line number Original line Diff line number Diff line
@@ -7,44 +7,54 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Resource          ${EXECDIR}/resources/NotificationUtils.resource
Resource          ${EXECDIR}/resources/NotificationUtils.resource


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


*** Variable ***
*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${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:
${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 ***
Add Initial Entity
Check that a notification is only sent if statis is active
    [Arguments]      ${fragment_filename}    
    [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
    [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_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
Delete Initial Entity
    Set Suite Variable    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Create Subscription  ${subscription_id}  ${subscription_payload}  
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}


    Wait for redirected request
*** Test Cases ***
Check that a notification is sent to the endpoint
    [Documentation]     Check that a notification is only sent if and only if the status is active
    [Tags]    sub-notification    5_11_7    046_09


    Add Initial Entity
    Setup Initial Subscriptions


*** Keywords ***
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
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}


Delete Subscription
    ${notification}=    Wait for notification    timeout=${10}
    Stop Local Server
    Delete Subscription      ${subscription_id}


+11 −0
Original line number Original line Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:randomUUID",
    "type": "Building",
    "name": {
        "type": "Property",
        "value": "Building1"
    },
    "@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"
    ]
}
 No newline at end of file
+0 −1
Original line number Original line Diff line number Diff line
@@ -8,7 +8,6 @@
      }
      }
   ],
   ],
   "notification":{
   "notification":{
      "format":"keyValues",
      "endpoint":{
      "endpoint":{
         "uri":"http://my.endpoint.org/notify",
         "uri":"http://my.endpoint.org/notify",
         "accept":"*/*"
         "accept":"*/*"