Unverified Commit 6fb1bf7b authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat(pick-omit): add TCs for Query Temporal Representation of Entities

parent 5c6063c8
Loading
Loading
Loading
Loading
+90 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can query the temporal evolution of entities with pick and omit query params

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

Test Setup          Setup Initial Entities
Test Teardown       Delete Initial Entities
Test Template       Query Temporal Evolution Of Entities With Pick Or Omit Query Params


*** Variables ***
${first_vehicle_payload_file}=      2020-08-vehicle-temporal-representation.jsonld
${second_vehicle_payload_file}=     2020-09-vehicle-temporal-representation.jsonld
${bus_payload_file}=                2020-08-bus-temporal-representation.jsonld


*** Test Cases ***    PICK    OMIT    EXPECTED_FILENAME    GROUP_BY
021_21_01 QueryWithPickOnAttributes
    [Documentation]    Check that one can query temporal entities with pick on attributes
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    speed    ${EMPTY}    pick-omit/temporal-entities-pick-speed.json    None
021_21_02 QueryWithOmitOnAttributes
    [Documentation]    Check that one can query temporal entities with omit on attributes
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    ${EMPTY}    speed    pick-omit/temporal-entities-omit-speed.json
021_21_03 QueryWithPickOnNonCoreMembers
    [Documentation]    Check that one can query temporal entities with pick on core members
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    id    ${EMPTY}    pick-omit/temporal-entities-pick-id.json
021_21_04 QueryWithOmitOnNonCoreMembers
    [Documentation]    Check that one can query temporal entities with omit on core members
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    ${EMPTY}    type    pick-omit/temporal-entities-omit-type.json
021_21_05 QueryWithPickOnAttributesAndCoreMembers
    [Documentation]    Check that one can query temporal entities with pick on attributes and core members
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    id,speed    ${EMPTY}    pick-omit/temporal-entities-pick-id-speed.json
021_21_06 QueryWithOmitOnAttributesAndCoreMembers
    [Documentation]    Check that one can query temporal entities with omit on attributes and core members
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    ${EMPTY}    type,speed    pick-omit/temporal-entities-omit-type-speed.json


*** Keywords ***
Query Temporal Evolution Of Entities With Pick Or Omit Query Params
    [Documentation]    Query the temporal evolution of entities giving pick or omit query params different values
    [Arguments]    ${pick}    ${omit}    ${expected_filename}    ${group_by}=id

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=Building,Vehicle
    ...    timerel=after
    ...    timeAt=1970-01-01T00:00:00Z
    ...    pick=${pick}
    ...    omit=${omit}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing EntityTemporal elements
    ...    ${expected_filename}
    ...    ${response.json()}
    ...    ${group_by}

