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

feat: add test for simplified temporal representation of entity

parent f5f7c685
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can retrieve the temporal evolution of an entity with the simplified temporal representation
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Suite Setup      Setup Initial Entities

*** Variable ***
${vehicule_id_prefix}=  urn:ngsi-ld:Vehicle:
${vehicle_payload_file}=  vehicule-temporal-representation-sample.jsonld
${vehicle_expectation_file}=  vehicle-simplified-temporal-representation-expectation.jsonld

*** Test Case ***
Retrieve the temporal evolution of an entity with the simplified temporal representation
    [Documentation]  Check that you can retrieve the temporal evolution of an entity with the simplified temporal representation
    [Tags]  mandatory

    @{options}=  Create List   temporalValues
    Retrieve Temporal Representation Of Entity   ${temporal_entity_representation_id}   options=${options}    context=${fiware_context}

    Check Response Status Code Set To  200
    Check Response Body Containing simplified temporal representation of EntityTemporal element       ${vehicle_expectation_file}    ${temporal_entity_representation_id}

    #TODO Call Delete Temporal Representation Of Entity

*** Keywords ***
Setup Initial Entities
    ${temporal_entity_representation_id}=     Generate Random Entity Id    ${vehicule_id_prefix}
    Create Temporal Representation Of Entity  ${vehicle_payload_file}     ${temporal_entity_representation_id}
    Set Suite Variable  ${temporal_entity_representation_id}
+15 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:Vehicle:randomUUID",
   "type":"Vehicle",
   "brandName": "Volvo",
   "speed":[
      [ 120, "2018-08-01T12:03:00Z" ],
      [ 80, "2018-08-01T12:05:00Z" ],
      [ 100, "2018-08-01T12:07:00Z" ]
   ],
   "fuelLevel":[
      [ 67, "2018-08-01T12:03:00Z" ],
      [ 53, "2018-08-01T13:05:00Z" ],
      [ 40, "2018-08-01T14:07:00Z" ]
   ]
}
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
@@ -109,13 +109,15 @@ Create Temporal Representation Of Entity
    Output  response

Retrieve Temporal Representation Of Entity
    [Arguments]  ${temporal_entity_representation_id}   ${attrs}=${EMPTY}      ${context}=${EMPTY}
    [Arguments]  ${temporal_entity_representation_id}   ${attrs}=${EMPTY}      ${options}=${EMPTY}      ${context}=${EMPTY}
    ${attrs_length} =  Get Length  ${attrs}
    ${options_length} =  Get Length  ${options}
    &{headers}=  Create Dictionary
    &{params}=  Create Dictionary

    Run Keyword If     '${context}'!=''       Set To Dictionary   ${headers}    Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json"
    Run Keyword If     ${attrs_length}>0       Set To Dictionary   ${params}       attrs=${attrs}
    Run Keyword If     ${options_length}>0       Set To Dictionary   ${params}       options=${options}

    ${response}=  GET  ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id}      headers=${headers}      query=${params}
    Output  request
+7 −0
Original line number Diff line number Diff line
@@ -39,6 +39,13 @@ Check Response Body Containing EntityTemporal element
        List Should Not Contain Duplicates      ${temporal_attribute}
    END

Check Response Body Containing simplified temporal representation of EntityTemporal element
    [Arguments]     ${filename}    ${temporal_entity_representation_id}
    ${temporal_entity_representation_payload}=    Load Json From File    ${EXECDIR}/data/temporalEntities/expectations/${filename}
    ${temporal_entity_representation}=    Update Value To Json    ${temporal_entity_representation_payload}     $..id   ${temporal_entity_representation_id}

    Dictionaries Should Be Equal    ${response['body']}    ${temporal_entity_representation}

Check Response Body Containing Problem Details Element Containing Detail Element
    [Arguments]     ${response_body}
    Should Not Be Empty     ${response_body['detail']}