Commit 53c821db authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add new inclusive test for purge entities

parent ed39a9c1
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that, when one has an inclusive registration on a Context Broker, one is able to purge entities based on type on both Context Broker and Context Source

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup          Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Test Teardown       Delete Registrations And Stop Context Source Mock Server

*** Variables ***
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D017_01_inc Purge Entities On Both Context Broker And Context Source
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to purge entities based on type on both Context Broker and Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_21

    Set Stub Reply    DELETE    /ngsi-ld/v1/entities?type=Vehicle    204
    ${response}=    Purge Entities    entity_types=Vehicle    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}

    ${stub_count}=    Get Stub Count    DELETE    /ngsi-ld/v1/entities?type=Vehicle
    Should Be True    ${stub_count} > 0

    ${response}=    Retrieve Entity    ${entity_id}
    Check Response Status Code    404    ${response.status_code}

*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    Start Context Source Mock Server

Delete Registrations And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Stop Context Source Mock Server
+67 −0
Original line number Diff line number Diff line
@@ -297,3 +297,70 @@ Retrieve Entity Types
    ...    expected_status=any
    Output    ${response}    Retrieve Entity Types
    RETURN    ${response}

Purge Entities
    [Arguments]
    ...    ${entity_types}=${EMPTY}
    ...    ${entity_ids}=${EMPTY}
    ...    ${attrs}=${EMPTY}
    ...    ${attrs_exclude}=${EMPTY}
    ...    ${entity_id_pattern}=${EMPTY}
    ...    ${q}=${EMPTY}
    ...    ${georel}=${EMPTY}
    ...    ${geometry}=${EMPTY}
    ...    ${geoproperty}=${EMPTY}
    ...    ${scopeq}=${EMPTY}
    ...    ${datasetId}=${EMPTY}
    ...    ${context}=${EMPTY}
    ...    ${broker_url}=${EMPTY}
    ${attrs_length}=    Get Length    ${attrs}
    ${attrs_exclude_length}=    Get Length    ${attrs_exclude}
    ${entity_ids_length}=    Get Length    ${entity_ids}
    ${entity_types_length}=    Get Length    ${entity_types}
    &{headers}=    Create Dictionary
    &{params}=    Create Dictionary
    IF    '${context}'!=''
        ${context_link}=    Build Context Link    ${context}
        Set To Dictionary    ${headers}    Link=${context_link}
    END
    IF    ${attrs_length}>0
        Set To Dictionary    ${params}    attrs=${attrs}
    END
    IF    ${attrs_exclude_length}>0
        Set To Dictionary    ${params}    excludedAttrs=${attrs_exclude}
    END
    IF    ${entity_ids_length}>0
        Set To Dictionary    ${params}    id=${entity_ids}
    END
    IF    ${entity_types_length}>0
        Set To Dictionary    ${params}    type=${entity_types}
    END
    IF    '${entity_id_pattern}'!=''
        Set To Dictionary    ${params}    idPattern=${entity_id_pattern}
    END
    IF    '${q}'!=''
        Set To Dictionary    ${params}    q=${q}
    END
    IF    '${georel}'!=''
        Set To Dictionary    ${params}    georel=${georel}
    END
    IF    '${geometry}'!=''
        Set To Dictionary    ${params}    geometry=${geometry}
    END
    IF    '${geoproperty}'!=''
        Set To Dictionary    ${params}    geoproperty=${geoproperty}
    END
    IF    '${scopeq}'!=''
        Set To Dictionary    ${params}    scopeQ=${scopeq}
    END
    IF    '${datasetId}'!=''
        Set To Dictionary    ${params}    datasetId=${datasetId}
    END
    ${final_url}=    Set Variable If    '${broker_url}' != ''    ${broker_url}    ${url}
    ${response}=    DELETE
    ...    url=${final_url}/${ENTITIES_ENDPOINT_PATH}
    ...    headers=${headers}
    ...    params=${params}
    ...    expected_status=any
    Output    ${response}    Purge Entities
    RETURN    ${response}
 No newline at end of file