Commit d6796e96 authored by Houcem Kacem's avatar Houcem Kacem
Browse files

Merge branch 'feature/add-missing-tp-in-query-temporal-evolution-of-entities' into 'develop'

feat: add missing tp in query temporal evolution of entities

See merge request !36
parents 12c1bb6c 8499bf10
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can query the temporal evolution of entities matching the given NGSI-LD Context Source filter
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource
Resource    ${EXECDIR}/resources/MockServerUtils.resource

Suite Setup      Create Initial Context Source Registration
Suite Teardown      Delete Initial Context Source Registration

*** Variable ***
${context_source_registration_id_prefix}=  urn:ngsi-ld:ContextSourceRegistration:
${context_source_registration_payload_file_path}=   csourceRegistrations/context-source-registration-observationInterval-sample.jsonld
${context_source_url}=     http://${context_source_host}:${context_source_port}

*** Test Case ***
Query the temporal evolution of entities matching the given NGSI-LD context source filter
    [Documentation]  Check that you can query the temporal evolution of entities matching the given NGSI-LD Context Source filter
    [Tags]  mandatory

    @{entity_types_to_be_retrieved}=  Create List   Building

    Query Temporal Representation Of Entities   entity_types=${entity_types_to_be_retrieved}    csf=endpoint=="${context_source_url}"    timerel=after    timeAt=2020-07-01T12:05:00Z    context=${ngsild_test_suite_context}

    Wait for redirected request
    Check Response Status Code Set To  200

*** Keywords ***
Create Initial Context Source Registration
    Start Context Source Mock Server

    ${context_source_registration_id}=     Generate Random Entity Id    ${context_source_registration_id_prefix}
    ${context_source_registration_payload}=  Load Context Source Registration Sample With Reachable Context Source    ${context_source_registration_payload_file_path}    ${context_source_registration_id}

    Create Context Source Registration  ${context_source_registration_payload}

    Set Suite Variable  ${context_source_registration_id}

Delete Initial Context Source Registration
    Stop Context Source Mock Server

    Delete Context Source Registration     ${context_source_registration_id}
+2 −1
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ Retrieve Temporal Representation Of Entity
    Set Test Variable  ${response}

Query Temporal Representation Of Entities
    [Arguments]  ${context}=${EMPTY}     ${entity_types}=${EMPTY}   ${entity_ids}=${EMPTY}    ${entity_id_pattern}=${EMPTY}    ${ngsild_query}=${EMPTY}  ${georel}=${EMPTY}   ${geometry}=${EMPTY}    ${coordinates}=${EMPTY}    ${geoproperty}=${EMPTY}    ${timerel}=${EMPTY}      ${timeAt}=${EMPTY}     ${attrs}=${EMPTY}   ${limit}=${EMPTY}   ${lastN}=${EMPTY}
    [Arguments]  ${context}=${EMPTY}     ${entity_types}=${EMPTY}   ${entity_ids}=${EMPTY}    ${entity_id_pattern}=${EMPTY}    ${ngsild_query}=${EMPTY}  ${csf}=${EMPTY}   ${georel}=${EMPTY}   ${geometry}=${EMPTY}    ${coordinates}=${EMPTY}    ${geoproperty}=${EMPTY}    ${timerel}=${EMPTY}      ${timeAt}=${EMPTY}     ${attrs}=${EMPTY}   ${limit}=${EMPTY}   ${lastN}=${EMPTY}
    ${entity_types_length} =  Get Length  ${entity_types}
    ${entity_ids_length} =  Get Length  ${entity_ids}
    ${attrs_length} =  Get Length  ${attrs}
@@ -384,6 +384,7 @@ Query Temporal Representation Of Entities
    Run Keyword If     '${lastN}'!=''       Set To Dictionary   ${params}    lastN=${lastN}
    Run Keyword If     '${entity_id_pattern}'!=''       Set To Dictionary   ${params}    idPattern=${entity_id_pattern}
    Run Keyword If     '${ngsild_query}'!=''       Set To Dictionary   ${params}    q=${ngsild_query}
    Run Keyword If     '${csf}'!=''       Set To Dictionary   ${params}    csf=${csf}
    Run Keyword If     '${georel}'!=''       Set To Dictionary   ${params}    georel=${georel}
    Run Keyword If     '${geometry}'!=''       Set To Dictionary   ${params}    geometry=${geometry}
    Run Keyword If     '${coordinates}'!=''       Set To Dictionary   ${params}    coordinates=${coordinates}
+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ Check Response Body Containing List Containing Subscription elements
    ${comparison_result}=    Compare Dictionaries Ignoring Keys    ${response['body']}    ${subscription_payload}  ${EMPTY}
    Should Be True      ${comparison_result}   msg=Subscription Comparison Failed

# Since response body can be a json object if it contains one subscription
# Since response body can be a json object if it contains one element
# A check on the response body type is needed
Check Response Body Containing Number Of Entities
    [Arguments]     ${expected_entity_type}    ${expected_length}
+9 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Library JSONLibrary
*** Variable ***
${date_format}=  %Y-%m-%dT%H:%M:%SZ
${notification_server_url}=     http://${notification_server_host}:${notification_server_port}/notify
${context_source_url}=     http://${context_source_host}:${context_source_port}

*** Keywords ***
Load Entity
@@ -34,6 +35,14 @@ Load Subscription Sample With Reachable Endpoint

    [return]    ${subscription}

Load Context Source Registration Sample With Reachable Context Source
    [Arguments]    ${context_source_registration_file_path}     ${context_source_registration_id}=${EMPTY}      ${context_source_endpoint_uri}=${context_source_url}

    ${context_source_registration_payload}=  Load Test Sample    ${context_source_registration_file_path}    ${context_source_registration_id}
    ${context_source_registration}=    Update Value To Json    ${context_source_registration_payload}     $..endpoint   ${context_source_endpoint_uri}

    [return]    ${context_source_registration}

Remove Entity Type
    [Arguments]    ${entity}

+21 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation  Mock http server for context sources
Library      HttpCtrl.Server

*** Keywords ***
Start Context Source Mock Server
    #Initialize HTTP Client And Server
    Start Server        0.0.0.0   8086

Wait for redirected request
    [Arguments]  ${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

Stop Context Source Mock Server
    #Terminate HTTP Server
    Stop Server
Loading