Feature/between check for entities

Edited by thomas Bousselin

Merge request reports

Loading
+9 −5
Changes for TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_01.robot: 9 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -19,25 +19,29 @@ ${second_vehicle_payload_file}= 2020-09-vehicle-temporal-representation.json
${bus_payload_file}=                2020-08-bus-temporal-representation.jsonld


*** Test Cases ***    TIMEREL    TIMEAT    EXPECTATION_FILE
*** Test Cases ***    TIMEREL    TIMEAT    ENDTIMEAT    EXPECTATION_FILE
021_01_01 After
    [Tags]    te-query    5_7_4
    after    2020-08-01T12:04:00Z    vehicles-temporal-representation-021-01-01.jsonld
    after    2020-08-01T12:04:00Z    ${EMPTY}    vehicles-temporal-representation-021-01-01.jsonld
021_01_02 Before
    [Tags]    te-query    5_7_4
    before    2020-09-01T13:06:00Z    vehicles-temporal-representation-021-01-02.jsonld
    before    2020-09-01T13:06:00Z    ${EMPTY}    vehicles-temporal-representation-021-01-02.jsonld
021_01_03 Between
    [Tags]    te-query    5_7_4
    between    2020-08-01T12:04:00Z    2020-09-01T13:06:00Z    vehicles-temporal-representation-021-01-03.jsonld


*** Keywords ***
Query the temporal evolution of entities
    [Documentation]    Check that one can query the temporal evolution of entities
    [Arguments]    ${timerel}    ${timeat}    ${expectation_file}
    [Arguments]    ${timerel}    ${timeAt}    ${endTimeAt}    ${expectation_file}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    Vehicle

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    timerel=${timerel}
    ...    timeAt=${timeat}
    ...    timeAt=${timeAt}
    ...    endTimeAt=${endTimeAt}
    ...    context=${ngsild_test_suite_context}

    @{temporal_entities_representation_ids}=    Create List
+1 −1
Changes for TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_03.robot: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ ${expectation_file}= vehicles-temporal-representation-021-03.json
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    timerel=after
    ...    timeAt=2020-07-01T12:05:00Z
    ...    lastN=${14}
    ...    lastN=${4}
    ...    context=${ngsild_test_suite_context}

    @{temporal_entities_representation_ids}=    Create List
+3 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_13.robot: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ ${second_vehicle_payload_file}= 2020-09-vehicle-temporal-representation.json
021_13_02 Before
    [Tags]    te-query    5_7_4
    entity-operations-before-query.jsonld    vehicles-temporal-representation-021-13-02.jsonld
021_13_03 Between
    [Tags]    te-query    5_7_4
    entity-operations-between-query.jsonld    vehicles-temporal-representation-021-13-03.jsonld


*** Keywords ***
+9 −5
Changes for TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_14.robot: 9 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -19,24 +19,28 @@ ${second_vehicle_payload_file}= 2020-09-vehicle-temporal-representation.json
${bus_payload_file}=                2020-08-bus-temporal-representation.jsonld


*** Test Cases ***    TIMEREL    TIMEAT    EXPECTATION_FILE
*** Test Cases ***    TIMEREL    TIMEAT    ENDTIMEAT    EXPECTATION_FILE
021_14_01 After
    [Tags]    te-query    5_7_4
    after    2020-08-01T12:04:00Z    vehicles-temporal-representation-021-14-01.json
    after    2020-08-01T12:04:00Z    ${EMPTY}    vehicles-temporal-representation-021-14-01.json
021_14_02 Before
    [Tags]    te-query    5_7_4
    before    2020-09-01T13:06:00Z    vehicles-temporal-representation-021-14-02.json
    before    2020-09-01T13:06:00Z    ${EMPTY}    vehicles-temporal-representation-021-14-02.json
021_14_02 Between
    [Tags]    te-query    5_7_4
    between    2020-08-01T12:04:00Z    2020-09-01T13:06:00Z    vehicles-temporal-representation-021-14-03.json


*** Keywords ***
Query the temporal evolution of entities
    [Documentation]    Check that one can query the temporal evolution of entities with the simplified representation
    [Arguments]    ${timerel}    ${timeat}    ${expectation_file}
    [Arguments]    ${timerel}    ${timeAt}    ${endTimeAt}    ${expectation_file}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    Vehicle
    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    timerel=${timerel}
    ...    timeAt=${timeat}
    ...    timeAt=${timeAt}
    ...    endTimeAt=${endTimeAt}
    ...    context=${ngsild_test_suite_context}
    ...    options=temporalValues
    @{temporal_entities_representation_ids}=    Create List