Setup Initial Entities
    ${first_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-21-A
    ${create_response1}=    Create Temporal Representation Of Entity
    ...    ${first_vehicle_payload_file}
    ...    ${first_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response1.status_code}
    Set Test Variable    ${first_temporal_entity_representation_id}
    ${second_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-21-B
    ${create_response2}=    Create Temporal Representation Of Entity
    ...    ${second_vehicle_payload_file}
    ...    ${second_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response2.status_code}
    Set Test Variable    ${second_temporal_entity_representation_id}
    ${third_temporal_entity_representation_id}=    Catenate    ${BUS_ID_PREFIX}021-21-C
    ${create_response3}=    Create Temporal Representation Of Entity
    ...    ${bus_payload_file}
    ...    ${third_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response3.status_code}
    Set Test Variable    ${third_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}
    Delete Temporal Representation Of Entity    ${third_temporal_entity_representation_id}
+78 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a BadRequestDataException is returned if the Query Temporal Entities request is invalid with respect to pick and omit query params

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

Test Setup          Setup Initial Entities
Test Teardown       Delete Initial Entities
Test Template       Query Temporal Entities With Invalid Pick Or Omit Query Params Usage


*** Variables ***
${first_vehicle_payload_file}=      2020-08-vehicle-temporal-representation.jsonld
${second_vehicle_payload_file}=     2020-09-vehicle-temporal-representation.jsonld
${bus_payload_file}=                2020-08-bus-temporal-representation.jsonld


*** Test Cases ***    PICK    OMIT    ATTRS
020_22_01 RetrieveWithSameEntityMemberInPickAndOmit
    [Documentation]    Check that a BadRequestDataException is returned if an entity member is present in pick and omit
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    speed    speed    ${EMPTY}
020_22_02 RetrieveWithPickAndAttrs
    [Documentation]    Check that a BadRequestDataException is returned if pick and attrs query params are present
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    speed    ${EMPTY}    fuelLevel
020_22_03 RetrieveWithOmitAndAttrs
    [Documentation]    Check that a BadRequestDataException is returned if omit and attrs query params are present
    [Tags]    te-query    5_7_4    4_2_1    since_v1.8.1
    ${EMPTY}    speed    fuelLevel


*** Keywords ***
Query Temporal Entities With Invalid Pick Or Omit Query Params Usage
    [Documentation]    Check that a BadRequestDataException is returned if the Query Temporal Entities request is invalid with respect to pick and omit query params
    [Arguments]    ${pick}    ${omit}    ${attrs}

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=Building,Vehicle
    ...    timerel=after
    ...    timeAt=1970-01-01T00:00:00Z
    ...    pick=${pick}
    ...    omit=${omit}
    ...    attrs=${attrs}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}

Setup Initial Entities
    ${first_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-22-A
    ${create_response1}=    Create Temporal Representation Of Entity
    ...    ${first_vehicle_payload_file}
    ...    ${first_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response1.status_code}
    Set Test Variable    ${first_temporal_entity_representation_id}
    ${second_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-22-B
    ${create_response2}=    Create Temporal Representation Of Entity
    ...    ${second_vehicle_payload_file}
    ...    ${second_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response2.status_code}
    Set Test Variable    ${second_temporal_entity_representation_id}
    ${third_temporal_entity_representation_id}=    Catenate    ${BUS_ID_PREFIX}021-22-C
    ${create_response3}=    Create Temporal Representation Of Entity
    ...    ${bus_payload_file}
    ...    ${third_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response3.status_code}
    Set Test Variable    ${third_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}
    Delete Temporal Representation Of Entity    ${third_temporal_entity_representation_id}
+74 −0
Original line number Diff line number Diff line
[
    {
        "id": "urn:ngsi-ld:Bus:021-21-C",
        "type": "Bus",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 210,
                "instanceId": "urn:ngsi-ld:Instance:9d3c902b-5e16-4c45-8fa1-2d4c57f2b559",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 145,
                "instanceId": "urn:ngsi-ld:Instance:c89c7c43-5c0a-4acb-90ef-d8d39f3fd4d9",
                "observedAt": "2020-08-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 124,
                "instanceId": "urn:ngsi-ld:Instance:03ab2c33-9cb7-416f-86d0-c30731fbada4",
                "observedAt": "2020-08-01T14:07:00Z"
            }
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:021-21-A",
        "type": "Vehicle",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:8c488b28-84c2-4aac-8659-58be81f8ea75",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 53,
                "instanceId": "urn:ngsi-ld:Instance:902966d9-f9b9-4911-a1d4-fff32f9aac85",
                "observedAt": "2020-08-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 40,
                "instanceId": "urn:ngsi-ld:Instance:158e0c43-e7dc-4a0a-9068-a465147c910e",
                "observedAt": "2020-08-01T14:07:00Z"
            }
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:021-21-B",
        "type": "Vehicle",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:9561089f-3976-4080-bedc-71ceb6925226",
                "observedAt": "2020-09-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 53,
                "instanceId": "urn:ngsi-ld:Instance:11be1bee-a40c-4d47-bd83-c9d6afb9f420",
                "observedAt": "2020-09-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 40,
                "instanceId": "urn:ngsi-ld:Instance:6570037f-8ae9-4d25-85bb-25f5dc235be1",
                "observedAt": "2020-09-01T14:07:00Z"
            }
        ]
    }
]
 No newline at end of file
+71 −0
Original line number Diff line number Diff line
[
    {
        "id": "urn:ngsi-ld:Bus:021-21-C",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 210,
                "instanceId": "urn:ngsi-ld:Instance:ec0122ad-1a84-4e54-b48a-0ece5e3ef2b1",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 145,
                "instanceId": "urn:ngsi-ld:Instance:72343982-e0d3-4774-84aa-5b53650b75df",
                "observedAt": "2020-08-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 124,
                "instanceId": "urn:ngsi-ld:Instance:0092c6a7-c6cd-436a-aa11-f4fa9f1fd4bf",
                "observedAt": "2020-08-01T14:07:00Z"
            }
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:021-21-A",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:c094f028-7e58-4601-a595-a1f7898854a8",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 53,
                "instanceId": "urn:ngsi-ld:Instance:a8e2f379-d9ec-4732-b410-b4316cfe0601",
                "observedAt": "2020-08-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 40,
                "instanceId": "urn:ngsi-ld:Instance:40d94cbe-04fa-405d-83fb-ecc852a420c7",
                "observedAt": "2020-08-01T14:07:00Z"
            }
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:021-21-B",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:886b0c8c-3c39-4ab7-a7fd-6f763546f44e",
                "observedAt": "2020-09-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 53,
                "instanceId": "urn:ngsi-ld:Instance:aa25b081-3807-4b53-81e0-dca85352c0a3",
                "observedAt": "2020-09-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 40,
                "instanceId": "urn:ngsi-ld:Instance:c74f0a13-8994-4636-b6d6-76d6221a6021",
                "observedAt": "2020-09-01T14:07:00Z"
            }
        ]
    }
]
 No newline at end of file
