Commit dc4f9e50 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat(pick-omit): add TCs for Retrieve Temporal Representation of Entity

parent 78276c79
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the temporal evolution of an entity and pick or omit some attributes

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          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Retrieve the temporal evolution of an entity with pick and omit


*** Variables ***
${vehicle_payload_file}=        2020-08-vehicle-temporal-representation.jsonld
${vehicle_expectation_file}=    vehicle-temporal-representation-020-03.jsonld


*** Test Cases ***    PICK    OMIT    EXPECTATION_FILENAME
020_21_01 RetrieveWithPickOnAttributes
    [Documentation]    Check that one can retrieve an entity with pick on attributes
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    speed    ${EMPTY}    pick-omit/vehicle-pick-speed.json
020_21_02 RetrieveWithOmitOnAttributes
    [Documentation]    Check that one can retrieve an entity with omit on attributes
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    ${EMPTY}    speed    pick-omit/vehicle-omit-speed.json
020_21_03 RetrieveWithPickOnAttributesAndCoreMembers
    [Documentation]    Check that one can retrieve an entity with pick on attributes and core members
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    id,speed    ${EMPTY}    pick-omit/vehicle-pick-id-speed.json
020_21_04 RetrieveWithOmitOnAttributesAndCoreMembers
    [Documentation]    Check that one can retrieve an entity with omit on attributes and core members
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    ${EMPTY}    type,speed    pick-omit/vehicle-omit-type-speed.json


*** Keywords ***
Retrieve the temporal evolution of an entity with pick and omit
    [Documentation]    Check that one can retrieve the temporal evolution of an entity and pick or omit some attributes
    [Arguments]    ${pick}    ${omit}    ${expectation_filename}

    ${response}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    pick=${pick}
    ...    omit=${omit}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing EntityTemporal element
    ...    ${expectation_filename}
    ...    ${temporal_entity_representation_id}
    ...    ${response.json()}

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Vehicle Entity Id
    ${create_response}=    Create Temporal Representation Of Entity
    ...    ${vehicle_payload_file}
    ...    ${temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response.status_code}
    Set Suite Variable    ${temporal_entity_representation_id}

Delete Initial Temporal Entity
    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
+59 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a BadRequestDataException is returned if the Retrieve Temporal Entity request is invalid with respect to pick and omit query params

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

Test Setup          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Retrieve Temporal Entity With Invalid Pick Or Omit Query Params Usage


*** Variables ***
${vehicle_payload_file}=    2020-08-vehicle-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-retrieve    5_7_3    4_21    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-retrieve    5_7_3    4_21    since_v1.8.1
    speed    ${EMPTY}    fuelLevel
02_22_03 RetrieveWithOmitAndAttrs
    [Documentation]    Check that a BadRequestDataException is returned if omit and attrs query params are present
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    ${EMPTY}    speed    fuelLevel


*** Keywords ***
Retrieve Temporal Entity With Invalid Pick Or Omit Query Params Usage
    [Documentation]    Check that a BadRequestDataException is returned if the Retrieve Temporal Entity request is invalid with respect to pick and omit query params
    [Arguments]    ${pick}    ${omit}    ${attrs}
    ${response}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    accept=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    ...    attrs=${attrs}
    ...    pick=${pick}
    ...    omit=${omit}

    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()}

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Vehicle Entity Id
    ${create_response}=    Create Temporal Representation Of Entity
    ...    ${vehicle_payload_file}
    ...    ${temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response.status_code}
    Set Suite Variable    ${temporal_entity_representation_id}

Delete Initial Temporal Entity
    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
+24 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "fuelLevel": [
        {
            "type": "Property",
            "value": 67,
            "instanceId": "urn:ngsi-ld:Instance:7f53145a-998e-4e0b-89fa-62c10be17ffe",
            "observedAt": "2020-08-01T12:03:00Z"
        },
        {
            "type": "Property",
            "value": 53,
            "instanceId": "urn:ngsi-ld:Instance:8563626a-402e-44b2-9756-218a702d5bfd",
            "observedAt": "2020-08-01T13:05:00Z"
        },
        {
            "type": "Property",
            "value": 40,
            "instanceId": "urn:ngsi-ld:Instance:4b750757-3894-433e-a2f2-c95d20076385",
            "observedAt": "2020-08-01T14:07:00Z"
        }
    ]
}
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "fuelLevel": [
        {
            "type": "Property",
            "value": 67,
            "instanceId": "urn:ngsi-ld:Instance:4f363bef-f7e1-4c60-bd90-7eeedbc7eabe",
            "observedAt": "2020-08-01T12:03:00Z"
        },
        {
            "type": "Property",
            "value": 53,
            "instanceId": "urn:ngsi-ld:Instance:cdacbe23-110a-4be2-991e-f8577211814a",
            "observedAt": "2020-08-01T13:05:00Z"
        },
        {
            "type": "Property",
            "value": 40,
            "instanceId": "urn:ngsi-ld:Instance:b41df7f2-731c-4c2e-b92b-060427f1e222",
            "observedAt": "2020-08-01T14:07:00Z"
        }
    ]
}
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "speed": [
        {
            "type": "Property",
            "value": 120,
            "instanceId": "urn:ngsi-ld:Instance:742a20f2-3bb1-4e3c-892f-7a282b93bf6f",
            "observedAt": "2020-08-01T12:03:00Z"
        },
        {
            "type": "Property",
            "value": 80,
            "instanceId": "urn:ngsi-ld:Instance:1bac7961-22de-4259-a040-7eb69ab082cc",
            "observedAt": "2020-08-01T12:05:00Z"
        },
        {
            "type": "Property",
            "value": 100,
            "instanceId": "urn:ngsi-ld:Instance:6ca08d1e-6c8c-4ad2-83cb-7fb8720db827",
            "observedAt": "2020-08-01T12:07:00Z"
        }
    ]
}
 No newline at end of file
Loading