+190 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_15.robot: 190 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check temporal pagination is applied when querying the temporal evolution of entities

Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Suite Setup         Setup Initial Entities
Suite Teardown      Delete Initial Entities
Test Template       Retrieve Temporal Entities


*** Variables ***
${vehicule_id_prefix}=              urn:ngsi-ld:Vehicle:
${first_vehicle_payload_file}=      pagination/2020-01-vehicule-temporal-representation-twenty-instances.jsonld
${second_vehicle_payload_file}=     2020-09-vehicle-temporal-representation.jsonld
${timeBefore}=                      2019-01-01T01:01:00Z
${timeAfter}=                       2021-01-01T01:01:00Z
${lrt}=                             least recent timestamp
${mrt}=                             most recent timestamp


*** Test Cases ***
021_15_01 retrieve the entity with lastN and timerel before
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    lastN=${20}    expectedSize=20    timerel=before    timeAt=${timeAfter}    expectedRangeStart=${timeAfter}    expectedRangeEnd=${lrt}
021_15_02 retrieve the entity with lastN and timerel between
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    lastN=${20}    timerel=between    timeAt=${timeBefore}    endTimeAt=${timeAfter}    expectedRangeStart=${timeAfter}    expectedRangeEnd=${lrt}
021_15_03 retrieve the entity with lastN and timerel after
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    lastN=${20}    expectedSize=20    timerel=after    timeAt=${timeBefore}    expectedRangeStart=${mrt}    expectedRangeEnd=${lrt}
021_15_04 retrieve the entity with timerel before
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    timerel=before    expectedSize=*    timeAt=${timeAfter}    expectedRangeEnd=${mrt}
021_15_05 retrieve the entity with timerel between
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    timerel=between    timeAt=${timeBefore}    endTimeAt=${timeAfter}    expectedRangeStart=${timeBefore}    expectedRangeEnd=${mrt}
021_15_06 retrieve the entity with timerel after
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    timerel=after    timeAt=${timeBefore}    expectedRangeStart=${timeBefore}    expectedRangeEnd=${mrt}
021_15_07 retrieve the entity with temporalValues and timerel after
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    representation=temporalValues    timerel=after    timeAt=${timeBefore}    expectedRangeStart=${timeBefore}    expectedRangeEnd=${mrt}
021_15_08 retrieve the entity with temporalValues, lastN and timerel between
    [Tags]    te-retrieve    5_7_4    6_3_10    since_v1.5.1
    representation=temporalValues    lastN=${20}    timerel=between    timeAt=${timeBefore}    endTimeAt=${timeAfter}    expectedRangeStart=${timeAfter}    expectedRangeEnd=${lrt}


*** Keywords ***
Retrieve Temporal Entities
    [Documentation]    Check temporal pagination behavior on multiple entity endpoint
    [Arguments]
    ...    ${representation}=${EMPTY}
    ...    ${timerel}=${EMPTY}
    ...    ${timeAt}=${EMPTY}
    ...    ${endTimeAt}=${EMPTY}
    ...    ${lastN}=${EMPTY}
    ...    ${expectedRangeStart}=${EMPTY}
    ...    ${expectedRangeEnd}=${EMPTY}
    ...    ${expectedSize}=${EMPTY}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    Vehicle

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    options=${representation}
    ...    context=${ngsild_test_suite_context}
    ...    timerel=${timerel}
    ...    timeAt=${timeAt}
    ...    endTimeAt=${endTimeAt}
    ...    lastN=${lastN}
    Check Response Status Code    206    ${response.status_code}

    ${contentRange}=    Get Regexp Matches
    ...    ${response.headers}[Content-Range]
    ...    ([a-zA-Z\-]+) (.*-.*-.*)-(.*-.*-.*)\/(.*)
    ...    1
    ...    2
    ...    3
    ...    4
    ${unit}=    Set Variable    ${contentRange}[0][0]
    ${rangeStart}=    Convert Date    ${contentRange}[0][1]
    ${rangeEnd}=    Convert Date    ${contentRange}[0][2]
    ${size}=    Set Variable    ${contentRange}[0][3]

    Check Content Range Part Equal    ${unit}    date-time

    IF    $expectedRangeStart != ''
        IF    $expectedRangeStart == $lrt
            ${expectedRangeStart}=    Get Least Recent Timestamp From Vehicles    ${response.json()}
        ELSE IF    $expectedRangeStart == $mrt
            ${expectedRangeStart}=    Get Most Recent Timestamp From Vehicles    ${response.json()}
        ELSE
            ${expectedRangeStart}=    Convert Date    ${expectedRangeStart}
        END
        Check Content Range Part Equal    ${expectedRangeStart}    ${rangeStart}
    END

    IF    $expectedRangeEnd != ''
        IF    $expectedRangeEnd == $lrt
            ${expectedRangeEnd}=    Get Least Recent Timestamp From Vehicles
            ...    ${response.json()}
            ...    ${representation}
        ELSE IF    $expectedRangeEnd == $mrt
            ${expectedRangeEnd}=    Get Most Recent Timestamp From Vehicles
            ...    ${response.json()}
            ...    ${representation}
        ELSE
            ${expectedRangeEnd}=    Convert Date    ${expectedRangeEnd}
        END
        Check Content Range Part Equal    ${expectedRangeEnd}    ${rangeEnd}
    END

    IF    $expectedSize != ''
        Check Content Range Part Equal    ${expectedSize}    ${size}
    END

