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

Merge branch 'feature/ngsild-null-deletedat-merge-entity' into 'develop'

feat: add TCs for NGSI-LD Null, deletedAt and Merge Entity

See merge request !171
parents 698deec2 cfd649f1
Loading
Loading
Loading
Loading
+66 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the temporal evolution of an entity following the deletedAt temporal property

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

Test Setup          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${vehicle_payload_file}=    vehicle-temporal-representation-different-attributes-types.jsonld


*** Test Cases ***    ATTR_NAME    EXPECTATION_FILENAME
020_17_01 With a Property
    [Tags]    te-retrieve    5_7_3    since_v1.6.1
    fuelLevel    vehicle-temporal-representation-property-020-17.jsonld
020_17_02 With a Relationship
    [Tags]    te-retrieve    5_7_3    since_v1.6.1
    isParkedIn    vehicle-temporal-representation-relationship-020-17.jsonld
020_17_03 With a LanguageProperty
    [Tags]    te-retrieve    5_7_3    4_5_18    since_v1.6.1
    name    vehicle-temporal-representation-languageproperty-020-17.jsonld


*** Keywords ***
Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute
    [Documentation]    Check that one can retrieve the temporal evolution of an entity following the deletedAt temporal property
    [Arguments]    ${attr_name}    ${expectation_filename}
    ${response}=    Delete Entity Attributes
    ...    entityId=${temporal_entity_representation_id}
    ...    attributeId=${attr_name}
    ...    datasetId=${EMPTY}
    ...    deleteAll=false
    ...    context=${ngsild_test_suite_context}

    ${response2}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    timeproperty=deletedAt
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response2.status_code}
    Check Response Body Containing EntityTemporal element
    ...    filename=${expectation_filename}
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    response_body=${response2.json()}
    ...    excluded_regex=deletedAt
    Should Have Value In Json
    ...    json_object=${response2.json()}
    ...    json_path=['${attr_name}']['deletedAt']

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${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}
+69 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the temporal evolution of an entity following the deletedAt temporal property with temporal values

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

Test Setup          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${vehicle_payload_file}=    vehicle-temporal-representation-different-attributes-types.jsonld


*** Test Cases ***    ATTR_NAME    SIMPLIFIED_TEMPORAL_KEY    EXPECTATION_FILENAME
020_18_01 With a Property
    [Tags]    te-retrieve    5_7_3    since_v1.6.1
    fuelLevel    values    vehicle-temporal-values-representation-property-020-18.jsonld
020_18_02 With a Relationship
    [Tags]    te-retrieve    5_7_3    since_v1.6.1
    isParkedIn    objects    vehicle-temporal-values-representation-relationship-020-18.jsonld
020_18_03 With a LanguageProperty
    [Tags]    te-retrieve    5_7_3    4_5_18    since_v1.6.1
    name    languageMaps    vehicle-temporal-values-representation-languageproperty-020-18.jsonld


*** Keywords ***
Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute
    [Documentation]    Check that one can retrieve the temporal evolution of an entity following the deletedAt temporal property with temporal values
    [Arguments]    ${attr_name}    ${simplified_temporal_key}    ${expectation_filename}
    ${response}=    Delete Entity Attributes
    ...    entityId=${temporal_entity_representation_id}
    ...    attributeId=${attr_name}
    ...    datasetId=${EMPTY}
    ...    deleteAll=false
    ...    context=${ngsild_test_suite_context}

    ${response2}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    timeproperty=deletedAt
    ...    options=temporalValues
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response2.status_code}
    # Ignore the deletedAt value when checking the response body
    Check Response Body Containing EntityTemporal element
    ...    filename=${expectation_filename}
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    response_body=${response2.json()}
    ...    excluded_regex=root\\['${attr_name}'\\]\\['${simplified_temporal_key}'\\]\\[0\\]\\[1\\]
    # Check the deletedAt value is present in the response body
    Should Have Value In Json
    ...    json_object=${response2.json()}
    ...    json_path=['${attr_name}']['${simplified_temporal_key}'][0][1]

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${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}
+60 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the temporal evolution of a scope following the deletedAt temporal property

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

Test Setup          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${vehicle_payload_file}=    vehicle-temporal-representation-scope.jsonld