+131 −0
Original line number Diff line number Diff line
[
    {
        "id": "urn:ngsi-ld:Bus:021-21-C",
        "speed": [
            {
                "type": "Property",
                "value": 45,
                "instanceId": "urn:ngsi-ld:Instance:5d6d7785-b5d1-44dd-b82f-c02556166c7d",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 25,
                "instanceId": "urn:ngsi-ld:Instance:c62ccab7-59d9-4a74-86e6-38d891e9d4ba",
                "observedAt": "2020-08-01T12:05:00Z"
            },
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:8a1961b0-c20a-4e8f-9151-33da70ca507a",
                "observedAt": "2020-08-01T12:07:00Z"
            }
        ],
        "fuelLevel": [
            {
                "type": "Property",
                "value": 210,
                "instanceId": "urn:ngsi-ld:Instance:9e78ec30-778e-4d38-9f3b-d3260824cdf9",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 145,
                "instanceId": "urn:ngsi-ld:Instance:791258d6-6ec8-4341-93e1-cb69b80b1c8c",
                "observedAt": "2020-08-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 124,
                "instanceId": "urn:ngsi-ld:Instance:bb657e0d-fed9-4d69-a42a-7f7ff11b0999",
                "observedAt": "2020-08-01T14:07:00Z"
            }
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:021-21-A",
        "fuelLevel": [
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:e76aec35-e028-4f39-a71c-9ab87619c6f8",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 53,
                "instanceId": "urn:ngsi-ld:Instance:ebaa174d-1b0a-4150-9efa-ebaece61ef1f",
                "observedAt": "2020-08-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 40,
                "instanceId": "urn:ngsi-ld:Instance:21073f3c-5635-4995-944a-54b2bec9924c",
                "observedAt": "2020-08-01T14:07:00Z"
            }
        ],
        "speed": [
            {
                "type": "Property",
                "value": 120,
                "instanceId": "urn:ngsi-ld:Instance:32428955-8177-4887-a914-f2cac9af8b6e",
                "observedAt": "2020-08-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 80,
                "instanceId": "urn:ngsi-ld:Instance:14cb0355-7e11-4c27-9925-fb6037643f19",
                "observedAt": "2020-08-01T12:05:00Z"
            },
            {
                "type": "Property",
                "value": 100,
                "instanceId": "urn:ngsi-ld:Instance:2578bb4d-7bb3-448c-998e-9a41d0cdfebd",
                "observedAt": "2020-08-01T12:07:00Z"
            }
        ]
    },
    {
        "id": "urn:ngsi-ld:Vehicle:021-21-B",
        "speed": [
            {
                "type": "Property",
                "value": 120,
                "instanceId": "urn:ngsi-ld:Instance:ded77aae-0edf-4ce2-9c36-5a4187012add",
                "observedAt": "2020-09-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 80,
                "instanceId": "urn:ngsi-ld:Instance:10d36809-9a64-490b-84bc-ef9473962836",
                "observedAt": "2020-09-01T12:05:00Z"
            },
            {
                "type": "Property",
                "value": 100,
                "instanceId": "urn:ngsi-ld:Instance:5c69d3d8-d1f0-49f5-8a03-3bf24b8c23a3",
                "observedAt": "2020-09-01T12:07:00Z"
            }
        ],
        "fuelLevel": [
            {
                "type": "Property",
                "value": 67,
                "instanceId": "urn:ngsi-ld:Instance:74072f09-b040-4e71-bb63-eaff0ffab282",
                "observedAt": "2020-09-01T12:03:00Z"
            },
            {
                "type": "Property",
                "value": 53,
                "instanceId": "urn:ngsi-ld:Instance:4252a42e-8da5-446b-b5b1-396c9cfc5941",
                "observedAt": "2020-09-01T13:05:00Z"
            },
            {
                "type": "Property",
                "value": 40,
                "instanceId": "urn:ngsi-ld:Instance:87a1ed49-d71a-4eaa-b3f7-b82439288317",
                "observedAt": "2020-09-01T14:07:00Z"
            }
        ]
    }
]
 No newline at end of file
Loading