Setup Initial Entities
    ${first_temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicule_id_prefix}
    ${second_temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicule_id_prefix}
    ${response}=    Create Temporal Representation Of Entity
    ...    ${first_vehicle_payload_file}
    ...    ${first_temporal_entity_representation_id}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Create Temporal Representation Of Entity
    ...    ${second_vehicle_payload_file}
    ...    ${second_temporal_entity_representation_id}
    Check Response Status Code    201    ${response.status_code}

    Set Suite Variable    ${first_temporal_entity_representation_id}
    Set Suite Variable    ${second_temporal_entity_representation_id}

Delete Initial Entities
    Delete Temporal Representation Of Entity    ${first_temporal_entity_representation_id}
    Delete Temporal Representation Of Entity    ${second_temporal_entity_representation_id}

Get Least Recent Timestamp From Vehicles
    [Arguments]    ${body}    ${representation}=${EMPTY}

    ${attributeList}=    Get Attribute List From Vehicle Body    ${body}    ${representation}

    ${leastRecentTimestamp}=    Convert Date    ${timeAfter}
    FOR    ${attribute}    IN    @{attributeList}
        IF    $representation == 'temporalValues'
            ${attributeTime}=    Convert Date    ${attribute}[1]
        ELSE
            ${attributeTime}=    Convert Date    ${attribute}[observedAt]
        END

        IF    $leastRecentTimestamp >= $attributeTime
            ${leastRecentTimestamp}=    Set Variable    ${attributeTime}
        END
    END
    RETURN    ${leastRecentTimestamp}

Get Most Recent Timestamp From Vehicles
    [Arguments]    ${body}    ${representation}=${EMPTY}
    ${attributeList}=    Get Attribute List From Vehicle Body    ${body}    ${representation}

    ${mostRecentTimestamp}=    Convert Date    ${timeBefore}
    FOR    ${attribute}    IN    @{attributeList}
        IF    $representation == 'temporalValues'
            ${attributeTime}=    Convert Date    ${attribute}[1]
        ELSE
            ${attributeTime}=    Convert Date    ${attribute}[observedAt]
        END
        IF    $mostRecentTimestamp <= $attributeTime
            ${mostRecentTimestamp}=    Set Variable    ${attributeTime}
        END
    END
    RETURN    ${mostRecentTimestamp}

Get Attribute List From Vehicle Body
    [Arguments]    ${body}    ${representation}=${EMPTY}
    IF    $representation == 'temporalValues'
        ${attributeList}=    Combine Lists
        ...    ${body}[0][speed][values]
        ...    ${body}[0][fuelLevel][values]
        ...    ${body}[1][speed][values]
        ...    ${body}[1][fuelLevel][values]
    ELSE
        ${attributeList}=    Combine Lists
        ...    ${body}[0][speed]
        ...    ${body}[0][fuelLevel]
        ...    ${body}[1][speed]
        ...    ${body}[1][fuelLevel]
    END
    RETURN    ${attributeList}
Loading
Loading