*** Test Cases ***    EXPECTATION_FILENAME
020_19_01 With a Scope
    [Tags]    te-retrieve    4_18    5_7_3    6_19_3_1    since_v1.6.1
    vehicle-temporal-representation-property-020-19.jsonld


*** Keywords ***
Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute
    [Documentation]    Check that one can retrieve the temporal evolution of a scope following the deletedAt temporal property
    [Arguments]    ${expectation_filename}
    ${response}=    Delete Entity Attributes
    ...    entityId=${temporal_entity_representation_id}
    ...    attributeId=scope
    ...    datasetId=${EMPTY}
    ...    deleteAll=false
    ...    context=${ngsild_test_suite_context}

    ${response2}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    timeproperty=deletedAt
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response2.status_code}
    Check Response Body Containing EntityTemporal element
    ...    filename=${expectation_filename}
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    response_body=${response2.json()}
    ...    excluded_regex=deletedAt
    Should Have Value In Json
    ...    json_object=${response2.json()}
    ...    json_path=['scope']['deletedAt']

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${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}
+61 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the temporal evolution of a scope following the deletedAt temporal property with temporal values

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

Test Setup          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${vehicle_payload_file}=    vehicle-temporal-representation-scope.jsonld


*** Test Cases ***    EXPECTATION_FILENAME
020_20_01 With a Scope
    [Tags]    te-retrieve    4_18    5_7_3    6_19_3_1    since_v1.6.1
    vehicle-temporal-representation-property-020-20.jsonld


*** Keywords ***
Delete Temporal Attribute and Retrieve Temporal Evolution of Attribute
    [Documentation]    Check that one can retrieve the temporal evolution of a scope following the deletedAt temporal property with temporal values
    [Arguments]    ${expectation_filename}
    ${response}=    Delete Entity Attributes
    ...    entityId=${temporal_entity_representation_id}
    ...    attributeId=scope
    ...    datasetId=${EMPTY}
    ...    deleteAll=false
    ...    context=${ngsild_test_suite_context}

    ${response2}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    timeproperty=deletedAt
    ...    options=temporalValues
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response2.status_code}
    Check Response Body Containing EntityTemporal element
    ...    filename=${expectation_filename}
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    response_body=${response2.json()}
    ...    excluded_regex=root\\['scope'\\]\\['values'\\]\\[0\\]\\[1\\]
    Should Have Value In Json
    ...    json_object=${response2.json()}
    ...    json_path=['scope']['values'][0][1]

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${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}
+60 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can merge an entity

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Merge Entity Scenarios


*** Variables ***
${building_id_prefix}=          urn:ngsi-ld:Building:
${entity_payload_filename}=     merge/building-merge-data.jsonld


*** Test Cases ***    FILENAME    EXPECTATION_FILENAME
056_01_01 MergeAnEmptyEntity
    [Tags]    e-merge    5_6_17    6_5_3_4    since_v1.6.1
    building-minimal.jsonld    merge/building-non-edited.jsonld
056_01_02 MergeSimpleProperties
    [Tags]    e-merge    5_6_17    6_5_3_4    since_v1.6.1
    building-simple-attributes-second.jsonld    merge/building-attributes-edited.jsonld
056_01_03 MergeSimpleRelationship
    [Tags]    e-merge    5_6_17    6_5_3_4    since_v1.6.1
    building-relationship.jsonld    merge/building-with-relationship.jsonld
056_01_04 MergePropertyWithPartialData
    [Tags]    e-merge    5_6_17    6_5_3_4    since_v1.6.1
    merge/building-only-airQualityLevel-value.jsonld    merge/building-with-changed-airQualityLevel.jsonld


*** Keywords ***
Merge Entity Scenarios
    [Documentation]    Check that one can merge an entity
    [Arguments]    ${filename}    ${expectation_filename}
    ${response}=    Merge Entity
    ...    entity_id=${entity_id}
    ...    entity_filename=${filename}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    ${response1}=    Query Entity
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Response Body Containing Entity element
    ...    expectation_filename=${expectation_filename}
    ...    entity_id=${entity_id}
    ...    response_body=${response1.json()}

Setup Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Set Test Variable    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
Loading