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

feat: add 020_01 020_02 20_03 TPs

parent af4e8db9
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can retrieve the temporal evolution of an entity
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:

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

    Retrieve Temporal Representation Of Entity   ${temporal_entity_representation_id}

    @{expected_temporal_attributes}=  Create List   fuelLevel   speed

    Check Response Status Code Set To  200
    Check Response Body Containing EntityTemporal element       ${expected_temporal_attributes}

    #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  vehicule-temporal-representation-sample.jsonld     ${temporal_entity_representation_id}
    Set Suite Variable  ${temporal_entity_representation_id}
+30 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can retrieve the temporal evolution of an entity using a context
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:

*** Test Case ***
Retrieve the temporal evolution of an entity using a context
    [Documentation]  Check that you can retrieve the temporal evolution of an entity using a context
    [Tags]  mandatory

    Retrieve Temporal Representation Of Entity   ${temporal_entity_representation_id}   context=${fiware_context}

    @{expected_temporal_attributes}=  Create List   speed   fuelLevel

    Check Response Status Code Set To  200
    Check Response Body Containing EntityTemporal element       ${expected_temporal_attributes}

    #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  vehicule-temporal-representation-sample.jsonld     ${temporal_entity_representation_id}
    Set Suite Variable  ${temporal_entity_representation_id}
+29 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can retrieve the temporal evolution of certain attributes of an entity
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:

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

    @{temporal_attributes_to_be_retrieved}=  Create List   fuelLevel
    Retrieve Temporal Representation Of Entity   ${temporal_entity_representation_id}   attrs=${temporal_attributes_to_be_retrieved}    context=${fiware_context}

    Check Response Status Code Set To  200
    Check Response Body Containing EntityTemporal element       ${temporal_attributes_to_be_retrieved}

    #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  vehicule-temporal-representation-sample.jsonld     ${temporal_entity_representation_id}
    Set Suite Variable  ${temporal_entity_representation_id}
+48 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:Vehicle:randomUUID",
   "type":"Vehicle",
   "brandName":[
      {
         "type":"Property",
         "value":"Volvo"
      }
   ],
   "speed":[
      {
         "type":"Property",
         "value":120,
         "observedAt":"2018-08-01T12:03:00Z"
      },
      {
         "type":"Property",
         "value":80,
         "observedAt":"2018-08-01T12:05:00Z"
      },
      {
         "type":"Property",
         "value":100,
         "observedAt":"2018-08-01T12:07:00Z"
      }
   ],
   "fuelLevel":[
      {
         "type":"Property",
         "value":67,
         "observedAt":"2018-08-01T12:03:00Z"
      },
      {
         "type":"Property",
         "value":53,
         "observedAt":"2018-08-01T13:05:00Z"
      },
      {
         "type":"Property",
         "value":40,
         "observedAt":"2018-08-01T14:07:00Z"
      }
   ],
   "@context":[
      "https://fiware.github.io/data-models/context.jsonld",
      "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
   ]
}
 No newline at end of file
+25 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ ${BATCH_UPSERT_ENDPOINT_PATH} entityOperations/upsert
${BATCH_UPDATE_ENDPOINT_PATH}   entityOperations/update
${BATCH_DELETE_ENDPOINT_PATH}   entityOperations/delete
${ENTITIES_ENDPOINT_PATH}       entities
${TEMPORAL_ENTITIES_ENDPOINT_PATH}       temporal/entities
${response}
&{BATCH_OPERATION_ENDPOINT_MAPPING}    create=${BATCH_CREATE_ENDPOINT_PATH}    upsert=${BATCH_UPSERT_ENDPOINT_PATH}    update=${BATCH_UPDATE_ENDPOINT_PATH}    delete=${BATCH_DELETE_ENDPOINT_PATH}

@@ -96,3 +97,27 @@ Batch Request Entities From File
    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST Request      BatchRequest   ${endpoint_url}  data=${file_content}    headers=${headers}
    Set Test Variable  ${response}

Create Temporal Representation Of Entity
    [Arguments]  ${filename}    ${temporal_entity_representation_id}
    ${temporal_entity_representation_payload}=    Load Json From File    ${EXECDIR}/data/temporalEntities/${filename}
    ${temporal_entity_representation}=    Update Value To Json    ${temporal_entity_representation_payload}     $..id   ${temporal_entity_representation_id}

    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST  ${TEMPORAL_ENTITIES_ENDPOINT_PATH}  body=${temporal_entity_representation}  headers=${headers}
    Output  request
    Output  response

Retrieve Temporal Representation Of Entity
    [Arguments]  ${temporal_entity_representation_id}   ${attrs}=${EMPTY}      ${context}=${EMPTY}
    ${attrs_length} =  Get Length  ${attrs}
    &{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}

    ${response}=  GET  ${TEMPORAL_ENTITIES_ENDPOINT_PATH}/${temporal_entity_representation_id}      headers=${headers}      query=${params}
    Output  request
    Output  response
    Set Test Variable  ${response}
 No newline at end of file
Loading