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

fix 046_02

parent f857d1f5
Loading
Loading
Loading
Loading
+12 −10
Original line number Original line Diff line number Diff line
@@ -24,7 +24,6 @@ ${notification_server_send_url}= http://${send_notification_server_host}:${s
Setup Initial Subscriptions
Setup Initial Subscriptions
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${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}=    Load Subscription Sample With Reachable Endpoint    ${subscription_payload_file_path}    ${subscription_id}    ${notification_server_send_url}
    # http://ptsv2.com/t/9jkg1-1625063286/post
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Set Suite Variable    ${subscription_id}
    Set Suite Variable    ${subscription_id}


@@ -33,28 +32,31 @@ Delete Initial Subscriptions


Before Test
Before Test
    Setup Initial Subscriptions
    Setup Initial Subscriptions
    Add Initial Entity
    NotificationUtils.Start Local Server    ${notification_server_host}    ${notification_server_port}
    NotificationUtils.Start Local Server    ${notification_server_host}    ${notification_server_port}


After Test
After Test
    Delete Initial Subscriptions
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server
    Stop Local Server


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}

    
    
*** Test Cases ***
*** Test Cases ***
Check that a notification is only sent if status is active
Check that a notification is only sent if status is active
    [Documentation]     Check that a notification is only sent if and only if the status is active
    [Documentation]     Check that a notification is only sent if and only if the status is active
    [Tags]    sub-notification    5_11_7
    [Tags]    sub-notification    5_11_7
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix} 

    Create Entity    ${entity_building_filepath}    ${entity_id}
    Output    Before:
    Query Entity    ${entity_id}
    Sleep    5
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Output    After:

    Query Entity    ${entity_id}
    ${notification}=    Wait for notification    timeout=${5}
    ${notification}=    Wait for notification    timeout=${5}
    Output    Notification:
    Output    ${notification}


    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
+38 −8
Original line number Original line Diff line number Diff line
@@ -4,32 +4,62 @@ Resource ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
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-timeInterval-sample.jsonld
${subscription_payload_file_path}=    subscriptions/subscription-timeInterval-sample.jsonld
${building_id_prefix}=    urn:ngsi-ld:Building:
${building_id_prefix}=    urn:ngsi-ld:Building:
${notification_server_send_url}=     http://${send_notification_server_host}:${send_notification_server_port}/notify
${entity_building_filepath}=    building-simple-attributes-sample.jsonld


*** Keywords ***
*** Keywords ***
Setup Initial Subscriptions
Setup Initial Subscriptions
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${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}
    Set Suite Variable    ${subscription_id}


Delete Initial Subscriptions
Delete Initial Subscriptions
    Delete Subscription    ${subscription_id}
    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 ***
*** Test Case ***
Check that a notification is send on the timeinterval
Check that a notification is send on the timeinterval
    [Documentation]     If a Subscription defines a timeInterval member, a Notification shall be sent periodically, when the time interval (in seconds) specified in such value field is reached, regardless of Attribute changes."
    [Documentation]     If a Subscription defines a timeInterval member, a Notification shall be sent periodically, when the time interval (in seconds) specified in such value field is reached, regardless of Attribute changes."
    [Tags]    sub-notification    5_11_7
    [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}
    Setup Initial Subscriptions
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Add Initial Entity
    Set Suite Variable    ${subscription_id}

    Wait for notification  timeout=${15}
    Sleep    11
    ${notification}=    Wait for notification  timeout=${15}
    Output    ${notification}

    ${notification}=    Wait for notification  timeout=${15}
    Output    ${notification}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    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    Eifel Tower    ${notification}[data][0][name][value] 






+1 −1
Original line number Original line Diff line number Diff line
@@ -3,7 +3,7 @@
    "type": "Building",
    "type": "Building",
    "name": {
    "name": {
        "type": "Property",
        "type": "Property",
        "value": "Eiffel Tower"
        "value": "Eifel Tower"
    },
    },
    "subCategory": {
    "subCategory": {
        "type": "Property",
        "type": "Property",
+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":"application/json"
         "accept":"application/json"